diff --git a/velox/functions/sparksql/tests/StringTest.cpp b/velox/functions/sparksql/tests/StringTest.cpp index d77dd3b3dd28..aea4ac1b2e7e 100644 --- a/velox/functions/sparksql/tests/StringTest.cpp +++ b/velox/functions/sparksql/tests/StringTest.cpp @@ -99,7 +99,7 @@ TEST_F(StringTest, chr) { TEST_F(StringTest, contains) { const auto contains = [&](const std::optional& str, - const std::optional& pattern) { + const std::optional& pattern) { return evaluateOnce("contains(c0, c1)", str, pattern); }; EXPECT_EQ(contains("hello", "ello"), true); @@ -113,8 +113,8 @@ TEST_F(StringTest, contains) { TEST_F(StringTest, conv) { const auto conv = [&](const std::optional& str, - std::optional fromBase, - std::optional toBase) { + const std::optional& fromBase, + const std::optional& toBase) { return evaluateOnce("conv(c0, c1, c2)", str, fromBase, toBase); }; EXPECT_EQ(conv("4", 10, 2), "100"); @@ -174,7 +174,7 @@ TEST_F(StringTest, conv) { TEST_F(StringTest, endsWith) { const auto endsWith = [&](const std::optional& str, - const std::optional& pattern) { + const std::optional& pattern) { return evaluateOnce("endsWith(c0, c1)", str, pattern); }; EXPECT_EQ(endsWith("hello", "ello"), true); @@ -193,7 +193,7 @@ TEST_F(StringTest, endsWith) { TEST_F(StringTest, findInSet) { const auto findInSet = [&](const std::optional& str, - const std::optional& strArray) { + const std::optional& strArray) { return evaluateOnce("find_in_set(c0, c1)", str, strArray); }; EXPECT_EQ(findInSet("ab", "abc,b,ab,c,def"), 3); @@ -228,7 +228,7 @@ TEST_F(StringTest, findInSet) { TEST_F(StringTest, instr) { const auto instr = [&](const std::optional& haystack, - const std::optional& needle) { + const std::optional& needle) { return evaluateOnce("instr(c0, c1)", haystack, needle); }; EXPECT_EQ(instr("SparkSQL", "SQL"), 6); @@ -252,7 +252,7 @@ TEST_F(StringTest, instr) { TEST_F(StringTest, left) { const auto left = [&](const std::optional& str, - std::optional length) { + const std::optional& length) { return evaluateOnce("left(c0, c1)", str, length); }; EXPECT_EQ(left("example", -2), ""); @@ -298,16 +298,17 @@ TEST_F(StringTest, lpad) { std::string invalidPadString = "\xFFΨ\xFF"; const auto lpad = [&](const std::optional& string, - std::optional size) { + const std::optional& size) { return evaluateOnce("lpad(c0, c1)", string, size); }; - const auto lpadWithPadString = [&](const std::optional& string, - std::optional size, - const std::optional& padString) { - return evaluateOnce( - "lpad(c0, c1, c2)", string, size, padString); - }; + const auto lpadWithPadString = + [&](const std::optional& string, + const std::optional& size, + const std::optional& padString) { + return evaluateOnce( + "lpad(c0, c1, c2)", string, size, padString); + }; EXPECT_EQ(" text", lpad("text", 6)); @@ -347,7 +348,7 @@ TEST_F(StringTest, ltrim) { }; const auto ltrimWithTrimStr = [&](const std::optional& trimStr, - const std::optional& srcStr) { + const std::optional& srcStr) { return evaluateOnce("ltrim(c0, c1)", trimStr, srcStr); }; @@ -395,9 +396,9 @@ TEST_F(StringTest, md5) { TEST_F(StringTest, overlayVarchar) { const auto overlay = [&](const std::optional& input, - const std::optional& replace, - std::optional pos, - std::optional len) { + const std::optional& replace, + const std::optional& pos, + const std::optional& len) { // overlay is a keyword of DuckDB, use double quote avoid parse error. return evaluateOnce( "\"overlay\"(c0, c1, c2, c3)", input, replace, pos, len); @@ -422,9 +423,9 @@ TEST_F(StringTest, overlayVarchar) { TEST_F(StringTest, overlayVarbinary) { const auto overlay = [&](const std::optional& input, - const std::optional& replace, - std::optional pos, - std::optional len) { + const std::optional& replace, + const std::optional& pos, + const std::optional& len) { // overlay is a keyword of DuckDB, use double quote avoid parse error. return evaluateOnce( "\"overlay\"(cast(c0 as varbinary), cast(c1 as varbinary), c2, c3)", @@ -452,16 +453,17 @@ TEST_F(StringTest, overlayVarbinary) { TEST_F(StringTest, replace) { const auto replace = [&](const std::optional& str, - const std::optional& replaced) { + const std::optional& replaced) { return evaluateOnce("replace(c0, c1)", str, replaced); }; - const auto replaceWithReplacement = [&](const std::optional& str, - const std::optional& replaced, - const std::optional& replacement) { - return evaluateOnce( - "replace(c0, c1, c2)", str, replaced, replacement); - }; + const auto replaceWithReplacement = + [&](const std::optional& str, + const std::optional& replaced, + const std::optional& replacement) { + return evaluateOnce( + "replace(c0, c1, c2)", str, replaced, replacement); + }; EXPECT_EQ(replace("aaabaac", "a"), "bc"); EXPECT_EQ(replace("aaabaac", ""), "aaabaac"); EXPECT_EQ(replaceWithReplacement("aaabaac", "a", "z"), "zzzbzzc"); @@ -481,16 +483,17 @@ TEST_F(StringTest, rpad) { const std::string invalidPadString = "\xFFΨ\xFF"; const auto rpad = [&](const std::optional& string, - std::optional size) { + const std::optional& size) { return evaluateOnce("rpad(c0, c1)", string, size); }; - const auto rpadWithPadString = [&](const std::optional& string, - std::optional size, - const std::optional& padString) { - return evaluateOnce( - "rpad(c0, c1, c2)", string, size, padString); - }; + const auto rpadWithPadString = + [&](const std::optional& string, + const std::optional& size, + const std::optional& padString) { + return evaluateOnce( + "rpad(c0, c1, c2)", string, size, padString); + }; EXPECT_EQ("text ", rpad("text", 6)); @@ -530,7 +533,7 @@ TEST_F(StringTest, rtrim) { }; const auto rtrimWithTrimStr = [&](const std::optional& trimStr, - const std::optional& srcStr) { + const std::optional& srcStr) { return evaluateOnce("rtrim(c0, c1)", trimStr, srcStr); }; EXPECT_EQ(rtrim(""), ""); @@ -581,7 +584,7 @@ TEST_F(StringTest, sha1) { TEST_F(StringTest, sha2) { const auto sha2 = [&](const std::optional& str, - std::optional bitLength) { + const std::optional& bitLength) { return evaluateOnce( "sha2(cast(c0 as varbinary), c1)", str, bitLength); }; @@ -643,7 +646,7 @@ TEST_F(StringTest, sha2) { TEST_F(StringTest, startsWith) { const auto startsWith = [&](const std::optional& str, - const std::optional& pattern) { + const std::optional& pattern) { return evaluateOnce("startsWith(c0, c1)", str, pattern); }; @@ -659,13 +662,13 @@ TEST_F(StringTest, startsWith) { TEST_F(StringTest, substring) { const auto substring = [&](const std::optional& str, - std::optional start) { + const std::optional& start) { return evaluateOnce("substring(c0, c1)", str, start); }; const auto substringWithLength = [&](const std::optional& str, - std::optional start, - std::optional length) { + const std::optional& start, + const std::optional& length) { return evaluateOnce( "substring(c0, c1, c2)", str, start, length); }; @@ -791,7 +794,7 @@ TEST_F(StringTest, translateNonconstantMatch) { auto exprSet = compileExpression("translate(c0, c1, c2)", rowType); const auto testTranslate = [&](const std::vector& inputs, - const auto& expected) { + const auto& expected) { auto result = evaluate(*exprSet, makeRowVector(inputs)); velox::test::assertEqualVectors(expected, result); }; @@ -824,7 +827,7 @@ TEST_F(StringTest, trim) { }; const auto trimWithTrimStr = [&](const std::optional& trimStr, - const std::optional& srcStr) { + const std::optional& srcStr) { return evaluateOnce("trim(c0, c1)", trimStr, srcStr); };