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

[BugFix] Disable stats collection for generated columns #54537

Merged
merged 4 commits into from
Jan 2, 2025
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 @@ -369,6 +369,10 @@ public static List<String> getCollectibleColumns(Table table) {
}
List<String> columns = new ArrayList<>();
for (Column column : table.getBaseSchema()) {
// disable stats collection for auto generated columns, see SelectAnalyzer#analyzeSelect
if (column.isGeneratedColumn() && column.getName().startsWith(FeConstants.GENERATED_PARTITION_COLUMN_PREFIX)) {
continue;
}
if (!column.isAggregated()) {
columns.add(column.getName());
} else if (isPrimaryEngine && column.getAggregationType().equals(AggregateType.REPLACE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1535,4 +1535,35 @@ public long getDataSize() {
}
}

@Test
public void testGetCollectibleColumns1() throws Exception {
starRocksAssert.withTable("CREATE TABLE test.t_gen_col (" +
" c1 datetime NOT NULL," +
" c2 bigint," +
" c3 DATETIME NULL AS date_trunc('month', c1) " +
" ) " +
" DUPLICATE KEY(c1) " +
" PARTITION BY (c2, c3) " +
" PROPERTIES('replication_num'='1')");
Table table = starRocksAssert.getTable("test", "t_gen_col");
List<String> cols = StatisticUtils.getCollectibleColumns(table);
Assert.assertTrue(cols.size() == 3);
Assert.assertTrue(cols.contains("c3"));
starRocksAssert.dropTable("test.t_gen_col");
}

@Test
public void testGetCollectibleColumns2() throws Exception {
starRocksAssert.withTable("CREATE TABLE test.t_gen_col (" +
" c1 datetime NOT NULL," +
" c2 bigint" +
" ) " +
" DUPLICATE KEY(c1) " +
" PARTITION BY c2, date_trunc('month', c1) " +
" PROPERTIES('replication_num'='1')");
Table table = starRocksAssert.getTable("test", "t_gen_col");
List<String> cols = StatisticUtils.getCollectibleColumns(table);
Assert.assertTrue(cols.size() == 2);
starRocksAssert.dropTable("test.t_gen_col");
}
}
Loading