mihaibudiu commented on code in PR #3942:
URL: https://github.com/apache/calcite/pull/3942#discussion_r1739931926
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -15470,6 +15470,111 @@ private static void
checkLogicalOrFunc(SqlOperatorFixture f) {
f.checkAgg("logical_or(x)", values4, isNullValue());
}
+ @Test void testBitAndScalarFunc() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlStdOperatorTable.BITAND, VmName.EXPAND);
+ f.checkFails("bitand(^*^)", "Unknown identifier '\\*'", false);
+ f.checkScalar("bitand(2, 3)", "2", "INTEGER");
+ f.checkType("bitand(CAST(2 AS TINYINT), CAST(6 AS TINYINT))", "TINYINT");
+ f.checkType("bitand(CAST(2 AS SMALLINT), CAST(6 AS SMALLINT))",
"SMALLINT");
+ f.checkType("bitand(CAST(2 AS BIGINT), CAST(6 AS BIGINT))", "BIGINT");
+ f.checkScalar("bitand(CAST(x'0201' AS BINARY(2)), CAST(x'07f9' AS
BINARY(2)))", "0201",
+ "BINARY(2)");
+ f.checkScalar("bitand(CAST(x'0201' AS VARBINARY(2)), CAST(x'07f9' AS
VARBINARY(2)))", "0201",
+ "VARBINARY(2)");
+ f.checkFails("^bitand(1.2, 1.3)^",
+ "Cannot apply 'BITAND' to arguments of type '"
+ + "BITAND\\(<DECIMAL\\(2, 1\\)>, <DECIMAL\\(2, 1\\)>\\)'\\.
Supported form\\(s\\): '"
+ + "BITAND\\(<INTEGER>, <INTEGER>\\)'\n"
+ + "'BITAND\\(<BINARY>, <BINARY>\\)'",
+ false);
+ f.checkFails("^bitand()^",
+ "Invalid number of arguments to function 'BITAND'. Was expecting 2
arguments",
+ false);
+ f.checkFails("^bitand(1)^",
+ "Invalid number of arguments to function 'BITAND'. Was expecting 2
arguments",
+ false);
+ f.checkFails("^bitand(1, 2, 3)^",
+ "Invalid number of arguments to function 'BITAND'. Was expecting 2
arguments",
+ false);
+ f.checkNull("bitand(NULL, 1)");
+ f.checkNull("bitand(1, NULL)");
+ f.checkNull("bitand(NULL, NULL)");
+ f.checkFails("bitand(CAST(x'0201' AS VARBINARY), CAST(x'02' AS
VARBINARY))",
+ "Different length for bitwise operands: the first: 2, the second: 1",
+ true);
+ }
+
+ @Test void testBitOrScalarFunc() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlStdOperatorTable.BITOR, VmName.EXPAND);
+ f.checkFails("bitor(^*^)", "Unknown identifier '\\*'", false);
+ f.checkScalar("bitor(2, 4)", "6", "INTEGER");
+ f.checkType("bitor(CAST(2 AS TINYINT), CAST(6 AS TINYINT))", "TINYINT");
Review Comment:
Can we have a few tests with negative numbers, and a few with negative
shorter integers?
--
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]