Skip to content

bug: JSON not evaluating null #17433

Closed
@rad-pat

Description

@rad-pat

Search before asking

  • I had searched in the issues and found no similar issues.

Version

v1.2.695

What's Wrong?

When trying to query JSON values by key, null values seem to cause issue, leading to error such as

invalid digit found in string while evaluating function `to_int32('null')` in expr `to_int32()`, during run expr: `CAST(get_string(data_table.data (#2), 'key1') AS Int32 NULL)`

How to Reproduce?

CREATE TABLE data_table (
	id INTEGER, 
	name VARCHAR(30) NOT NULL, 
	"data" JSON NOT NULL, 
	nulldata JSON
)

INSERT INTO data_table (name, "data", nulldata) VALUES ('row1', '{"key1": null}', '{"key1": null}')

SELECT CAST(data_table."data" ->> 'key1' AS INTEGER) AS anon_1 
FROM data_table 
WHERE CAST((data_table."data" ->> 'key1') AS INTEGER) IS NULL;

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

Labels

C-bugCategory: something isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions