Skip to content

fix(sqlfuncs): return SQL NULL from json_equal/aws_policy_equal for NULL args - #933

Merged
jeffreyaven merged 4 commits into
stackql:mainfrom
prascli:fix/json-null-args-914
Nov 17, 2026
Merged

jeffreyaven merged 4 commits into
stackql:mainfrom
prascli:fix/json-null-args-914

Conversation

@prascli

@prascli prascli commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Implements #914.

json_equal and aws_policy_equal now 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.

prascli and others added 2 commits November 16, 2026 09:21
…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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 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_equal and aws_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

Comment on lines +20 to +21
if a == nil || b == nil {
return nil, nil //nolint:nilnil // A SQL NULL is a valid scalar result.
prascli and others added 2 commits November 17, 2026 04:32
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>
@jeffreyaven

Copy link
Copy Markdown
Member

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 jeffreyaven left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@jeffreyaven
jeffreyaven merged commit 9ca163b into stackql:main Nov 17, 2026
32 checks passed
@jeffreyaven

Copy link
Copy Markdown
Member

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.

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.

3 participants