xuzifu666 commented on code in PR #4180:
URL: https://github.com/apache/calcite/pull/4180#discussion_r1944609330
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5756,6 +5756,47 @@ void testBitGetFunc(SqlOperatorFixture f, String
functionName) {
f.checkNull("from_base32(cast (null as varchar))");
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6815">[CALCITE-6815]
+ * Add bin function (enabled in Hive and Spark library)</a>. */
+ @Test void testBin() {
+// final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.BIN);
+ final SqlOperatorFixture f0 =
Fixtures.forOperators(true).setFor(SqlLibraryOperators.BIN);
+ f0.checkFails("^bin(x'')^",
+ "No match found for function signature BIN\\(<BINARY>\\)",
+ false);
+ final List<SqlLibrary> libraries =
+ ImmutableList.of(SqlLibrary.SPARK, SqlLibrary.HIVE);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkString("bin(12)",
+ "1100",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(1)",
+ "1",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(01)",
+ "1",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(000)",
+ "0",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(-000)",
+ "0",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(-11)",
+ "1111111111111111111111111111111111111111111111111111111111110101",
+ "VARCHAR NOT NULL");
+ f.checkString("bin(-1)",
+ "1111111111111111111111111111111111111111111111111111111111111111",
+ "VARCHAR NOT NULL");
Review Comment:
Done
--
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]