Skip to content

Conversation

Mytherin
Copy link
Collaborator

Fixes #9717

When a struct field can have NULL values, the children of that struct field can also have NULL values transitively. In the linked query list extract set CAN_HAVE_NULL of the child to true, but this did not get properly pushed into the stats of the children of the struct, leading to an incorrect optimization being made. This PR changes the statistics so that Set(StatsInfo::CAN_HAVE_NULL_VALUES) correctly propagates this information to the children of structs.

@Mytherin Mytherin merged commit d1dec15 into duckdb:main Nov 21, 2023
@Mytherin Mytherin deleted the issue9717 branch December 4, 2023 11:45
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 11, 2023
@JRocki
Copy link

JRocki commented Dec 13, 2023

I'm not sure if this is relevant to this specific PR, but I am encountering something related. I have a table with a column of type char that I want to convert to type double. Most values are doubles, but there are a few 'nan' values (characters). I noticed that
try_cast({{ adapter.quote("MY_COLUMN") }}) as double) as numeric_column
would convert everything to a double, but when I the run

select *
from table
where numeric_column is NULL

I didn't see the expected rows where there was 'nan' returned as NULL. However, if I instead run
try_cast(nullif({{ adapter.quote("MY_COLUMN") }}, 'nan') as double) as numeric_column
then the query returns the expected amount of null entries. Is this expected behavior?

@Mytherin
Copy link
Collaborator Author

That sounds like expected behavior to me yes. NaN is different from NULL.

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.

Unable to correctly filter out rows with null values.
2 participants