Skip to content

Commit 66ef942

Browse files
authored
Added test for schema evolution. (#125)
1 parent d2c714c commit 66ef942

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "Running schema evolution test..."
5+
6+
SCENARIO_DIR="{{SCENARIO_DIR}}"
7+
INPUT_PATH="${SCENARIO_DIR}/../insert-scan/input.parquet"
8+
9+
# Create namespace
10+
{{ICE_CLI}} --config {{CLI_CONFIG}} create-namespace ${NAMESPACE_NAME}
11+
echo "OK Created namespace: ${NAMESPACE_NAME}"
12+
13+
# Insert table from iris parquet
14+
{{ICE_CLI}} --config {{CLI_CONFIG}} insert --create-table ${TABLE_NAME} "file://${INPUT_PATH}"
15+
echo "OK Inserted data into ${TABLE_NAME}"
16+
17+
# Alter table: add column only (so same parquet remains valid for second insert)
18+
{{ICE_CLI}} --config {{CLI_CONFIG}} alter-table ${TABLE_NAME} $'[{"op":"add_column","name":"extra","type":"string"}]'
19+
echo "OK Altered table schema"
20+
21+
# Verify schema: expect extra
22+
{{ICE_CLI}} --config {{CLI_CONFIG}} describe -s ${TABLE_NAME} > /tmp/schema_ev_describe.txt
23+
if ! grep -q "extra" /tmp/schema_ev_describe.txt; then
24+
echo "FAIL describe -s missing expected column 'extra'"
25+
cat /tmp/schema_ev_describe.txt
26+
exit 1
27+
fi
28+
echo "OK Schema verified"
29+
30+
# First scan to get baseline row count (scan output: header + data lines)
31+
{{ICE_CLI}} --config {{CLI_CONFIG}} scan ${TABLE_NAME} --limit 500 > /tmp/schema_ev_scan1.txt
32+
FIRST_LINES=$(wc -l < /tmp/schema_ev_scan1.txt)
33+
echo "OK First scan: ${FIRST_LINES} lines"
34+
35+
# Second insert from same parquet (file schema is subset of table after add_column only)
36+
{{ICE_CLI}} --config {{CLI_CONFIG}} insert ${TABLE_NAME} "file://${INPUT_PATH}"
37+
echo "OK Second insert completed"
38+
39+
# Second scan: expect more rows (more lines)
40+
{{ICE_CLI}} --config {{CLI_CONFIG}} scan ${TABLE_NAME} --limit 500 > /tmp/schema_ev_scan2.txt
41+
SECOND_LINES=$(wc -l < /tmp/schema_ev_scan2.txt)
42+
if [ "${SECOND_LINES}" -le "${FIRST_LINES}" ]; then
43+
echo "FAIL second scan should have more lines (got ${SECOND_LINES}, first had ${FIRST_LINES})"
44+
exit 1
45+
fi
46+
echo "OK Second scan: ${SECOND_LINES} lines (rows inserted)"
47+
48+
# Cleanup
49+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-table ${TABLE_NAME}
50+
{{ICE_CLI}} --config {{CLI_CONFIG}} delete-namespace ${NAMESPACE_NAME}
51+
echo "OK Cleanup done"
52+
53+
echo "Schema evolution test completed successfully"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: "Schema evolution (add, drop, rename)"
2+
description: "Tests alter-table: add column, drop column, rename column"
3+
4+
catalogConfig:
5+
warehouse: "s3://test-bucket/warehouse"
6+
7+
env:
8+
NAMESPACE_NAME: "test_schema_ev"
9+
TABLE_NAME: "test_schema_ev.t1"

0 commit comments

Comments
 (0)