Skip to content

Commit 06e66a2

Browse files
committed
ice: Add --s3-region CLI option
1 parent 6c00ad5 commit 06e66a2

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

examples/scratch/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ ice insert --partition='[{"column": "tpep_pickup_datetime", "transform": "day"}]
4646
ice insert --partition='[{"column": "tpep_pickup_datetime", "transform": "year"}]' nyc44.taxis111 -p https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2025-01.parquet
4747

4848
# warning: each parquet file below is ~500mb. this may take a while
49-
AWS_REGION=us-east-2 ice insert btc.transactions -p --s3-no-sign-request \
50-
s3://aws-public-blockchain/v1.0/btc/transactions/\
51-
date=2025-01-01/part-00000-33e8d075-2099-409b-a806-68dd17217d39-c000.snappy.parquet \
52-
s3://aws-public-blockchain/v1.0/btc/transactions/date=2025-01-02/*.parquet
49+
ice insert btc.transactions -p --s3-region=us-east-2 --s3-no-sign-request \
50+
s3://aws-public-blockchain/v1.0/btc/transactions/date=2025-01-01/*.parquet
5351

5452
# upload file to minio using local-mc,
5553
# then add file to the catalog without making a copy

ice/src/main/java/com/altinity/ice/cli/Main.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)