@@ -3199,3 +3199,73 @@ def execute_spark_query(query: str):
31993199 except :
32003200 print ("Dictionary: {}, Allowed Content Types: {}" .format (diction , allowed_content_types ))
32013201 raise
3202+
3203+
3204+ @pytest .mark .parametrize (
3205+ "storage_type" ,
3206+ ["s3" , "azure" , "local" ],
3207+ )
3208+ def test_partition_pruning_with_subquery_set (started_cluster_iceberg_with_spark , storage_type ):
3209+ instance = started_cluster_iceberg_with_spark .instances ["node1" ]
3210+ spark = started_cluster_iceberg_with_spark .spark_session
3211+ TABLE_NAME = "test_partition_pruning_" + storage_type + "_" + get_uuid_str ()
3212+ IN_MEMORY_TABLE = "in_memory_table_" + get_uuid_str ()
3213+
3214+ def execute_spark_query (query : str ):
3215+ return execute_spark_query_general (
3216+ spark ,
3217+ started_cluster_iceberg_with_spark ,
3218+ storage_type ,
3219+ TABLE_NAME ,
3220+ query ,
3221+ )
3222+
3223+ execute_spark_query (
3224+ f"""
3225+ CREATE TABLE { TABLE_NAME } (
3226+ id INT,
3227+ data STRING
3228+ )
3229+ USING iceberg
3230+ PARTITIONED BY (identity(id))
3231+ OPTIONS('format-version'='2')
3232+ """
3233+ )
3234+
3235+ execute_spark_query (
3236+ f"""
3237+ INSERT INTO { TABLE_NAME } VALUES
3238+ (1, 'a'),
3239+ (2, 'b'),
3240+ (3, 'c'),
3241+ (4, 'd'),
3242+ (5, 'e');
3243+ """
3244+ )
3245+
3246+
3247+ creation_expression = get_creation_expression (
3248+ storage_type , TABLE_NAME , started_cluster_iceberg_with_spark , table_function = True
3249+ )
3250+
3251+ instance .query (f"CREATE TABLE { IN_MEMORY_TABLE } (id INT) ENGINE = Memory" )
3252+ instance .query (f"INSERT INTO { IN_MEMORY_TABLE } VALUES (2), (4)" )
3253+
3254+
3255+ def check_validity_and_get_prunned_files (select_expression ):
3256+ settings1 = {
3257+ "use_iceberg_partition_pruning" : 0
3258+ }
3259+ settings2 = {
3260+ "use_iceberg_partition_pruning" : 1
3261+ }
3262+ return check_validity_and_get_prunned_files_general (
3263+ instance , TABLE_NAME , settings1 , settings2 , 'IcebergPartitionPrunedFiles' , select_expression
3264+ )
3265+
3266+ assert (
3267+ check_validity_and_get_prunned_files (
3268+ f"SELECT * FROM { creation_expression } WHERE id in (SELECT id FROM { IN_MEMORY_TABLE } ) ORDER BY ALL"
3269+ )
3270+ == 3
3271+ )
0 commit comments