Skip to content

Commit

Permalink
sql: add regression test for previously fixed JSON bug
Browse files Browse the repository at this point in the history
This commit adds a regression test for a bug that was unknowingly fixed
in #99275. See #113103 for more details.

Release note: None
  • Loading branch information
mgartner committed Oct 25, 2023
1 parent 70ba6b9 commit 065eea8
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/json
Original file line number Diff line number Diff line change
Expand Up @@ -973,3 +973,32 @@ SELECT * FROM test_49144 WHERE ("test_49144"."value" -> 'c') > '2.33' ORDER BY 1
----
{"c": 2.5}
{"c": 3}

# Regression test for #113103. Expressions with JSON values are
# composite-sensitive. The optimizer should not assume otherwise and perform
# optimizations that produce incorrect results.
subtest regression_113103

# Order three text values that are cast from logically equivalent JSON values.
query T
SELECT j::TEXT
FROM (VALUES ('1.0'::JSON), ('1'::JSON), ('1.00'::JSON)) v(j)
ORDER BY 1
----
1
1.0
1.00

# Add a filter that holds the JSON values constant to 1. The output should be
# the same as above.
query T
SELECT j::TEXT
FROM (VALUES ('1.0'::JSON), ('1'::JSON), ('1.00'::JSON)) v(j)
WHERE j = '1'::JSON
ORDER BY 1
----
1
1.0
1.00

subtest end

0 comments on commit 065eea8

Please sign in to comment.