spapin commented on code in PR #18587:
URL: https://github.com/apache/pinot/pull/18587#discussion_r3498578992
##########
pinot-core/src/test/java/org/apache/pinot/queries/JsonExtractScalarTest.java:
##########
@@ -191,6 +191,23 @@ public void
testNullAsDefaultValueWithNullHandlingDisabled() {
);
}
+ @Test(dataProvider = "allJsonColumns")
+ public void testColumnToColumnComparison(String column) {
+ // A JSON last name ("duck", "mouse", ...) is compared as a STRING against
stringColumn ("daffy duck",
+ // "mickey mouse", ...). The two are never equal, so '=' matches no row
and '!=' matches every row.
+ String lastName = "json_extract_scalar(" + column + ", '$.name.last',
'STRING', '')";
+ checkResult("SELECT intColumn FROM testTable WHERE " + lastName + " =
stringColumn", new Object[][]{});
+ checkResult("SELECT intColumn FROM testTable WHERE " + lastName + " !=
stringColumn LIMIT 3",
+ new Object[][]{{1}, {2}, {3}});
+
+ // A JSON id (101, 111, 121, ... for the first rows) is compared
numerically against intColumn (1, 2, 3, ...).
+ // The id is never equal to the row's intColumn, and for the leading rows
it is the larger value.
+ String id = "json_extract_scalar(" + column + ", '$.id', 'INT', '0')";
+ checkResult("SELECT intColumn FROM testTable WHERE " + id + " =
intColumn", new Object[][]{});
Review Comment:
I wouldn't. This would be a test that is there specifically because the
previous implementation was casting to double. So not only the unit test is
tied to the implementation, it is tied to the OLD implementation. I think it's
a headache to think about.
If we want to test large numbers to make sure the property holds, maybe
property testing, i.e. testing random values that covers the int space, would
make more sense. We wouldn't only test values that alias as double, but also
any other edge cases (null values, negative values, etc...)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]