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] Fix prune column check the case of column error (backport #55562) #55616

Merged
merged 2 commits into from
Feb 7, 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 @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import org.junit.Assert;

public class AnalyzeTestUtil {
private static ConnectContext connectContext;
private static StarRocksAssert starRocksAssert;
private static String DB_NAME = "test";
protected static ConnectContext connectContext;
protected static StarRocksAssert starRocksAssert;
protected static String DB_NAME = "test";

public static void init() throws Exception {
Config.enable_experimental_rowstore = true;
Expand Down
Loading