-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the struct function return the correct data type. #6594
Conversation
4a61c5c
to
2ba5351
Compare
7222c9f
to
e601bc6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me -- thank you @jiangzhx . I suggest one more test to show that the column names are always named "c1, c2, etc" even when they don't align with the table column names
|
||
# Scalar function struct | ||
statement ok | ||
create table simple_struct_test ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please also add an example test where the column names don't happen to line up with the column names?
Like
create table test(x boolean) as values (true);
select struct(x) from test
?
I expect the output is named c1
even though the column is named x
To make the output struct named x
I think would be a significant change to the type resolution code as it would need to get a Schema
rather than a [DataType]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your help.
i have updated the current test case:
create table simple_struct_test (
c1 boolean,
c2 INT,
c3 FLOAT,
c4 DOUBLE,
a VARCHAR,
b TEXT
) as select *
from (values
(true, 1,3.1,3.14,'str','text')
);
it's should cover the scenario you mentioned.
e601bc6
to
12f45b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @jiangzhx
* Make the struct function return the correct data type. * add testcase
Which issue does this PR close?
Error: ArrowError(InvalidArgumentError("column types must match schema types, expected Struct([]) but found Struct([Field { name: "c0", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: "c1", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) at column index 0"))
Closes #6597.
Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?