Skip to content

Conversation

@kyle-cheung
Copy link
Contributor

@kyle-cheung kyle-cheung commented Jan 6, 2026

When running a query like WHERE NOT json -> 'key', DuckDB attempts to apply the NOT to the entire JSON before performing the extraction. This results in a Conversion Error because the JSON string cannot be cast to a numerical/boolean type for negation.

Wrapping the JSON extraction in parentheses resolves the error.

CREATE TABLE test_json AS SELECT JSON '{"is_active": false, "is_true": true}' AS data;

-- Will fail
SELECT * FROM test_json WHERE NOT data -> 'is_active';

-- Will work
SELECT * FROM test_json WHERE NOT (data -> 'is_active');

This is expected to take higher precedence in a future DuckDB release (expected 1.7.0) see here duckdb/duckdb#20399

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

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

Hey @kyle-cheung, thanks for the contribution.

A minor request on my end, should be good to go otherwise.

@georgesittas georgesittas merged commit af50c1c into tobymao:main Jan 7, 2026
9 checks passed
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.

2 participants