diff --git a/cpp/src/gandiva/expr_decomposer.cc b/cpp/src/gandiva/expr_decomposer.cc index 4f198e0ed82ab..1c09d28f5e036 100644 --- a/cpp/src/gandiva/expr_decomposer.cc +++ b/cpp/src/gandiva/expr_decomposer.cc @@ -52,7 +52,7 @@ Status ExprDecomposer::Visit(const FieldNode& node) { // eg. replacing 'like' with 'starts_with' can save function calls at evaluation // time. const FunctionNode ExprDecomposer::TryOptimize(const FunctionNode& node) { - if (node.descriptor()->name() == "like" || node.descriptor()->name() == "ilike") { + if (node.descriptor()->name() == "like") { return LikeHolder::TryOptimize(node); } else { return node; diff --git a/cpp/src/gandiva/like_holder_test.cc b/cpp/src/gandiva/like_holder_test.cc index 925a62d34bbf6..342f3c56c172f 100644 --- a/cpp/src/gandiva/like_holder_test.cc +++ b/cpp/src/gandiva/like_holder_test.cc @@ -277,37 +277,4 @@ TEST_F(TestILikeHolder, TestDot) { EXPECT_FALSE(like("abcd")); } -TEST_F(TestILikeHolder, TestOptimise) { - // optimise for 'starts_with' - auto fnode = LikeHolder::TryOptimize(BuildILike("xy 123z%")); - EXPECT_EQ(fnode.descriptor()->name(), "starts_with"); - EXPECT_EQ(fnode.ToString(), "bool starts_with((string) in, (const string) xy 123z)"); - - // optimise for 'ends_with' - fnode = LikeHolder::TryOptimize(BuildILike("%xyz")); - EXPECT_EQ(fnode.descriptor()->name(), "ends_with"); - EXPECT_EQ(fnode.ToString(), "bool ends_with((string) in, (const string) xyz)"); - - // optimise for 'is_substr' - fnode = LikeHolder::TryOptimize(BuildILike("%abc%")); - EXPECT_EQ(fnode.descriptor()->name(), "is_substr"); - EXPECT_EQ(fnode.ToString(), "bool is_substr((string) in, (const string) abc)"); - - // no optimisation for others. - fnode = LikeHolder::TryOptimize(BuildILike("xyz_")); - EXPECT_EQ(fnode.descriptor()->name(), "ilike"); - - fnode = LikeHolder::TryOptimize(BuildILike("_xyz")); - EXPECT_EQ(fnode.descriptor()->name(), "ilike"); - - fnode = LikeHolder::TryOptimize(BuildILike("_xyz_")); - EXPECT_EQ(fnode.descriptor()->name(), "ilike"); - - fnode = LikeHolder::TryOptimize(BuildILike("%xyz_")); - EXPECT_EQ(fnode.descriptor()->name(), "ilike"); - - fnode = LikeHolder::TryOptimize(BuildILike("x_yz%")); - EXPECT_EQ(fnode.descriptor()->name(), "ilike"); -} - } // namespace gandiva