Binder Error could not find key "key" in struct #11080
Replies: 7 comments 1 reply
-
Dug in more and found the culprit. We changed the Still, like the StackOverflow poster, I would prefer the behavior described (returning NULL for actual NULLS and missing keys alike). Is this possible to arrange, or to have an option in A possible hack-around: in every partition, create a fake JSON with all possible keys. 🤔 |
Beta Was this translation helpful? Give feedback.
-
Hello @liquidcarbon, can you please create a reproducible example for this issue? |
Beta Was this translation helpful? Give feedback.
-
Something like this:
SELECT
a,
a.key,
b,
b.yek,
--b.key,
FROM '/tmp/a.json' This works as expected, even though there's no But if you ask for
And I think it should (have an option to) work and return a column of NULLs for |
Beta Was this translation helpful? Give feedback.
-
Thanks! I'll discuss it with the team. |
Beta Was this translation helpful? Give feedback.
-
Hello, is there an update on this or a workaround? |
Beta Was this translation helpful? Give feedback.
-
Imo, the important things here are (1) consistency (2) availability of some solution. For example, (1) you shouldn't make struct return nulls on missing keys if lists don't return nulls on missing indices as well (or you might even argue if tables don't return null values on non existing column specifiers) (2) it would be perfectly fine to have a function like |
Beta Was this translation helpful? Give feedback.
-
For other query engines like trino/athena, the utility function COALESCE(A.Value, '') works perfectly fine but not with duckdb when A.Value does not exist. As you know schemas evolve over the time, so this is must FEATURE for a query engine. Any solution planning to implement ? or workaround |
Beta Was this translation helpful? Give feedback.
-
What happens?
Hello, I recently updated DuckDB to 0.9.2 and I'm getting hard error on queries that I'm 99% (but not 100%) sure worked before.
When I run
COALESCE(A.Value, '')
I was expecting an empty string both whenA.Value
is NULL as well as whenA.Value
is absent. Now it errors out.I'm not sure how to get around that, because the structure of the JSON files I'm querying is quite variable and the keys are indeed often missing.
Related: https://stackoverflow.com/questions/77188196/is-it-possible-to-suppress-binder-error-could-not-find-key-in-duckdb
To Reproduce
Create a STRUCT with a missing field and try to ask for it.
OS:
Linux
DuckDB Version:
0.9.2
DuckDB Client:
python
Full Name:
Alex
Affiliation:
self
Have you tried this on the latest nightly build?
I have tested with a nightly build
Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
Beta Was this translation helpful? Give feedback.
All reactions