Skip to content
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

Try to auto-cast list_filter input and throw exception when failing #6119

Merged
merged 3 commits into from
Feb 10, 2023

Conversation

taniabogatsch
Copy link
Contributor

This PR addresses one of the two bugs mentioned in #5816. list_filter would throw a runtime error when provided with non-boolean lambda expression results in nested lambdas. Now, we try to auto-cast the expression result to bool, and throw an exception if that fails.

@taniabogatsch taniabogatsch self-assigned this Feb 7, 2023
Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I wonder if this cannot be solved at binding time by forcing the return type of the expression to be boolean. For regular functions this is solved by setting the arguments types - but perhaps for lambdas we need to explicitly call BoundCastExpression::AddCastToType to add the cast to the expression.

Copy link
Collaborator

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks a lot cleaner. One more comment:

src/function/scalar/list/list_lambdas.cpp Outdated Show resolved Hide resolved
@Mytherin Mytherin merged commit 0f0ce6d into duckdb:master Feb 10, 2023
@taniabogatsch taniabogatsch deleted the fix-lambda-bugs branch February 10, 2023 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants