@Override public boolean visit(OdpsSetLabelStatement x) { if (x.getTable() != null) { x.getTable().accept(this); } return false; }
public String getAlias() { if (tableSource == null) { return null; } return tableSource.getAlias(); }
private void parseIndexHintList(SQLTableSource tableSource) { if (lexer.token() == Token.USE) { lexer.nextToken(); MySqlUseIndexHint hint = new MySqlUseIndexHint(); parseIndexHint(hint); tableSource.getHints().add(hint); parseIndexHintList(tableSource); } if (lexer.identifierEquals("IGNORE")) { lexer.nextToken(); MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint(); parseIndexHint(hint); tableSource.getHints().add(hint); parseIndexHintList(tableSource); } if (lexer.identifierEquals("FORCE")) { lexer.nextToken(); MySqlForceIndexHint hint = new MySqlForceIndexHint(); parseIndexHint(hint); tableSource.getHints().add(hint); parseIndexHintList(tableSource); } }
protected SQLTableSource parseLateralView(SQLTableSource tableSource) { accept(Token.VIEW); if ("LATERAL".equalsIgnoreCase(tableSource.getAlias())) { tableSource.setAlias(null); } SQLLateralViewTableSource lateralViewTabSrc = new SQLLateralViewTableSource(); lateralViewTabSrc.setTableSource(tableSource); SQLMethodInvokeExpr udtf = (SQLMethodInvokeExpr) this.exprParser.expr(); lateralViewTabSrc.setMethod(udtf); String alias = as(); lateralViewTabSrc.setAlias(alias); accept(Token.AS); this.exprParser.names(lateralViewTabSrc.getColumns()); return parseTableSourceRest(lateralViewTabSrc); } }
tableSource = ctxTable.findTableSource(owner_hash); SQLTableSource ctxFrom = ctx.getFrom(); if (ctxFrom != null) { tableSource = ctxFrom.findTableSource(owner_hash); tableSource = parentCtxTable.findTableSource(owner_hash); if (tableSource == null) { SQLTableSource ctxFrom = parentCtx.getFrom(); if (ctxFrom != null) { tableSource = ctxFrom.findTableSource(owner_hash); SQLTableSource into = mergeStatement.getInto(); if (into instanceof SQLSubqueryTableSource && into.aliasHashCode64() == owner_hash) { x.setResolvedOwnerObject(into); SQLColumnDefinition column = tableSource.findColumn(x.nameHashCode64()); if (column != null) { x.setResolvedColumn(column);
from.accept(visitor); && ((SQLPropertyExpr) tableExpr).getName().equals("*")) { String alias = ((SQLPropertyExpr) tableExpr).getOwnernName(); SQLTableSource refTableSource = from.findTableSource(alias); if (refTableSource != null) { ((SQLPropertyExpr) tableExpr).setResolvedTableSource(refTableSource); table.accept(visitor); ctx.setTableSource(table);
@Override public boolean visit(OdpsInsertStatement x) { SQLTableSource from = x.getFrom(); if (x.getFrom() != null) { if (from instanceof SQLSubqueryTableSource) { SQLSelect select = ((SQLSubqueryTableSource) from).getSelect(); print0(ucase ? "FROM (" : "from ("); this.indentCount++; println(); select.accept(this); this.indentCount--; println(); print0(") "); print0(x.getFrom().getAlias()); } else { print0(ucase ? "FROM " : "from "); from.accept(this); } println(); } for (int i = 0; i < x.getItems().size(); ++i) { HiveInsert insert = x.getItems().get(i); if (i != 0) { println(); } insert.accept(this); } return false; }
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) { if (tableSource.getAlias() == null || tableSource.getAlias().length() == 0) { Token token = lexer.token; long hash; tableSource.setAlias(alias); rightTableSource.setAlias(this.tableAlias()); SQLExprHint hint = new SQLExprHint(hintExpr); hint.setParent(tableSource); rightTableSource.getHints().add(hint); if (lexer.token == Token.COMMA) { lexer.nextToken(); if (tableSource.aliasHashCode64() == FnvHash.Constants.NATURAL && JdbcConstants.MYSQL.equals(dbType)) { tableSource.setAlias(null); natural = true; if (tableSource.aliasHashCode64() == FnvHash.Constants.LATERAL && lexer.token() == Token.VIEW) { return parseLateralView(tableSource);
ctx.setTableSource(from); from.accept(visitor); } else if (x.getParent() != null && x.getParent().getParent() instanceof HiveInsert && x.getParent().getParent().getParent() instanceof HiveMultiInsertStatement){ column = tableSource.findColumn(propertyExpr.nameHashCode64()); if (column != null) { propertyExpr.setResolvedColumn(column); continue; column = from.findColumn(name_hash); if (column != null) { identExpr.setResolvedColumn(column);
tableSource.setAlias(alias); tableSrc.addAfterComment(lexer.readAndResetComments());
tableSrc.addAfterComment(lexer.readAndResetComments());
@Override public boolean visit(HiveMultiInsertStatement x) { SQLTableSource from = x.getFrom(); if (x.getFrom() != null) { if (from instanceof SQLSubqueryTableSource) { SQLSelect select = ((SQLSubqueryTableSource) from).getSelect(); print0(ucase ? "FROM (" : "from ("); this.indentCount++; println(); select.accept(this); this.indentCount--; println(); print0(") "); print0(x.getFrom().getAlias()); } else { print0(ucase ? "FROM " : "from "); from.accept(this); } println(); } for (int i = 0; i < x.getItems().size(); ++i) { HiveInsert insert = x.getItems().get(i); if (i != 0) { println(); } insert.accept(this); } return false; }
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) { if (tableSource.getAlias() == null || tableSource.getAlias().length() == 0) { Token token = lexer.token; long hash; tableSource.setAlias(alias); rightTableSource.setAlias(this.tableAlias()); SQLExprHint hint = new SQLExprHint(hintExpr); hint.setParent(tableSource); rightTableSource.getHints().add(hint); if (lexer.token == Token.COMMA) { lexer.nextToken(); if (tableSource.aliasHashCode64() == FnvHash.Constants.NATURAL && JdbcConstants.MYSQL.equals(dbType)) { tableSource.setAlias(null); natural = true; if (tableSource.aliasHashCode64() == FnvHash.Constants.LATERAL && lexer.token() == Token.VIEW) { return parseLateralView(tableSource);
protected SQLTableSource parseLateralView(SQLTableSource tableSource) { accept(Token.VIEW); if ("LATERAL".equalsIgnoreCase(tableSource.getAlias())) { tableSource.setAlias(null); } SQLLateralViewTableSource lateralViewTabSrc = new SQLLateralViewTableSource(); lateralViewTabSrc.setTableSource(tableSource); SQLMethodInvokeExpr udtf = (SQLMethodInvokeExpr) this.exprParser.expr(); lateralViewTabSrc.setMethod(udtf); String alias = as(); lateralViewTabSrc.setAlias(alias); accept(Token.AS); this.exprParser.names(lateralViewTabSrc.getColumns()); return parseTableSourceRest(lateralViewTabSrc); } }
tableSource.setAlias(alias); tableSrc.addAfterComment(lexer.readAndResetComments());
tableSource = ctxTable.findTableSource(owner_hash); SQLTableSource ctxFrom = ctx.getFrom(); if (ctxFrom != null) { tableSource = ctxFrom.findTableSource(owner_hash); tableSource = parentCtxTable.findTableSource(owner_hash); if (tableSource == null) { SQLTableSource ctxFrom = parentCtx.getFrom(); if (ctxFrom != null) { tableSource = ctxFrom.findTableSource(owner_hash); SQLTableSource into = mergeStatement.getInto(); if (into instanceof SQLSubqueryTableSource && into.aliasHashCode64() == owner_hash) { x.setResolvedOwnerObject(into); SQLColumnDefinition column = tableSource.findColumn(x.nameHashCode64()); if (column != null) { x.setResolvedColumn(column);
tableSrc.addAfterComment(lexer.readAndResetComments());
protected void printTableSource(SQLTableSource x) { Class<?> clazz = x.getClass(); if (clazz == SQLJoinTableSource.class) { visit((SQLJoinTableSource) x); } else if (clazz == SQLExprTableSource.class) { visit((SQLExprTableSource) x); } else if (clazz == SQLSubqueryTableSource.class) { visit((SQLSubqueryTableSource) x); } else { x.accept(this); } }
public String getAlias() { return into.getAlias(); }
@Override public boolean visit(OdpsInsertStatement x) { SQLTableSource from = x.getFrom(); if (x.getFrom() != null) { if (from instanceof SQLSubqueryTableSource) { SQLSelect select = ((SQLSubqueryTableSource) from).getSelect(); print0(ucase ? "FROM (" : "from ("); this.indentCount++; println(); select.accept(this); this.indentCount--; println(); print0(") "); print0(x.getFrom().getAlias()); } else { print0(ucase ? "FROM " : "from "); from.accept(this); } println(); } for (int i = 0; i < x.getItems().size(); ++i) { HiveInsert insert = x.getItems().get(i); if (i != 0) { println(); } insert.accept(this); } return false; }