@@ -141,9 +141,10 @@ void createTable(
141141 names = {"-p" },
142142 description = "Create table if not exists" )
143143 boolean createTableIfNotExists ,
144+ @ CommandLine .Option (names = {"--s3-region" }) String s3Region ,
144145 @ CommandLine .Option (
145146 names = {"--s3-no-sign-request" },
146- description = "Access input file(s) " )
147+ description = "Access input file(s)" )
147148 boolean s3NoSignRequest ,
148149 @ CommandLine .Option (
149150 arity = "1" ,
@@ -163,6 +164,7 @@ void createTable(
163164 "JSON array of sort orders: [{\" column\" :\" name\" ,\" desc\" :true,\" nullFirst\" :true}]" )
164165 String sortOrderJson )
165166 throws IOException {
167+ setAWSRegion (s3Region );
166168 try (RESTCatalog catalog = loadCatalog (this .configFile ())) {
167169 List <IceSortOrder > sortOrders = new ArrayList <>();
168170 List <IcePartition > partitions = new ArrayList <>();
@@ -223,9 +225,10 @@ void insert(
223225 description =
224226 "Use table credentials to access input files (instead of credentials from execution environment)" )
225227 boolean forceTableAuth ,
228+ @ CommandLine .Option (names = {"--s3-region" }) String s3Region ,
226229 @ CommandLine .Option (
227230 names = {"--s3-no-sign-request" },
228- description = "Access input file(s) " )
231+ description = "Access input file(s)" )
229232 boolean s3NoSignRequest ,
230233 @ CommandLine .Option (
231234 names = "--s3-copy-object" ,
@@ -269,6 +272,7 @@ void insert(
269272 throw new UnsupportedOperationException (
270273 "--s3-no-sign-request + --s3-copy-object is not supported by AWS (see --help for details)" );
271274 }
275+ setAWSRegion (s3Region );
272276 try (RESTCatalog catalog = loadCatalog (this .configFile ())) {
273277 if (dataFiles .length == 1 && "-" .equals (dataFiles [0 ])) {
274278 dataFiles = readInput ().toArray (new String [0 ]);
@@ -326,6 +330,13 @@ void insert(
326330 }
327331 }
328332
333+ // FIXME: do not modify system properties, configure aws sdk instead
334+ private static void setAWSRegion (String v ) {
335+ if (!Strings .isNullOrEmpty (v )) {
336+ System .setProperty ("aws.region" , v );
337+ }
338+ }
339+
329340 private static List <String > readInput () {
330341 List <String > r = new ArrayList <>();
331342 try (Scanner scanner = new Scanner (System .in )) {
0 commit comments