Enhancement
#11036 fixed queries combining JSON_VALID with JSON operations in filter conditions. It detects a preceding JSON_VALID guard and allows the matching string-to-JSON cast to substitute JSON null for invalid input, so those rows can later be filtered out.
This is a targeted workaround rather than short-circuit evaluation: the guarded expression subtree still executes. Its scope is limited to recognized filter patterns, leaving cases such as projection expressions, OR conditions, and invalid dynamic JSON paths uncovered.
For example:
SELECT id FROM t
WHERE JSON_VALID(doc)
AND JSON_EXTRACT(doc, json_path) IS NOT NULL;
If a row contains both invalid JSON and an invalid JSON path, tolerating the JSON cast error is insufficient: subsequent path evaluation can still fail. When JSON_VALID(doc) is false, the entire right-hand expression should be skipped for that row.
Replace this workaround with general short-circuit evaluation for AND, OR, and two_value_and, adapting ClickHouse's deferred expression evaluation approach to TiFlash. Support filters and projections, preserve TiDB NULL semantics, and retain errors from expressions that must execute.
Evaluation should follow the expression order supplied by TiDB.
Enhancement
#11036 fixed queries combining
JSON_VALIDwith JSON operations in filter conditions. It detects a precedingJSON_VALIDguard and allows the matching string-to-JSON cast to substitute JSON null for invalid input, so those rows can later be filtered out.This is a targeted workaround rather than short-circuit evaluation: the guarded expression subtree still executes. Its scope is limited to recognized filter patterns, leaving cases such as projection expressions, OR conditions, and invalid dynamic JSON paths uncovered.
For example:
If a row contains both invalid JSON and an invalid JSON path, tolerating the JSON cast error is insufficient: subsequent path evaluation can still fail. When
JSON_VALID(doc)is false, the entire right-hand expression should be skipped for that row.Replace this workaround with general short-circuit evaluation for
AND,OR, andtwo_value_and, adapting ClickHouse's deferred expression evaluation approach to TiFlash. Support filters and projections, preserve TiDB NULL semantics, and retain errors from expressions that must execute.Evaluation should follow the expression order supplied by TiDB.