Repository navigation
fix(sqlfuncs): return SQL NULL from json_equal/aws_policy_equal for NULL args - #933
Conversation
…or NULL args Implements stackql issue stackql#914: json_equal and aws_policy_equal now return SQL NULL (nil) when either argument is SQL NULL, instead of raising an error. Non-NULL malformed/unparseable arguments still raise parse errors; byte-identical aws_policy_equal shortcut preserved. Update golden vectors (cref_null_*) and DIVERGENCES.md accordingly. Signed-off-by: Indra Prasetya <11029197+indraoverflow@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Required regression tests are missing for nullable comparisons and row filtering through the SQL driver, and neither golden file covers both-NULL inputs.
1 open issue
What changed in this PR
Updates StackQL’s SQL equality functions for issue #914 so NULL optional properties yield SQL NULL rather than aborting queries.
Changes:
- Adds NULL propagation to
json_equalandaws_policy_equal, preserving non-NULL parsing behavior and the policy function’s byte-identical shortcut. - Updates four NULL-side golden expectations and documents the new behavior.
| File | Description |
|---|---|
internal/stackql/sqlengine/internal/sqlfuncs/testdata/json_equal.json |
Expects NULL for either NULL argument. |
internal/stackql/sqlengine/internal/sqlfuncs/testdata/aws_policy_equal.json |
Expects NULL for either NULL argument. |
internal/stackql/sqlengine/internal/sqlfuncs/jsonequal.go |
Returns NULL before coercion or parsing; updates documentation. |
internal/stackql/sqlengine/internal/sqlfuncs/DIVERGENCES.md |
Documents NULL results and preserved parse-error behavior. |
internal/stackql/sqlengine/internal/sqlfuncs/awspolicyequal.go |
Returns NULL before comparison; updates documentation. |
Review effort: Balanced
| if a == nil || b == nil { | ||
| return nil, nil //nolint:nilnil // A SQL NULL is a valid scalar result. |
Split existing assertions into helpers and defer SQL row closure without changing the contributor's test scenarios. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Confirmed the NULL behavior fix is not yet in current main (dbd22f7). The latest contributor commit already addresses the Copilot requests for driver-level nullable filtering and both-NULL golden vectors. Added only the minimal test-structure/row-cleanup repair needed to unblock lint. Local CGO_ENABLED=0 tests for sqlengine and sqlfuncs pass; CI-pinned golangci-lint v2.15.0 reports 0 issues for sqlengine/... . Waiting for all CI before merging with original contributor commits preserved. End-to-end Robot coverage will be a separate follow-up PR after this merges. |
jeffreyaven
left a comment
There was a problem hiding this comment.
NULL propagation is absent from current main and the implementation preserves non-NULL parsing behavior. Latest regression tests and both-NULL vectors address the Copilot review. Targeted Go tests and CI-pinned lint pass locally after the test-only lint repair. Merge will wait for all CI checks.
|
Merged after all checks passed, using a merge commit so the original contributor commits are preserved on main. Thank you for the contribution. The separate post-merge follow-up is #934. Its new end-to-end Robot regression identified an additional NULL-handling implementation in OmniSDK WHERE evaluation, addressed independently in stackql-labs/omnisdk#60; the original fix remains intact. |

Implements #914.
json_equalandaws_policy_equalnow return SQL NULL when either argument is SQL NULL, instead of raising an error. Non-NULL malformed/unparseable arguments still raise parse errors; the aws_policy_equal byte-identical shortcut is preserved.Updates golden vectors (
cref_null_*) and DIVERGENCES.md.