Skip to content
Merged
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 @@ -52,6 +52,7 @@
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;
Expand Down Expand Up @@ -273,6 +274,47 @@ protected QueryRunner createQueryRunner() throws Exception {
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 =
Expand Down Expand Up @@ -655,6 +697,33 @@ public void testPartitionPushDown5() throws Exception {
.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();
Expand Down
Loading