Skip to content

Commit

Permalink
[BugFix] Fix prune column check the case of column error (#55562)
Browse files Browse the repository at this point in the history
Signed-off-by: Seaven <[email protected]>
(cherry picked from commit 88faea0)
  • Loading branch information
Seaven committed Feb 7, 2025
1 parent e8d5c46 commit f01b877
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ public Scope visitTable(TableRelation node, Scope outerScope) {
for (Column column : fullSchema) {
// TODO: avoid analyze visible or not each time, cache it in schema
if (needPruneScanColumns && !column.isKey() &&
!bucketColumns.contains(column.getName()) &&
!partitionColumns.contains(column.getName()) &&
!pruneScanColumns.contains(column.getName().toLowerCase())) {
bucketColumns.stream().noneMatch(column.getName()::equalsIgnoreCase) &&
partitionColumns.stream().noneMatch(column.getName()::equalsIgnoreCase) &&
pruneScanColumns.stream().noneMatch(column.getName()::equalsIgnoreCase)) {
// reduce unnecessary columns init, but must init key columns/bucket columns/partition columns
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public static void beforeClass() throws Exception {
" \"replication_num\" = \"1\"\n" +
");";
starRocksAssert.withTable(createStructTableSql);
String upperColumnTableSql = "CREATE TABLE upper_tbl(\n" +
"Ka1 int, \n" +
"Kb2 varchar(32), \n" +
"Kc3 int, \n" +
"Kd4 int" +
") DISTRIBUTED BY HASH(`Ka1`) BUCKETS 1\n" +
"PROPERTIES (\n" +
" \"replication_num\" = \"1\"\n" +
");";
starRocksAssert.withTable(upperColumnTableSql);
}

@Test
Expand Down Expand Up @@ -468,4 +478,13 @@ public void testTypeKeys() throws Exception {
analyzeFail("select * from tarray order by v5");
analyzeFail("select DENSE_RANK() OVER(partition by v5 order by v4) from tarray");
}
@Test
public void testUpperColumn() {
try {
AnalyzeTestUtil.connectContext.getSessionVariable().setEnableAnalyzePhasePruneColumns(true);
analyzeSuccess("select Ka1 from db.upper_tbl");
} finally {
AnalyzeTestUtil.connectContext.getSessionVariable().setEnableAnalyzePhasePruneColumns(false);
}
}
}

0 comments on commit f01b877

Please sign in to comment.