Skip to content

Commit 05f2505

Browse files
committed
Add scenario test for delete partition
1 parent 45fbacb commit 05f2505

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Running delete partition test..."
5+
6+
# Create namespace
7+
{{ICE_CLI}} --config {{CLI_CONFIG}} create-namespace ${NAMESPACE_NAME}
8+
echo "OK Created namespace: ${NAMESPACE_NAME}"
9+
10+
# Get the full path to the input file
11+
SCENARIO_DIR="{{SCENARIO_DIR}}"
12+
INPUT_PATH="${SCENARIO_DIR}/${INPUT_FILE}"
13+
14+
# 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}"
17+
18+
# Delete partition for a specific day
19+
output=$({{ICE_CLI}} --config {{CLI_CONFIG}} delete ${TABLE_NAME} --partition "[{\"name\": \"${TRANSFORMED_PARTITION_COLUMN}\", \"values\": [\"${DELETE_PARTITION_DAY}\"]}]" 2>&1)
20+
21+
echo "$output"
22+
23+
line_count=$(echo "$output" | wc -l)
24+
25+
if [ "$line_count" -ne 1 ]; then
26+
echo "FAIL Expected 1 line, got $line_count"
27+
exit 1
28+
fi
29+
30+
if ! echo "$output" | grep -qF "${TRANSFORMED_PARTITION_COLUMN}=${DELETE_PARTITION_DAY}"; then
31+
echo "FAIL Expected output to contain '${TRANSFORMED_PARTITION_COLUMN}=${DELETE_PARTITION_DAY}'"
32+
exit 1
33+
fi
34+
35+
echo "OK Deleted partition with value ${DELETE_PARTITION_DAY}"
36+
37+
# Cleanup
38+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-table ${TABLE_NAME}
39+
echo "OK Deleted table: ${TABLE_NAME}"
40+
41+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-namespace ${NAMESPACE_NAME}
42+
echo "OK Deleted namespace: ${NAMESPACE_NAME}"
43+
44+
echo "Delete partition test completed successfully"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Delete partition
2+
description: Tests deleting individual partitions by value
3+
4+
catalogConfig:
5+
warehouse: s3://test-bucket/warehouse
6+
7+
env:
8+
NAMESPACE_NAME: test_delete_partition
9+
TABLE_NAME: test_delete_partition.tripdata_p_by_day
10+
INPUT_FILE: tripdata.parquet
11+
PARTITION_SPEC: '[{"column":"tpep_pickup_datetime","transform":"day"}]'
12+
PARTITION_COLUMN: tpep_pickup_datetime
13+
TRANSFORMED_PARTITION_COLUMN: tpep_pickup_datetime_day
14+
DELETE_PARTITION_DAY: 2025-01-02
Binary file not shown.

ice/src/main/java/com/altinity/ice/cli/internal/iceberg/Partitioning.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ public static Integer applyTimestampTransform(Table table, String fieldName, Obj
387387
if (transform.isIdentity() || !(value instanceof String s)) {
388388
return null;
389389
}
390+
if (s.isEmpty()) {
391+
return null;
392+
}
390393

391394
Type sourceType = table.schema().findType(partitionField.sourceId());
392395
if (!(sourceType instanceof Types.TimestampType)) {

0 commit comments

Comments
 (0)