Skip to content

Commit 2df33d1

Browse files
committed
test: Add test for inferred partitions
1 parent fbe7781 commit 2df33d1

4 files changed

Lines changed: 54 additions & 17 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Create/delete tables, insert data with `ice insert -p ns1.table1 file://example.
1010

1111
## Installation
1212

13-
Pre-built binaries\* (+ links to Docker images for [ice](https://hub.docker.com/r/altinity/ice) and [ice-rest-catalog](https://hub.docker.com/r/altinity/ice-rest-catalog)) are available form [GitHub Releases](https://github.com/Altinity/ice/releases) page.
13+
Pre-built binaries\* (+ links to Docker images for [ice](https://hub.docker.com/r/altinity/ice) and [ice-rest-catalog](https://hub.docker.com/r/altinity/ice-rest-catalog)) are available from [GitHub Releases](https://github.com/Altinity/ice/releases) page.
1414
> \* currently require `java` 21+ to run (available [here](https://adoptium.net/installation/)).
1515
1616
## Usage
Binary file not shown.

ice-rest-catalog/src/test/resources/scenarios/insert-partitioned/run.sh.tmpl

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,64 @@ echo "OK Created namespace: ${NAMESPACE_NAME}"
99

1010
# Get the full path to the input file
1111
SCENARIO_DIR="{{SCENARIO_DIR}}"
12-
INPUT_PATH="${SCENARIO_DIR}/${INPUT_FILE}"
12+
INPUT_PATH_IRIS="${SCENARIO_DIR}/${INPUT_FILE_IRIS}"
13+
INPUT_PATH_ONTIME="${SCENARIO_DIR}/${INPUT_FILE_ONTIME}"
1314

1415
# Create table with partitioning and insert data
15-
{{ICE_CLI}} --config {{CLI_CONFIG}} insert --create-table ${TABLE_NAME} ${INPUT_PATH} --partition="${PARTITION_SPEC}"
16-
echo "OK Inserted data with partitioning into table ${TABLE_NAME}"
16+
{{ICE_CLI}} --config {{CLI_CONFIG}} insert --create-table ${TABLE_NAME_IRIS} ${INPUT_PATH_IRIS} --partition="${PARTITION_SPEC_IRIS}"
17+
echo "OK Inserted data with partitioning into table ${TABLE_NAME_IRIS}"
1718

1819
# List partitions and validate output
19-
LIST_PARTITIONS_OUT=$(mktemp)
20-
trap "rm -f '${LIST_PARTITIONS_OUT}'" EXIT
21-
{{ICE_CLI}} --config {{CLI_CONFIG}} list-partitions ${TABLE_NAME} > "${LIST_PARTITIONS_OUT}"
22-
if ! grep -q "partitions:" "${LIST_PARTITIONS_OUT}"; then
20+
LIST_PARTITIONS_OUT_IRIS=$(mktemp)
21+
trap "rm -f '${LIST_PARTITIONS_OUT_IRIS}'" EXIT
22+
{{ICE_CLI}} --config {{CLI_CONFIG}} list-partitions ${TABLE_NAME_IRIS} > "${LIST_PARTITIONS_OUT_IRIS}"
23+
if ! grep -q "partitions:" "${LIST_PARTITIONS_OUT_IRIS}"; then
2324
echo "FAIL: list-partitions output missing 'partitions:' section"
24-
cat "${LIST_PARTITIONS_OUT}"
25+
cat "${LIST_PARTITIONS_OUT_IRIS}"
2526
exit 1
2627
fi
27-
if ! grep -qE -- "- *[^=]+=" "${LIST_PARTITIONS_OUT}"; then
28+
if ! grep -qE -- "- *[^=]+=" "${LIST_PARTITIONS_OUT_IRIS}"; then
2829
echo "FAIL: list-partitions output has no partition entries (expected at least one key=value)"
29-
cat "${LIST_PARTITIONS_OUT}"
30+
cat "${LIST_PARTITIONS_OUT_IRIS}"
3031
exit 1
3132
fi
32-
echo "OK Listed and validated partitions for ${TABLE_NAME}"
33+
echo "OK Listed and validated partitions for ${TABLE_NAME_IRIS}"
34+
35+
# Create table using file with single partition
36+
{{ICE_CLI}} --config {{CLI_CONFIG}} insert --create-table ${TABLE_NAME_ONTIME} ${INPUT_PATH_ONTIME} --partition="${PARTITION_SPEC_ONTIME}"
37+
echo "OK Inserted data with partitioning into table ${TABLE_NAME_ONTIME}"
38+
39+
# List partitions and validate output
40+
LIST_PARTITIONS_OUT_ONTIME=$(mktemp)
41+
trap "rm -f '${LIST_PARTITIONS_OUT_ONTIME}'" EXIT
42+
{{ICE_CLI}} --config {{CLI_CONFIG}} list-partitions ${TABLE_NAME_ONTIME} > "${LIST_PARTITIONS_OUT_ONTIME}"
43+
if ! grep -q "partitions:" "${LIST_PARTITIONS_OUT_ONTIME}"; then
44+
echo "FAIL: list-partitions output missing 'partitions:' section"
45+
cat "${LIST_PARTITIONS_OUT_ONTIME}"
46+
exit 1
47+
fi
48+
if ! grep -qE -- "- *[^=]+=" "${LIST_PARTITIONS_OUT_ONTIME}"; then
49+
echo "FAIL: list-partitions output has no partition entries (expected at least one key=value)"
50+
cat "${LIST_PARTITIONS_OUT_ONTIME}"
51+
exit 1
52+
fi
53+
echo "OK Listed and validated partitions for ${TABLE_NAME_ONTIME}"
54+
55+
# Validate data file was inserted to correct partitioned path
56+
57+
FILES_OUT_ONTIME=$({{ICE_CLI}} --config {{CLI_CONFIG}} files ${TABLE_NAME_ONTIME})
58+
59+
if [[ "${FILES_OUT_ONTIME}" != *${EXPECTED_DATA_PATH_ONTIME}* ]]; then
60+
echo "FAIL: expected substring '${EXPECTED_DATA_PATH_ONTIME}' not found in files command output: ${FILES_OUT_ONTIME}"
61+
exit 1
62+
fi
63+
echo "OK Validated correct partitioned data file path for ${TABLE_NAME_ONTIME}"
3364

3465
# Cleanup
35-
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-table ${TABLE_NAME}
36-
echo "OK Deleted table: ${TABLE_NAME}"
66+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-table ${TABLE_NAME_IRIS}
67+
echo "OK Deleted table: ${TABLE_NAME_IRIS}"
68+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-table ${TABLE_NAME_ONTIME}
69+
echo "OK Deleted table: ${TABLE_NAME_ONTIME}"
3770

3871
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-namespace ${NAMESPACE_NAME}
3972
echo "OK Deleted namespace: ${NAMESPACE_NAME}"

ice-rest-catalog/src/test/resources/scenarios/insert-partitioned/scenario.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ catalogConfig:
66

77
env:
88
NAMESPACE_NAME: "test_insert_partitioned"
9-
TABLE_NAME: "test_insert_partitioned.iris_partitioned"
10-
INPUT_FILE: "input.parquet"
11-
PARTITION_SPEC: '[{"column":"variety","transform":"identity"}]'
9+
TABLE_NAME_IRIS: "test_insert_partitioned.iris_partitioned"
10+
TABLE_NAME_ONTIME: "test_insert_partitioned.ontime_partitioned"
11+
INPUT_FILE_IRIS: "input.parquet"
12+
INPUT_FILE_ONTIME: "ontime-2010-01-01.parquet"
13+
PARTITION_SPEC_IRIS: '[{"column":"variety","transform":"identity"}]'
14+
PARTITION_SPEC_ONTIME: '[{"column":"Year"}]'
15+
EXPECTED_DATA_PATH_ONTIME: "s3://test-bucket/warehouse/test_insert_partitioned/ontime_partitioned/data/Year=2010/*.parquet"
1216

0 commit comments

Comments
 (0)