public SQLSubqueryTableSource clone() { SQLSubqueryTableSource x = new SQLSubqueryTableSource(); cloneTo(x); return x; }
public void setFrom(SQLSelect select, String alias) { if (select == null) { this.from = null; return; } SQLSubqueryTableSource from = new SQLSubqueryTableSource(select); from.setAlias(alias); this.setFrom(from); }
private static String createCountUseSubQuery(SQLSelect select, String dbType) { SQLSelectQueryBlock countSelectQuery = createQueryBlock(dbType); SQLSelectItem countItem = createCountItem(dbType); countSelectQuery.getSelectList().add(countItem); SQLSubqueryTableSource fromSubquery = new SQLSubqueryTableSource(select); fromSubquery.setAlias("ALIAS_COUNT"); countSelectQuery.setFrom(fromSubquery); SQLSelect countSelect = new SQLSelect(countSelectQuery); SQLSelectStatement countStmt = new SQLSelectStatement(countSelect, dbType); return SQLUtils.toSQLString(countStmt, dbType); }
static void resolve(SchemaResolveVisitor visitor, SQLParameter x) { SQLName name = x.getName(); if (name instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) name).setResolvedParameter(x); } SQLExpr expr = x.getDefaultValue(); SchemaResolveVisitor.Context ctx = null; if (expr != null) { if (expr instanceof SQLQueryExpr) { ctx = visitor.createContext(x); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(((SQLQueryExpr) expr).getSubQuery()); tableSource.setParent(x); tableSource.setAlias(x.getName().getSimpleName()); ctx.setTableSource(tableSource); } expr.accept(visitor); } if (ctx != null) { visitor.popContext(); } }
countQueryBlock.getSelectList().add(new SQLSelectItem(new SQLAllColumnExpr())); countQueryBlock.setFrom(new SQLSubqueryTableSource(select.clone(), "XX")); countQueryBlock.getSelectList().add(new SQLSelectItem(aggregateExpr, "ROWNUM")); countQueryBlock.setFrom(new SQLSubqueryTableSource(select.clone(), "XX")); offsetQueryBlock.setFrom(new SQLSubqueryTableSource(new SQLSelect(countQueryBlock), "XXX")); offsetQueryBlock.setWhere(pageCondition);
countQueryBlock.getSelectList().add(new SQLSelectItem(new SQLAllColumnExpr())); countQueryBlock.setFrom(new SQLSubqueryTableSource(select.clone(), "XX")); countQueryBlock.getSelectList().add(new SQLSelectItem(new SQLPropertyExpr(new SQLIdentifierExpr("XX"), "*"))); countQueryBlock.setFrom(new SQLSubqueryTableSource(select.clone(), "XX")); offsetQueryBlock.setFrom(new SQLSubqueryTableSource(new SQLSelect(countQueryBlock), "XXX")); offsetQueryBlock.setWhere(pageCondition);
public boolean visit(OracleForStatement x) { Context ctx = createContext(x); SQLName index = x.getIndex(); SQLExpr range = x.getRange(); if (index != null) { SQLDeclareItem declareItem = new SQLDeclareItem(index, null); declareItem.setParent(x); if (index instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) index).setResolvedDeclareItem(declareItem); } declareItem.setResolvedObject(range); ctx.declare(declareItem); if (range instanceof SQLQueryExpr) { SQLSelect select = ((SQLQueryExpr) range).getSubQuery(); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(select); declareItem.setResolvedObject(tableSource); } index.accept(this); } if (range != null) { range.accept(this); } for (SQLStatement stmt : x.getStatements()) { stmt.accept(this); } popContext(); return false; }
public SQLStatement parseInsert() { OdpsInsertStatement stmt = new OdpsInsertStatement(); if (lexer.token() == Token.FROM) { lexer.nextToken(); if (lexer.token() == Token.IDENTIFIER) { SQLName tableName = this.exprParser.name(); SQLExprTableSource from = new SQLExprTableSource(tableName); stmt.setFrom(from); } else { accept(Token.LPAREN); SQLSelectParser selectParser = createSQLSelectParser(); SQLSelect select = selectParser.select(); accept(Token.RPAREN); String alias = lexer.stringVal(); accept(Token.IDENTIFIER); SQLSubqueryTableSource from = new SQLSubqueryTableSource(select, alias); stmt.setFrom(from); } } for (;;) { HiveInsert insert = parseHiveInsert(); stmt.addItem(insert); if (lexer.token() != Token.INSERT) { break; } } return stmt; }
countQueryBlock.getSelectList().add(new SQLSelectItem(new SQLIdentifierExpr("ROWNUM"), "RN")); countQueryBlock.setFrom(new SQLSubqueryTableSource(select.clone(), "XX")); countQueryBlock.setWhere(new SQLBinaryOpExpr(new SQLIdentifierExpr("ROWNUM"), // offsetQueryBlock.setFrom(new SQLSubqueryTableSource(new SQLSelect(countQueryBlock), "XXX")); offsetQueryBlock.setWhere(new SQLBinaryOpExpr(new SQLIdentifierExpr("RN"), //
SQLSubqueryTableSource y = new SQLSubqueryTableSource(); xx.cloneTo(y);
public SQLSubqueryTableSource clone() { SQLSubqueryTableSource x = new SQLSubqueryTableSource(); cloneTo(x); return x; }
accept(Token.IDENTIFIER); SQLSubqueryTableSource from = new SQLSubqueryTableSource(select, alias);
tableSource = new SQLUnionQueryTableSource((SQLUnionQuery) query); } else { tableSource = new SQLSubqueryTableSource(select);
public void setFrom(SQLSelect select, String alias) { if (select == null) { this.from = null; return; } SQLSubqueryTableSource from = new SQLSubqueryTableSource(select); from.setAlias(alias); this.setFrom(from); }
tableSource = new SQLUnionQueryTableSource((SQLUnionQuery) query); } else { tableSource = new SQLSubqueryTableSource(select);
if (lexer.token == Token.SELECT) { SQLSelect select = this.select(); rightTableSource = new SQLSubqueryTableSource(select); } else { rightTableSource = this.parseTableSource();
private static String createCountUseSubQuery(SQLSelect select, String dbType) { SQLSelectQueryBlock countSelectQuery = createQueryBlock(dbType); SQLSelectItem countItem = createCountItem(dbType); countSelectQuery.getSelectList().add(countItem); SQLSubqueryTableSource fromSubquery = new SQLSubqueryTableSource(select); fromSubquery.setAlias("ALIAS_COUNT"); countSelectQuery.setFrom(fromSubquery); SQLSelect countSelect = new SQLSelect(countSelectQuery); SQLSelectStatement countStmt = new SQLSelectStatement(countSelect, dbType); return SQLUtils.toSQLString(countStmt, dbType); }
lexer.nextToken(); SQLSelect select = this.createSQLSelectParser().select(); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(select); stmt.setInto(tableSource); accept(Token.RPAREN);
static void resolve(SchemaResolveVisitor visitor, SQLParameter x) { SQLName name = x.getName(); if (name instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) name).setResolvedParameter(x); } SQLExpr expr = x.getDefaultValue(); SchemaResolveVisitor.Context ctx = null; if (expr != null) { if (expr instanceof SQLQueryExpr) { ctx = visitor.createContext(x); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(((SQLQueryExpr) expr).getSubQuery()); tableSource.setParent(x); tableSource.setAlias(x.getName().getSimpleName()); ctx.setTableSource(tableSource); } expr.accept(visitor); } if (ctx != null) { visitor.popContext(); } }
public boolean visit(OracleForStatement x) { Context ctx = createContext(x); SQLName index = x.getIndex(); SQLExpr range = x.getRange(); if (index != null) { SQLDeclareItem declareItem = new SQLDeclareItem(index, null); declareItem.setParent(x); if (index instanceof SQLIdentifierExpr) { ((SQLIdentifierExpr) index).setResolvedDeclareItem(declareItem); } declareItem.setResolvedObject(range); ctx.declare(declareItem); if (range instanceof SQLQueryExpr) { SQLSelect select = ((SQLQueryExpr) range).getSubQuery(); SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(select); declareItem.setResolvedObject(tableSource); } index.accept(this); } if (range != null) { range.accept(this); } for (SQLStatement stmt : x.getStatements()) { stmt.accept(this); } popContext(); return false; }