Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't pushdown like expression with escape in Ignite connector #19452

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ public IgniteClient(
this.connectorExpressionRewriter = JdbcConnectorExpressionRewriterBuilder.newBuilder()
.addStandardRules(this::quoted)
.map("$like(value: varchar, pattern: varchar): boolean").to("value LIKE pattern")
.map("$like(value: varchar, pattern: varchar, escape: varchar(1)): boolean").to("value LIKE pattern ESCAPE escape")
chenjian2664 marked this conversation as resolved.
Show resolved Hide resolved
.build();
this.aggregateFunctionRewriter = new AggregateFunctionRewriter<>(
connectorExpressionRewriter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.trino.plugin.jdbc.BaseJdbcConnectorTest;
import io.trino.sql.planner.plan.FilterNode;
import io.trino.sql.planner.plan.TableScanNode;
import io.trino.testing.QueryRunner;
import io.trino.testing.TestingConnectorBehavior;
import io.trino.testing.sql.SqlExecutor;
Expand All @@ -31,6 +33,7 @@

import static com.google.common.base.Strings.nullToEmpty;
import static io.trino.plugin.ignite.IgniteQueryRunner.createIgniteQueryRunner;
import static io.trino.sql.planner.assertions.PlanMatchPattern.node;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -96,6 +99,34 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
};
}

@Test
public void testLikeWithEscape()
{
try (TestTable testTable = new TestTable(
getQueryRunner()::execute,
"test_like_with_escape",
"(id int, a varchar(4))",
List.of(
"1, 'abce'",
"2, 'abcd'",
"3, 'a%de'"))) {
String tableName = testTable.getName();

assertThat(query("SELECT * FROM " + tableName + " WHERE a LIKE 'a%'"))
.isFullyPushedDown();
assertThat(query("SELECT * FROM " + tableName + " WHERE a LIKE '%c%' ESCAPE '\\'"))
.matches("VALUES (1, 'abce'), (2, 'abcd')")
.isNotFullyPushedDown(node(FilterNode.class, node(TableScanNode.class)));

assertThat(query("SELECT * FROM " + tableName + " WHERE a LIKE 'a\\%d%' ESCAPE '\\'"))
.matches("VALUES (3, 'a%de')")
.isNotFullyPushedDown(node(FilterNode.class, node(TableScanNode.class)));

assertThatThrownBy(() -> onRemoteDatabase().execute("SELECT * FROM " + tableName + " WHERE a LIKE 'a%' ESCAPE '\\'"))
.hasMessageContaining("Failed to execute statement");
}
}

@Test
public void testDatabaseMetadataSearchEscapedWildCardCharacters()
{
Expand Down
Loading