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 @@ -250,7 +250,9 @@ private LogicalPlan preAggForRandomDistribution(LogicalOlapScan olapScan) {
List<Slot> childOutputSlots = olapScan.computeOutput();
List<Expression> groupByExpressions = new ArrayList<>();
List<NamedExpression> outputExpressions = new ArrayList<>();
List<Column> columns = olapTable.getBaseSchema();
List<Column> columns = olapScan.isIndexSelected()
? olapTable.getSchemaByIndexId(olapScan.getSelectedIndexId())
: olapTable.getBaseSchema();

for (Column col : columns) {
// use exist slot in the plan
Expand Down
6 changes: 6 additions & 0 deletions regression-test/data/statistics/test_analyze_mv.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !test_agg --
1 6
2 9
3 6

19 changes: 19 additions & 0 deletions regression-test/suites/statistics/test_analyze_mv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,25 @@ suite("test_analyze_mv") {
assertEquals("1", result[0][7])
assertEquals("5", result[0][8])

sql """drop table if exists testMvDirectSelect"""
sql """
CREATE TABLE testMvDirectSelect (
key1 int NOT NULL,
key2 int NOT NULL,
value int SUM
)ENGINE=OLAP
AGGREGATE KEY(key1, key2)
COMMENT "OLAP"
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES (
"replication_num" = "1"
);
"""

createMV("CREATE MATERIALIZED VIEW aggMv as select key1, SUM(value) from testMvDirectSelect group by key1;")
sql """insert into testMvDirectSelect values (1, 1, 1), (1, 2, 2), (1, 3, 3), (2, 1, 4), (2, 2, 5), (3, 2, 6)"""
qt_test_agg """select * from testMvDirectSelect index aggMv order by mv_key1"""

sql """drop database if exists test_analyze_mv"""
}