use of com.alibaba.druid.sql.dialect.odps.ast.OdpsValuesTableSource in project druid by alibaba.
the class SchemaStatVisitor method visit.
public boolean visit(SQLIdentifierExpr x) {
String currentTable = getCurrentTable();
if (containsSubQuery(currentTable)) {
return false;
}
String ident = x.toString();
if (variants.containsKey(ident)) {
return false;
}
Column column = null;
if (currentTable != null) {
column = addColumn(currentTable, ident);
if (column != null && isParentGroupBy(x)) {
this.groupByColumns.add(column);
}
x.putAttribute(ATTR_COLUMN, column);
} else {
boolean skip = false;
for (SQLObject parent = x.getParent(); parent != null; parent = parent.getParent()) {
if (parent instanceof SQLSelectQueryBlock) {
SQLTableSource from = ((SQLSelectQueryBlock) parent).getFrom();
if (from instanceof OdpsValuesTableSource) {
skip = true;
break;
}
} else if (parent instanceof SQLSelectQuery) {
break;
}
}
if (!skip) {
column = handleUnkownColumn(ident);
}
if (column != null) {
x.putAttribute(ATTR_COLUMN, column);
}
}
if (column != null) {
SQLObject parent = x.getParent();
if (parent instanceof SQLPrimaryKey) {
column.setPrimaryKey(true);
} else if (parent instanceof SQLUnique) {
column.setUnique(true);
}
setColumn(x, column);
}
return false;
}
use of com.alibaba.druid.sql.dialect.odps.ast.OdpsValuesTableSource in project druid by alibaba.
the class OdpsSelectParser method parseTableSource.
public SQLTableSource parseTableSource() {
if (lexer.token() == Token.VALUES) {
lexer.nextToken();
OdpsValuesTableSource tableSource = new OdpsValuesTableSource();
for (; ; ) {
accept(Token.LPAREN);
SQLListExpr listExpr = new SQLListExpr();
this.exprParser.exprList(listExpr.getItems(), listExpr);
accept(Token.RPAREN);
listExpr.setParent(tableSource);
tableSource.getValues().add(listExpr);
if (lexer.token() == Token.COMMA) {
lexer.nextToken();
continue;
}
break;
}
String alias = this.as();
tableSource.setAlias(alias);
accept(Token.LPAREN);
this.exprParser.names(tableSource.getColumns(), tableSource);
accept(Token.RPAREN);
return tableSource;
}
return super.parseTableSource();
}
Aggregations