This is an automated email from the ASF dual-hosted git repository.
aitozi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-presto.git
The following commit(s) were added to refs/heads/main by this push:
new a48836a fix query failed with map filter (#47)
a48836a is described below
commit a48836a9710df8c1fcbf7fe6aceab8fe0eb6467b
Author: WenjunMin <[email protected]>
AuthorDate: Sun Jan 19 17:10:31 2025 +0800
fix query failed with map filter (#47)
---
.../org/apache/paimon/presto/TestPrestoITCase.java | 69 ++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git
a/paimon-presto-common/src/test/java/org/apache/paimon/presto/TestPrestoITCase.java
b/paimon-presto-common/src/test/java/org/apache/paimon/presto/TestPrestoITCase.java
index e2e8fab..484e492 100644
---
a/paimon-presto-common/src/test/java/org/apache/paimon/presto/TestPrestoITCase.java
+++
b/paimon-presto-common/src/test/java/org/apache/paimon/presto/TestPrestoITCase.java
@@ -52,6 +52,7 @@ import com.facebook.presto.tests.DistributedQueryRunner;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
@@ -273,6 +274,47 @@ public class TestPrestoITCase {
commit.commit(0, writer.prepareCommit(true, 0));
}
+ // table with map field
+ {
+ Path tablePath = new Path(warehouse, "default.db/t_map");
+ RowType rowType =
+ new RowType(
+ Arrays.asList(
+ new DataField(0, "i1", new IntType()),
+ new DataField(1, "i2",
VarCharType.STRING_TYPE),
+ new DataField(
+ 2,
+ "i3",
+ new MapType(new IntType(),
VarCharType.STRING_TYPE))));
+ new SchemaManager(LocalFileIO.create(), tablePath)
+ .createTable(
+ new Schema(
+ rowType.getFields(),
+ ImmutableList.of("i2"),
+ ImmutableList.of("i2", "i1"),
+ ImmutableMap.of("bucket", "1"),
+ ""));
+ FileStoreTable table =
FileStoreTableFactory.create(LocalFileIO.create(), tablePath);
+ InnerTableWrite writer = table.newWrite("user");
+ InnerTableCommit commit = table.newCommit("user");
+ writer.write(
+ GenericRow.of(
+ 1,
+ BinaryString.fromString("20241103"),
+ new GenericMap(ImmutableMap.of(1,
BinaryString.fromString("1")))));
+ writer.write(
+ GenericRow.of(
+ 2,
+ BinaryString.fromString("20241103"),
+ new GenericMap(ImmutableMap.of(1,
BinaryString.fromString("2")))));
+ writer.write(
+ GenericRow.of(
+ 3,
+ BinaryString.fromString("20241104"),
+ new GenericMap(ImmutableMap.of(1,
BinaryString.fromString("1")))));
+ commit.commit(0, writer.prepareCommit(true, 0));
+ }
+
DistributedQueryRunner queryRunner = null;
try {
queryRunner =
@@ -655,6 +697,33 @@ public class TestPrestoITCase {
.isEqualTo("[[1, 20241103, 1], [2, 20241103, 2]]");
}
+ @DataProvider(name = "subscriptsFilterEnabled")
+ public Object[] subscriptsFilterEnabled() {
+ return new Object[] {"false", "true"};
+ }
+
+ @Test(dataProvider = "subscriptsFilterEnabled")
+ public void testQueryMap(String subscriptsFilterEnabled) throws Exception {
+ assertThat(
+ sql(
+ "SELECT * FROM paimon.default.t_map where
upper(i2) = '20241103' and i3[1] = '1'",
+ "range_filters_on_subscripts_enabled",
+ subscriptsFilterEnabled))
+ .isEqualTo("[[1, 20241103, {1=1}]]");
+ assertThat(
+ sql(
+ "SELECT * FROM paimon.default.t_map where
i3[1] = '1' or i3[1] = '2'",
+ "range_filters_on_subscripts_enabled",
+ subscriptsFilterEnabled))
+ .isEqualTo("[[1, 20241103, {1=1}], [2, 20241103, {1=2}], [3,
20241104, {1=1}]]");
+ assertThat(
+ sql(
+ "SELECT * FROM paimon.default.t_map where
i3[1] = '1'",
+ "range_filters_on_subscripts_enabled",
+ subscriptsFilterEnabled))
+ .isEqualTo("[[1, 20241103, {1=1}], [3, 20241104, {1=1}]]");
+ }
+
private String sql(String sql, String key, String value) throws Exception {
Session session =
testSessionBuilder().setCatalogSessionProperty("paimon", key,
value).build();