Skip to content

Commit

Permalink
Fix show variables where failed (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
imay authored and chaoyli committed Aug 18, 2017
1 parent f5882c5 commit 3edd06f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions fe/src/com/baidu/palo/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.baidu.palo.catalog.Catalog;
import com.baidu.palo.catalog.Column;
import com.baidu.palo.catalog.Database;
import com.baidu.palo.catalog.InfoSchemaDb;
import com.baidu.palo.catalog.Table;
import com.baidu.palo.cluster.ClusterNamespace;
import com.baidu.palo.catalog.Type;
Expand Down Expand Up @@ -525,6 +526,10 @@ public SlotDescriptor registerColumnRef(TableName tblName, String colName) throw
if (tblName == null) {
d = resolveColumnRef(colName);
} else {
if (InfoSchemaDb.isInfoSchemaDb(tblName.getDb()) ||
(tblName.getDb() == null && InfoSchemaDb.isInfoSchemaDb(getDefaultDb()))) {
tblName = new TableName(tblName.getDb(), tblName.getTbl().toLowerCase());
}
d = resolveColumnRef(tblName, colName);
}
if (d == null && hasAncestors() && isSubquery) {
Expand Down
4 changes: 2 additions & 2 deletions fe/src/com/baidu/palo/analysis/ExprSubstitutionMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public ExprSubstitutionMap() {
}

// Only used to convert show statement to select statement
public ExprSubstitutionMap(boolean check_analyzed) {
public ExprSubstitutionMap(boolean checkAnalyzed) {
this(Lists.<Expr>newArrayList(), Lists.<Expr>newArrayList());
this.checkAnalyzed_ = false;
this.checkAnalyzed_ = checkAnalyzed;
}

public ExprSubstitutionMap(List<Expr> lhs, List<Expr> rhs) {
Expand Down
2 changes: 1 addition & 1 deletion fe/src/com/baidu/palo/analysis/ShowVariablesStmt.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public SelectStmt toSelectStmt(Analyzer analyzer) {
analyze(analyzer);
// Columns
SelectList selectList = new SelectList();
ExprSubstitutionMap aliasMap = new ExprSubstitutionMap();
ExprSubstitutionMap aliasMap = new ExprSubstitutionMap(false);
TableName tableName = null;
if (type == SetType.GLOBAL) {
tableName = new TableName(InfoSchemaDb.getDatabaseName(), "GLOBAL_VARIABLES");
Expand Down
11 changes: 11 additions & 0 deletions fe/src/com/baidu/palo/catalog/InfoSchemaDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,15 @@ public Table getTable(String name) {
public static String getFullInfoSchemaDbName(String cluster) {
return ClusterNamespace.getDbFullName(cluster, DATABASE_NAME);
}

public static boolean isInfoSchemaDb(String dbName) {
if (dbName == null) {
return false;
}
String[] ele = dbName.split(ClusterNamespace.CLUSTER_DELIMITER);
if (ele.length == 2) {
dbName = ele[1];
}
return DATABASE_NAME.equalsIgnoreCase(dbName);
}
}

0 comments on commit 3edd06f

Please sign in to comment.