[fix](lower_case_table_names) Fix the bug of case-sensitive aliases in the query when lower_case_table_names=1 is set (#7495)
* [fix](lower_case_table_names) Fix the bug of case-sensitive aliases in the query when lower_case_table_names=1 is set
This commit is contained in:
@ -43,6 +43,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -148,6 +149,9 @@ public class TableRef implements ParseNode, Writable {
|
||||
public TableRef(TableName name, String alias, PartitionNames partitionNames, ArrayList<String> commonHints) {
|
||||
this.name = name;
|
||||
if (alias != null) {
|
||||
if (Catalog.isStoredTableNamesLowerCase()) {
|
||||
alias = alias.toLowerCase();
|
||||
}
|
||||
aliases_ = new String[]{alias};
|
||||
hasExplicitAlias_ = true;
|
||||
} else {
|
||||
|
||||
@ -98,6 +98,16 @@ public class TableNameStoredLowercaseTest {
|
||||
dorisAssert.query(sql2).explainQuery();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQueryTableAliasCaseInsensitive() throws Exception {
|
||||
String sql1 = "select T1.siteid, t2.k2 from table1 T1 join table2 T2 on t1.siteid = t2.k1" +
|
||||
" where T2.k5 > 1000 order by t1.siteid";
|
||||
dorisAssert.query(sql1).explainQuery();
|
||||
|
||||
String sql2 = "select t.siteid, T.username from (select * from Table1) T";
|
||||
dorisAssert.query(sql2).explainQuery();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateSameTableFailed() {
|
||||
String TABle2 = "create table db1.TABle2(k1 int, k2 varchar(32), k3 varchar(32)) "
|
||||
|
||||
Reference in New Issue
Block a user