danny0405 commented on a change in pull request #13865: URL: https://github.com/apache/flink/pull/13865#discussion_r518578072
########## File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/functions/SqlFunctionUtils.java ########## @@ -1116,4 +1116,26 @@ public static float struncate(float b0) { public static float struncate(float b0, int b1) { return (float) doubleValue(struncate(castFrom((double) b0, 38, 18), b1)); } + + /** + * Compare between two byte arrays. + * The result is 1 if array1 is great than array2, + * -1 if array1 is less than array2 and 0 if array1 is equal array2. + * Note: Currently, this is used in {@code ScalarOperatorGens} + * for comparing two fields of binary or varbinary type. + * + * @param array1 byte array1 to be compared. + * @param array2 byte array2 to be compared. + * @return Target value. + */ + public static int byteArrayCompare(byte[] array1, byte[] array2) { Review comment: ```java /** * Compares two byte arrays in lexicographical order. * * <p>The result is * positive if {@code array1} is great than {@code array2}, * negative if {@code array1} is less than {@code array2} and * 0 if {@code array1} is equal to {@code array2}. * * <p>Note: Currently, this is used in {@code ScalarOperatorGens} * for comparing two fields of binary or varbinary type. * * @param array1 byte array to compare. * @param array2 byte array to compare. * @return an Integer indicating which one is bigger */ ``` ########## File path: flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/expressions/ScalarOperatorsTest.scala ########## @@ -62,6 +62,40 @@ class ScalarOperatorsTest extends ScalarOperatorsTestBase { ) } + @Test + def testCompareOperator(): Unit= { + + // f18 and f19 have same length. + testSqlApi( + "f18 > f19", + "true") Review comment: We may also need to add some test in `SqlExpressionTest.testComparisonFunctions` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org