use of com.alibaba.druid.FastsqlException in project druid by alibaba.
the class CalciteMySqlNodeVisitor method visit.
@Override
public boolean visit(SQLExprTableSource x) {
SqlIdentifier table;
SQLExpr expr = x.getExpr();
if (expr instanceof SQLIdentifierExpr) {
table = buildIdentifier((SQLIdentifierExpr) expr);
} else if (expr instanceof SQLPropertyExpr) {
table = buildIdentifier((SQLPropertyExpr) expr);
} else {
throw new FastsqlException("not support : " + expr);
}
if (x.getAlias() != null) {
SqlIdentifier alias = new SqlIdentifier(x.computeAlias(), SqlParserPos.ZERO);
SqlBasicCall as = new SqlBasicCall(SqlStdOperatorTable.AS, new SqlNode[] { table, alias }, SqlParserPos.ZERO);
sqlNode = as;
} else {
sqlNode = table;
}
return false;
}
use of com.alibaba.druid.FastsqlException in project druid by alibaba.
the class CalciteMySqlNodeVisitor method buildIdentifier.
SqlIdentifier buildIdentifier(SQLPropertyExpr x) {
String name = SQLUtils.normalize(x.getName());
if ("*".equals(name)) {
name = "";
}
SQLExpr owner = x.getOwner();
List<String> names;
if (owner instanceof SQLIdentifierExpr) {
names = Arrays.asList(((SQLIdentifierExpr) owner).normalizedName(), name);
} else if (owner instanceof SQLPropertyExpr) {
names = new ArrayList<String>();
buildIdentifier((SQLPropertyExpr) owner, names);
names.add(name);
} else {
throw new FastsqlException("not support : " + owner);
}
return new SqlIdentifier(names, SqlParserPos.ZERO);
}
Aggregations