@@ -2057,6 +2057,39 @@ async fn test_round_trip_date_part_display() -> Result<()> {
20572057 Ok ( ( ) )
20582058}
20592059
2060+ #[ tokio:: test]
2061+ async fn test_tpch_part_in_list_query_with_real_parquet_data ( ) -> Result < ( ) > {
2062+ use datafusion_common:: test_util:: datafusion_test_data;
2063+
2064+ let ctx = SessionContext :: new ( ) ;
2065+
2066+ // Register the TPC-H part table using the local test data
2067+ let test_data = datafusion_test_data ( ) ;
2068+ let table_sql = format ! (
2069+ "CREATE EXTERNAL TABLE part STORED AS PARQUET LOCATION '{test_data}/tpch_part_small.parquet'"
2070+ ) ;
2071+ ctx. sql ( & table_sql) . await . map_err ( |e| {
2072+ DataFusionError :: External ( format ! ( "Failed to create part table: {e}" ) . into ( ) )
2073+ } ) ?;
2074+
2075+ // Test the exact problematic query
2076+ let sql =
2077+ "SELECT p_size FROM part WHERE p_size IN (14, 6, 5, 31) and p_partkey > 1000" ;
2078+
2079+ let logical_plan = ctx. sql ( sql) . await ?. into_unoptimized_plan ( ) ;
2080+ let optimized_plan = ctx. state ( ) . optimize ( & logical_plan) ?;
2081+ let physical_plan = ctx. state ( ) . create_physical_plan ( & optimized_plan) . await ?;
2082+
2083+ // Serialize the physical plan - bug may happen here already but not necessarily manifests
2084+ let codec = DefaultPhysicalExtensionCodec { } ;
2085+ let proto = PhysicalPlanNode :: try_from_physical_plan ( physical_plan. clone ( ) , & codec) ?;
2086+
2087+ // This will fail with the bug, but should succeed when fixed
2088+ let _deserialized_plan =
2089+ proto. try_into_physical_plan ( & ctx, ctx. runtime_env ( ) . as_ref ( ) , & codec) ?;
2090+ Ok ( ( ) )
2091+ }
2092+
20602093#[ tokio:: test]
20612094/// Tests that we can serialize an unoptimized "analyze" plan and it will work on the other end
20622095async fn analyze_roundtrip_unoptimized ( ) -> Result < ( ) > {
@@ -2090,6 +2123,5 @@ async fn analyze_roundtrip_unoptimized() -> Result<()> {
20902123 let physical_planner =
20912124 datafusion:: physical_planner:: DefaultPhysicalPlanner :: default ( ) ;
20922125 physical_planner. optimize_physical_plan ( unoptimized, & session_state, |_, _| { } ) ?;
2093-
20942126 Ok ( ( ) )
20952127}
0 commit comments