cockroachdb / cockroachdb/cockroach
sql/jsonpath: comparison expression with non-existent path should return `false`
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
CockroachDB and PG are inconsistent in the following example:
PG:
```
> CREATE TABLE t1 (a int, b jsonb);
> INSERT INTO t1 VALUES (1, '{"a": 1}');
> SELECT a, jsonb_path_query(b, '$.l.b == 123') FROM t1 ORDER BY a;
a | jsonb_path_query
---+------------------
1 | false
```
CRDB:
```
> CREATE TABLE t1 (a int, b jsonb);
> INSERT INTO t1 VALUES (1, '{"a": 1}');
> SELECT a, jsonb_path_query(b, '$.l.b == 123') FROM t1 ORDER BY a;
a | jsonb_path_query
----+-------------------
1 | null
(1 row)
```
For `SELECT a, jsonb_path_query(b, '$.l.b == 123') FROM t1 ORDER BY a;`, PG returns `false`, while CockroachDB returns `null`
Jira issue: CRDB-55009
Contributor guide
Research direction
Start by reproducing the jsonb_path_query example from the issue in CockroachDB and PostgreSQL, confirming the null-versus-false difference for a non-existent path. Trace the SQL JSONPath implementation and its existing tests, then add coverage for this query and verify that the result matches PostgreSQL without changing other JSONPath behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100