Apache DataFusion SQL Query Engine
Use UDTF name in logical plan table scan (#16468)
Jack Eadie85eebcd25dfb
diff --git a/datafusion/sql/src/relation/mod.rs b/datafusion/sql/src/relation/mod.rsindex 88a32a2183..1c5a8ff4d2 100644--- a/datafusion/sql/src/relation/mod.rs+++ b/datafusion/sql/src/relation/mod.rs@@ -66,7 +66,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {.get_table_function_source(&tbl_func_name, args)?;let plan = LogicalPlanBuilder::scan(TableReference::Bare {- table: "tmp_table".into(),+ table: format!("{tbl_func_name}()").into(),},provider,None,diff --git a/datafusion/sqllogictest/test_files/array.slt b/datafusion/sqllogictest/test_files/array.sltindex cb2394af06..6ccaf4bdf8 100644--- a/datafusion/sqllogictest/test_files/array.slt+++ b/datafusion/sqllogictest/test_files/array.slt@@ -6073,8 +6073,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]@@ -6102,8 +6102,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]@@ -6131,8 +6131,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]@@ -6162,8 +6162,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: array_has(LargeList([7f4b18de3cfeb9b4ac78c381ee2ad278, a, b, c]), substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)))-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: array_has(LargeList([7f4b18de3cfeb9b4ac78c381ee2ad278, a, b, c]), substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)))+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]@@ -6191,8 +6191,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IN ([Utf8View("7f4b18de3cfeb9b4ac78c381ee2ad278"), Utf8View("a"), Utf8View("b"), Utf8View("c")])+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]@@ -6222,8 +6222,8 @@ logical_plan03)----SubqueryAlias: test04)------SubqueryAlias: t05)--------Projection:-06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL)-07)------------TableScan: tmp_table projection=[value]+06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL)+07)------------TableScan: generate_series() projection=[value]physical_plan01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]diff --git a/datafusion/sqllogictest/test_files/spark/array/array.slt b/datafusion/sqllogictest/test_files/spark/array/array.sltindex 1caf2239fb..57aa080be3 100644--- a/datafusion/sqllogictest/test_files/spark/array/array.slt+++ b/datafusion/sqllogictest/test_files/spark/array/array.slt@@ -25,4 +25,3 @@## PySpark 3.5.5 Result: {'array(1, 2, 3)': [1, 2, 3], 'typeof(array(1, 2, 3))': 'array<int>', 'typeof(1)': 'int', 'typeof(2)': 'int', 'typeof(3)': 'int'}#query#SELECT array(1::int, 2::int, 3::int);-diff --git a/datafusion/sqllogictest/test_files/spark/array/array_repeat.slt b/datafusion/sqllogictest/test_files/spark/array/array_repeat.sltindex 33779bf626..544c39608f 100644--- a/datafusion/sqllogictest/test_files/spark/array/array_repeat.slt+++ b/datafusion/sqllogictest/test_files/spark/array/array_repeat.slt@@ -25,4 +25,3 @@## PySpark 3.5.5 Result: {'array_repeat(123, 2)': ['123', '123'], 'typeof(array_repeat(123, 2))': 'array<string>', 'typeof(123)': 'string', 'typeof(2)': 'int'}#query#SELECT array_repeat('123'::string, 2::int);-diff --git a/datafusion/sqllogictest/test_files/spark/array/sequence.slt b/datafusion/sqllogictest/test_files/spark/array/sequence.sltindex 60df815b1d..bb4aa06bfd 100644--- a/datafusion/sqllogictest/test_files/spark/array/sequence.slt+++ b/datafusion/sqllogictest/test_files/spark/array/sequence.slt@@ -30,4 +30,3 @@## PySpark 3.5.5 Result: {'sequence(5, 1)': [5, 4, 3, 2, 1], 'typeof(sequence(5, 1))': 'array<int>', 'typeof(5)': 'int', 'typeof(1)': 'int'}#query#SELECT sequence(5::int, 1::int);-diff --git a/datafusion/sqllogictest/test_files/table_functions.slt b/datafusion/sqllogictest/test_files/table_functions.sltindex 4cc8084811..ad33d9dd0a 100644--- a/datafusion/sqllogictest/test_files/table_functions.slt+++ b/datafusion/sqllogictest/test_files/table_functions.slt@@ -153,7 +153,7 @@ SELECT * FROM generate_series(1, 5, NULL)query TTEXPLAIN SELECT * FROM generate_series(1, 5)-----logical_plan TableScan: tmp_table projection=[value]+logical_plan TableScan: generate_series() projection=[value]physical_plan LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=1, end=5, batch_size=8192]#@@ -276,7 +276,7 @@ SELECT * FROM range(1, 5, NULL)query TTEXPLAIN SELECT * FROM range(1, 5)-----logical_plan TableScan: tmp_table projection=[value]+logical_plan TableScan: range() projection=[value]physical_plan LazyMemoryExec: partitions=1, batch_generators=[range: start=1, end=5, batch_size=8192]#