Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: shuming.li <[email protected]>
  • Loading branch information
LiShuMing committed Dec 31, 2024
1 parent bf81bb5 commit 940212a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,10 @@ public static List<String> getCollectibleColumns(Table table) {
isPrimaryEngine = KeysType.PRIMARY_KEYS.equals(((OlapTable) table).getKeysType());
}
List<String> columns = new ArrayList<>();
Set<String> partitionColumns = Sets.newHashSet(table.getPartitionColumnNames());
for (Column column : table.getBaseSchema()) {
// disable stats collection for generated columns
if (column.isGeneratedColumn()) {
// 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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,7 @@ public long getDataSize() {
}

@Test
public void testGetCollectibleColumns() throws Exception {
public void testGetCollectibleColumns1() throws Exception {
starRocksAssert.withTable("CREATE TABLE test.t_gen_col (" +
" c1 datetime NOT NULL," +
" c2 bigint," +
Expand All @@ -1547,8 +1547,23 @@ public void testGetCollectibleColumns() throws Exception {
" 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);
Assert.assertTrue(!cols.contains("c3"));
starRocksAssert.dropTable("test.t_gen_col");
}
}

0 comments on commit 940212a

Please sign in to comment.