datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

UNION ALL with null constants results in Schema error

Open alamb opened this issue 1 year ago • 1 comments

Describe the bug

UNION ALL with null constants results in Schema error

To Reproduce

Run the following query from https://github.com/apache/datafusion/blob/main/datafusion/sqllogictest/test_files/metadata.slt

query T
select name from (
  SELECT nonnull_name as name FROM "table_with_metadata"
  UNION ALL
  SELECT NULL::string as name
) group by name order by name;
----
no_bar
no_baz
no_foo
NULL

It results with

External error: query failed: DataFusion error: Schema error: No field named nonnull_name. Valid fields are table_with_metadata.id, table_with_metadata.name, table_with_metadata.l_name. [SQL] select name from ( SELECT nonnull_name as name FROM "table_with_metadata" UNION ALL SELECT NULL::string as name ) group by name order by name; at test_files/metadata.slt:127 Error: Execution("1 failures") error: test failed, to rerun pass `-p datafusion-sqllogictest --test sqllogictests`

Expected behavior

Query should complete

Additional context

No response

alamb avatar Oct 18 '24 19:10 alamb

@wiedld is working on this one I believe -- see https://github.com/apache/datafusion/pull/12954

alamb avatar Oct 18 '24 19:10 alamb

I believe @itsjunetime may have some time to work on this this week.

alamb avatar Oct 21 '24 16:10 alamb

take

itsjunetime avatar Oct 22 '24 21:10 itsjunetime