Skip to content
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 @@ -55,14 +55,18 @@ public Rule build() {
LogicalOlapScan olapScan = filter.child();
OlapTable table = olapScan.getTable();
Builder<Long> selectedTabletIdsBuilder = ImmutableList.builder();
for (Long id : olapScan.getSelectedPartitionIds()) {
Partition partition = table.getPartition(id);
MaterializedIndex index = partition.getIndex(olapScan.getSelectedIndexId());
selectedTabletIdsBuilder
.addAll(getSelectedTabletIds(filter.getConjuncts(), index,
olapScan.getSelectedIndexId() == olapScan.getTable()
.getBaseIndexId(),
partition.getDistributionInfo()));
if (olapScan.getSelectedTabletIds().isEmpty()) {
for (Long id : olapScan.getSelectedPartitionIds()) {
Partition partition = table.getPartition(id);
MaterializedIndex index = partition.getIndex(olapScan.getSelectedIndexId());
selectedTabletIdsBuilder
.addAll(getSelectedTabletIds(filter.getConjuncts(), index,
olapScan.getSelectedIndexId() == olapScan.getTable()
.getBaseIndexId(),
partition.getDistributionInfo()));
}
} else {
selectedTabletIdsBuilder.addAll(olapScan.getSelectedTabletIds());
}
List<Long> selectedTabletIds = selectedTabletIdsBuilder.build();
if (new HashSet(selectedTabletIds).equals(new HashSet(olapScan.getSelectedTabletIds()))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,27 @@
-- !select4 --

-- !select5 --
1 doris 19

-- !select6 --
2 nereids 18

-- !select7 --
1 doris 19

-- !select8 --
1 doris 19

-- !select9 --

-- !select10 --
1 doris 19

-- !select11 --

-- !select12 --

-- !select13 --

-- !no_partition_1 --
1 doris 19
Expand All @@ -29,3 +48,11 @@

-- !no_partition_4 --

-- !no_partition_5 --
2 nereids 18

-- !no_partition_6 --
2 nereids 18

-- !no_partition_7 --

Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,24 @@ suite("select_with_tablets") {
// result should be empty because TABLET(${res[0][0]}) is not belonged to partition between_20_70.
order_qt_select4 """ SELECT * FROM ${table_name1} PARTITION between_20_70 TABLET(${res[0][0]}) """

order_qt_select5 """ SELECT * FROM ${table_name1} where id < 2 """
order_qt_select6 """ SELECT * FROM ${table_name1} TABLET(${res[0][0]}) where id = 2 """
order_qt_select7 """ SELECT * FROM ${table_name1} TABLET(${res[0][0]}) where id < 2 """
order_qt_select8 """ SELECT * FROM ${table_name1} PARTITION less_than_20 TABLET(${res[0][0]}) where id < 2 """
// result of order_qt_select9 should be empty
order_qt_select9 """ SELECT * FROM ${table_name1} PARTITION between_20_70 TABLET(${res[0][0]}) where id < 2"""
order_qt_select10 """ SELECT * FROM ${table_name1} PARTITION less_than_20 where id < 2"""
// result of order_qt_select11 should be empty
order_qt_select11 """ SELECT * FROM ${table_name1} PARTITION between_20_70 where id < 2"""

res = sql """ show tablets from ${table_name1} where version = 1 """
assertTrue(res.size() == 2)
assertEquals("1", res[0][4])
assertEquals("1", res[1][4])
// result should be empty because TABLET(${res[0][0]}) does not have data.
order_qt_select5 """ SELECT * FROM ${table_name1} TABLET(${res[0][0]}) """
order_qt_select12 """ SELECT * FROM ${table_name1} TABLET(${res[0][0]}) """
// result should be empty because TABLET(${res[1][0]}) does not have data.
order_qt_select6 """ SELECT * FROM ${table_name1} TABLET(${res[1][0]}) """
order_qt_select13 """ SELECT * FROM ${table_name1} TABLET(${res[1][0]}) """

// Test non-partitioned table
def table_no_partition = "table_no_partition"
Expand All @@ -87,4 +97,8 @@ suite("select_with_tablets") {
order_qt_no_partition_2 """ SELECT * FROM ${table_no_partition} TABLET(${res[0][0]}) """
order_qt_no_partition_3 """ SELECT * FROM ${table_no_partition} TABLET(${res[1][0]}) """
order_qt_no_partition_4 """ SELECT * FROM ${table_no_partition} TABLET(${res[2][0]}) """

order_qt_no_partition_5 """ SELECT * FROM ${table_no_partition} where id = 2 """
order_qt_no_partition_6 """ SELECT * FROM ${table_no_partition} TABLET(${res[0][0]}) where id = 2 """
order_qt_no_partition_7 """ SELECT * FROM ${table_no_partition} TABLET(${res[0][0]}) where id > 2 """
}