-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix logical vs physical schema mismatch for aliased now()
#12951
Fix logical vs physical schema mismatch for aliased now()
#12951
Conversation
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.
Looks all good to me, thanks for figuring out this one.
now()
@@ -84,4 +84,8 @@ impl ScalarUDFImpl for NowFunc { | |||
ScalarValue::TimestampNanosecond(now_ts, Some("+00:00".into())), | |||
))) | |||
} | |||
|
|||
fn is_nullable(&self, _args: &[Expr], _schema: &dyn ExprSchema) -> bool { |
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.
now can never be nullable
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.
Thank you @wiedld and @itsjunetime
@@ -125,5 +125,21 @@ NULL NULL l_bar | |||
|
|||
|
|||
|
|||
query P rowsort |
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.
👍
)) | ||
GROUP BY ts | ||
ORDER BY ts | ||
LIMIT 1; |
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.
I verified that without the code in this PR, this test fails like this:
External error: query failed: DataFusion error: Schema error: No field named ts. Valid fields are table_with_metadata.id, table_with_metadata.name, table_with_metadata.l_name.
[SQL] SELECT ts
FROM ((
SELECT now() AS ts
FROM table_with_metadata
) UNION ALL (
SELECT ts
FROM table_with_metadata
))
GROUP BY ts
ORDER BY ts
LIMIT 1;
at test_files/metadata.slt:128
Which issue does this PR close?
Part of #12733
We found another bug for aliased now() columns.
Rationale for this change
See the reproducer in the first commit.
Both of the next two commits are required for the fix.
What changes are included in this PR?
get_field_metadata
should handle aliased columns.Also, the
now()
udf is not nullable.Are these changes tested?
Yes.
Are there any user-facing changes?
Not really.
Only that the now() udf will return not-nullable (instead of the default impl).