You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "tanclary (via GitHub)" <gi...@apache.org> on 2023/07/26 17:32:50 UTC
[GitHub] [calcite] tanclary commented on a diff in pull request #3330: [CALCITE-5851] Add LEVENSHTEIN function (enabled in Hive and Spark library)
tanclary commented on code in PR #3330:
URL: https://github.com/apache/calcite/pull/3330#discussion_r1275282393
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -4320,6 +4320,23 @@ static void checkRlikeFails(SqlOperatorFixture f) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.MYSQL), consumer);
}
+ @Test void testLevenshtein() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.LEVENSHTEIN);
+ f0.checkFails("^levenshtein('abc', 'abc')^",
+ "No match found for function signature LEVENSHTEIN\\(<CHARACTER>, <CHARACTER>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkScalar("levenshtein('', '')", 0, "INTEGER NOT NULL");
+ f.checkScalar("levenshtein('abc', 'abc')", 0, "INTEGER NOT NULL");
+ f.checkScalar("levenshtein('kitten', 'sitting')", 3, "INTEGER NOT NULL");
+ f.checkScalar("levenshtein('frog', 'fog')", 1, "INTEGER NOT NULL");
+ f.checkScalar("levenshtein(_UTF8'\u4F60\u597D', _UTF8'\u4F60\u5F88\u597D')",
+ 1, "INTEGER NOT NULL");
Review Comment:
What is the expected behavior if the second argument is null?
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org