Skip to content

Conversation

@wiedld
Copy link
Contributor

@wiedld wiedld commented Oct 15, 2024

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).

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) functions Changes to functions implementation labels Oct 15, 2024
@wiedld wiedld marked this pull request as ready for review October 15, 2024 21:32
Copy link
Contributor

@itsjunetime itsjunetime left a 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.

@alamb alamb changed the title Fix logical vs physical schema mismatch for aliased now(). Fix logical vs physical schema mismatch for aliased now() Oct 15, 2024
)))
}

fn is_nullable(&self, _args: &[Expr], _schema: &dyn ExprSchema) -> bool {
Copy link
Contributor

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

Copy link
Contributor

@alamb alamb left a 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




query P rowsort
Copy link
Contributor

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;
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

functions Changes to functions implementation physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants