Skip to content

Commit 99b6b12

Browse files
committed
Restore ctas and rtas
1 parent 82af784 commit 99b6b12

2 files changed

Lines changed: 0 additions & 118 deletions

File tree

integration_tests/src/main/python/iceberg/iceberg_ctas_test.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -328,62 +328,3 @@ def test_ctas_aqe(spark_tmp_table_factory, partition_col_sql):
328328
table_prop,
329329
partition_col_sql=partition_col_sql,
330330
conf=conf)
331-
332-
333-
@iceberg
334-
@ignore_order(local=True)
335-
@pytest.mark.skipif(is_iceberg_remote_catalog(), reason="Skip for remote catalog to reduce test time")
336-
def test_ctas_from_table_after_drop_partition_field(spark_tmp_table_factory):
337-
"""Test CTAS with partitioned target after source table drops a partition field (void transform).
338-
339-
When a partition field is dropped, Iceberg creates a 'void transform' -
340-
the field remains in the partition spec but no longer affects partitioning.
341-
This test verifies CTAS still runs correctly on GPU after partition evolution.
342-
"""
343-
base_table_name = get_full_table_name(spark_tmp_table_factory)
344-
cpu_table_name = f"{base_table_name}_cpu"
345-
gpu_table_name = f"{base_table_name}_gpu"
346-
347-
table_prop = {"format-version": "2"}
348-
# Use two partition columns so after dropping one, we still have at least one
349-
partition_col_sql = "bucket(8, _c2), bucket(8, _c3)"
350-
351-
# Create partitioned tables with initial data
352-
create_iceberg_table(cpu_table_name, partition_col_sql=partition_col_sql, table_prop=table_prop)
353-
create_iceberg_table(gpu_table_name, partition_col_sql=partition_col_sql, table_prop=table_prop)
354-
355-
# Insert initial data into tables before partition evolution
356-
def insert_initial_data(spark, table_name):
357-
df = gen_df(spark, list(zip(iceberg_base_table_cols, iceberg_gens_list)), seed=42)
358-
df.writeTo(table_name).append()
359-
360-
with_cpu_session(lambda spark: insert_initial_data(spark, cpu_table_name))
361-
with_cpu_session(lambda spark: insert_initial_data(spark, gpu_table_name))
362-
363-
# Drop one partition field on both tables (creates void transform)
364-
def drop_partition_field(spark, table_name):
365-
spark.sql(f"ALTER TABLE {table_name} DROP PARTITION FIELD bucket(8, _c2)")
366-
367-
with_cpu_session(lambda spark: drop_partition_field(spark, cpu_table_name))
368-
with_cpu_session(lambda spark: drop_partition_field(spark, gpu_table_name))
369-
370-
# CTAS after partition evolution - generate data inline with same seed
371-
def execute_ctas(spark, target_table):
372-
df = gen_df(spark, list(zip(iceberg_base_table_cols, iceberg_gens_list)), seed=43)
373-
view_name = spark_tmp_table_factory.get()
374-
df.createOrReplaceTempView(view_name)
375-
spark.sql(f"DROP TABLE IF EXISTS {target_table}")
376-
props_sql = _props_to_sql(table_prop)
377-
spark.sql(
378-
f"CREATE TABLE {target_table} USING ICEBERG "
379-
f"TBLPROPERTIES ({props_sql}) AS SELECT * FROM {view_name}")
380-
381-
with_gpu_session(lambda spark: execute_ctas(spark, gpu_table_name),
382-
conf=iceberg_write_enabled_conf)
383-
with_cpu_session(lambda spark: execute_ctas(spark, cpu_table_name),
384-
conf=iceberg_write_enabled_conf)
385-
386-
# Compare results
387-
cpu_data = with_cpu_session(lambda spark: spark.table(cpu_table_name).collect())
388-
gpu_data = with_cpu_session(lambda spark: spark.table(gpu_table_name).collect())
389-
assert_equal_with_local_sort(cpu_data, gpu_data)

integration_tests/src/main/python/iceberg/iceberg_rtas_test.py

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -381,62 +381,3 @@ def test_rtas_aqe(spark_tmp_table_factory, partition_col_sql):
381381
partition_col_sql=partition_col_sql,
382382
create_or_replace=False,
383383
conf=conf)
384-
385-
386-
@iceberg
387-
@ignore_order(local=True)
388-
@pytest.mark.skipif(is_iceberg_remote_catalog(), reason="Skip for remote catalog to reduce test time")
389-
def test_rtas_after_drop_partition_field(spark_tmp_table_factory):
390-
"""Test REPLACE TABLE AS SELECT on table after dropping a partition field (void transform).
391-
392-
When a partition field is dropped, Iceberg creates a 'void transform' -
393-
the field remains in the partition spec but no longer affects partitioning.
394-
This test verifies RTAS still runs correctly on GPU after partition evolution.
395-
"""
396-
base_table_name = get_full_table_name(spark_tmp_table_factory)
397-
cpu_table_name = f"{base_table_name}_cpu"
398-
gpu_table_name = f"{base_table_name}_gpu"
399-
400-
table_prop = {"format-version": "2"}
401-
# Use two partition columns so after dropping one, we still have at least one
402-
partition_col_sql = "bucket(8, _c2), bucket(8, _c3)"
403-
404-
# Create partitioned tables with initial data
405-
create_iceberg_table(cpu_table_name, partition_col_sql=partition_col_sql, table_prop=table_prop)
406-
create_iceberg_table(gpu_table_name, partition_col_sql=partition_col_sql, table_prop=table_prop)
407-
408-
# Insert initial data into tables before partition evolution
409-
def insert_initial_data(spark, table_name):
410-
df = gen_df(spark, list(zip(iceberg_base_table_cols, iceberg_gens_list)), seed=42)
411-
df.writeTo(table_name).append()
412-
413-
with_cpu_session(lambda spark: insert_initial_data(spark, cpu_table_name))
414-
with_cpu_session(lambda spark: insert_initial_data(spark, gpu_table_name))
415-
416-
# Drop one partition field on both tables (creates void transform)
417-
def drop_partition_field(spark, table_name):
418-
spark.sql(f"ALTER TABLE {table_name} DROP PARTITION FIELD bucket(8, _c2)")
419-
420-
with_cpu_session(lambda spark: drop_partition_field(spark, cpu_table_name))
421-
with_cpu_session(lambda spark: drop_partition_field(spark, gpu_table_name))
422-
423-
# REPLACE TABLE AS SELECT after partition evolution
424-
# Generate data inline with same seed to ensure identical data for both sessions
425-
def execute_rtas(spark, table_name):
426-
df = gen_df(spark, list(zip(iceberg_base_table_cols, iceberg_gens_list)), seed=43)
427-
view_name = spark_tmp_table_factory.get()
428-
df.createOrReplaceTempView(view_name)
429-
props_sql = _props_to_sql(table_prop)
430-
spark.sql(
431-
f"REPLACE TABLE {table_name} USING ICEBERG "
432-
f"TBLPROPERTIES ({props_sql}) AS SELECT * FROM {view_name}")
433-
434-
with_gpu_session(lambda spark: execute_rtas(spark, gpu_table_name),
435-
conf=iceberg_write_enabled_conf)
436-
with_cpu_session(lambda spark: execute_rtas(spark, cpu_table_name),
437-
conf=iceberg_write_enabled_conf)
438-
439-
# Compare results
440-
cpu_data = with_cpu_session(lambda spark: spark.table(cpu_table_name).collect())
441-
gpu_data = with_cpu_session(lambda spark: spark.table(gpu_table_name).collect())
442-
assert_equal_with_local_sort(cpu_data, gpu_data)

0 commit comments

Comments
 (0)