Skip to content

Commit 85eebcd

Browse files
authored
Use UDTF name in logical plan table scan (#16468)
* use UDTF name in logical plan table scan * update sqllogictest
1 parent 7cecc18 commit 85eebcd

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

datafusion/sql/src/relation/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
6666
.get_table_function_source(&tbl_func_name, args)?;
6767
let plan = LogicalPlanBuilder::scan(
6868
TableReference::Bare {
69-
table: "tmp_table".into(),
69+
table: format!("{tbl_func_name}()").into(),
7070
},
7171
provider,
7272
None,

datafusion/sqllogictest/test_files/array.slt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6073,8 +6073,8 @@ logical_plan
60736073
03)----SubqueryAlias: test
60746074
04)------SubqueryAlias: t
60756075
05)--------Projection:
6076-
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")])
6077-
07)------------TableScan: tmp_table projection=[value]
6076+
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")])
6077+
07)------------TableScan: generate_series() projection=[value]
60786078
physical_plan
60796079
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
60806080
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
@@ -6102,8 +6102,8 @@ logical_plan
61026102
03)----SubqueryAlias: test
61036103
04)------SubqueryAlias: t
61046104
05)--------Projection:
6105-
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")])
6106-
07)------------TableScan: tmp_table projection=[value]
6105+
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")])
6106+
07)------------TableScan: generate_series() projection=[value]
61076107
physical_plan
61086108
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
61096109
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
@@ -6131,8 +6131,8 @@ logical_plan
61316131
03)----SubqueryAlias: test
61326132
04)------SubqueryAlias: t
61336133
05)--------Projection:
6134-
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")])
6135-
07)------------TableScan: tmp_table projection=[value]
6134+
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")])
6135+
07)------------TableScan: generate_series() projection=[value]
61366136
physical_plan
61376137
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
61386138
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
@@ -6162,8 +6162,8 @@ logical_plan
61626162
03)----SubqueryAlias: test
61636163
04)------SubqueryAlias: t
61646164
05)--------Projection:
6165-
06)----------Filter: array_has(LargeList([7f4b18de3cfeb9b4ac78c381ee2ad278, a, b, c]), substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)))
6166-
07)------------TableScan: tmp_table projection=[value]
6165+
06)----------Filter: array_has(LargeList([7f4b18de3cfeb9b4ac78c381ee2ad278, a, b, c]), substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)))
6166+
07)------------TableScan: generate_series() projection=[value]
61676167
physical_plan
61686168
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
61696169
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
@@ -6191,8 +6191,8 @@ logical_plan
61916191
03)----SubqueryAlias: test
61926192
04)------SubqueryAlias: t
61936193
05)--------Projection:
6194-
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")])
6195-
07)------------TableScan: tmp_table projection=[value]
6194+
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")])
6195+
07)------------TableScan: generate_series() projection=[value]
61966196
physical_plan
61976197
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
61986198
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]
@@ -6222,8 +6222,8 @@ logical_plan
62226222
03)----SubqueryAlias: test
62236223
04)------SubqueryAlias: t
62246224
05)--------Projection:
6225-
06)----------Filter: substr(CAST(md5(CAST(tmp_table.value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL)
6226-
07)------------TableScan: tmp_table projection=[value]
6225+
06)----------Filter: substr(CAST(md5(CAST(generate_series().value AS Utf8View)) AS Utf8View), Int64(1), Int64(32)) IS NOT NULL OR Boolean(NULL)
6226+
07)------------TableScan: generate_series() projection=[value]
62276227
physical_plan
62286228
01)ProjectionExec: expr=[count(Int64(1))@0 as count(*)]
62296229
02)--AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))]

datafusion/sqllogictest/test_files/spark/array/array.slt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@
2525
## 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'}
2626
#query
2727
#SELECT array(1::int, 2::int, 3::int);
28-

datafusion/sqllogictest/test_files/spark/array/array_repeat.slt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@
2525
## PySpark 3.5.5 Result: {'array_repeat(123, 2)': ['123', '123'], 'typeof(array_repeat(123, 2))': 'array<string>', 'typeof(123)': 'string', 'typeof(2)': 'int'}
2626
#query
2727
#SELECT array_repeat('123'::string, 2::int);
28-

datafusion/sqllogictest/test_files/spark/array/sequence.slt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@
3030
## 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'}
3131
#query
3232
#SELECT sequence(5::int, 1::int);
33-

datafusion/sqllogictest/test_files/table_functions.slt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ SELECT * FROM generate_series(1, 5, NULL)
153153
query TT
154154
EXPLAIN SELECT * FROM generate_series(1, 5)
155155
----
156-
logical_plan TableScan: tmp_table projection=[value]
156+
logical_plan TableScan: generate_series() projection=[value]
157157
physical_plan LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=1, end=5, batch_size=8192]
158158

159159
#
@@ -276,7 +276,7 @@ SELECT * FROM range(1, 5, NULL)
276276
query TT
277277
EXPLAIN SELECT * FROM range(1, 5)
278278
----
279-
logical_plan TableScan: tmp_table projection=[value]
279+
logical_plan TableScan: range() projection=[value]
280280
physical_plan LazyMemoryExec: partitions=1, batch_generators=[range: start=1, end=5, batch_size=8192]
281281

282282
#

0 commit comments

Comments
 (0)