The following are top voted examples for showing how to use net.sf.jsqlparser.statement.select.Union. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to product more good examples.
+
Save this class to your library
http://www.programcreek.com/java-api-examples/index.php?api=net.sf.jsqlparser.statement.select.Union
Example 1
Project: pepe File: SqlParse.java View source code | Vote up | 6 votes |
@SuppressWarnings("unchecked") public void visit(Union arg0) { List<PlainSelect> plainSelects = arg0.getPlainSelects(); for (PlainSelect select : plainSelects) { select.accept(new SelectVisitorImplementation()); } }
Example 2
Project: pepe File: CCJSqlParser.java View source code | Vote up | 6 votes |
final public SelectBody SelectBody() throws ParseException { SelectBody selectBody = null; if (jj_2_5(2147483647)) { selectBody = Union(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_SELECT: selectBody = PlainSelect(); break; default: jj_la1[23] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return selectBody;} throw new Error("Missing return statement in function"); }
Example 3
Project: jdbc4sparql File: SparqlSelectVisitor.java View source code | Vote up | 6 votes |
@Override public void visit(final Union union) { // TODO implement ALL if (union.isDistinct()) { queryBuilder.setDistinct(); } final List<SparqlQueryBuilder> unionBuilders = new ArrayList<SparqlQueryBuilder>(); for (final Iterator<?> iter = union.getPlainSelects().iterator(); iter .hasNext();) { final PlainSelect ps = (PlainSelect) iter.next(); final SparqlQueryBuilder sqb = new SparqlQueryBuilder(queryBuilder); ps.accept(new SparqlSelectVisitor(sqb)); unionBuilders.add(sqb); } try { queryBuilder.addUnion(unionBuilders); } catch (final SQLDataException e) { throw new IllegalStateException(e); } deparseOrderBy(union.getOrderByElements()); deparseLimit(union.getLimit()); throw new UnsupportedOperationException("UNION is not supported"); }
Example 4
Project: geotools-old File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
public static PlainSelect parseSqlQuery(String selectStatement) throws IOException { CCJSqlParserManager pm = new CCJSqlParserManager(); Reader reader = new StringReader(selectStatement); Statement statement; try { statement = pm.parse(reader); } catch (Exception e) { throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(), e); } if (!(statement instanceof Select)) { // either PlainSelect or Union throw new IllegalArgumentException("expected select or union statement: " + statement); } SelectBody selectBody = ((Select) statement).getSelectBody(); if (selectBody instanceof Union) { // dataStore.registerView(typeName, (Union) selectBody); throw new UnsupportedOperationException( "ArcSDEDataStore does not supports registering Union queries"); } else if (selectBody instanceof PlainSelect) { return (PlainSelect) selectBody; } else { throw new IllegalStateException(selectBody.getClass().getName()); } }
Example 5
Project: PlatypusJS File: SourcesFinder.java View source code | Vote up | 6 votes |
@Override public void visit(Union union) { Iterator iter = union.getPlainSelects().iterator(); if (iter.hasNext()) { PlainSelect plainSelect = (PlainSelect) iter.next(); visit(plainSelect); } }
Example 6
Project: PlatypusJS File: CCJSqlParser.java View source code | Vote up | 6 votes |
final public SelectBody SelectBody() throws ParseException {SelectBody selectBody = null; if (jj_2_5(2147483647)) { selectBody = Union(); } else { switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) { case K_SELECT:{ selectBody = PlainSelect(); break; } default: jj_la1[25] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if ("" != null) return selectBody;} throw new Error("Missing return statement in function"); }
Example 7
Project: mimir File: MimirJSqlParser.java View source code | Vote up | 6 votes |
final public SelectBody SelectBody() throws ParseException { SelectBody selectBody = null; if (jj_2_5(2147483647)) { selectBody = Union(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_SELECT: selectBody = PlainSelect(); break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return selectBody;} throw new Error("Missing return statement in function"); }
Example 8
Project: geotools_trunk File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
public static PlainSelect parseSqlQuery(String selectStatement) throws IOException { CCJSqlParserManager pm = new CCJSqlParserManager(); Reader reader = new StringReader(selectStatement); Statement statement; try { statement = pm.parse(reader); } catch (Exception e) { throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(), e); } if (!(statement instanceof Select)) { // either PlainSelect or Union throw new IllegalArgumentException("expected select or union statement: " + statement); } SelectBody selectBody = ((Select) statement).getSelectBody(); if (selectBody instanceof Union) { // dataStore.registerView(typeName, (Union) selectBody); throw new UnsupportedOperationException( "ArcSDEDataStore does not supports registering Union queries"); } else if (selectBody instanceof PlainSelect) { return (PlainSelect) selectBody; } else { throw new IllegalStateException(selectBody.getClass().getName()); } }
Example 9
Project: geotools-2.7.x File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
public static PlainSelect parseSqlQuery(String selectStatement) throws IOException { CCJSqlParserManager pm = new CCJSqlParserManager(); Reader reader = new StringReader(selectStatement); Statement statement; try { statement = pm.parse(reader); } catch (Exception e) { throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(), e); } if (!(statement instanceof Select)) { // either PlainSelect or Union throw new IllegalArgumentException("expected select or union statement: " + statement); } SelectBody selectBody = ((Select) statement).getSelectBody(); if (selectBody instanceof Union) { // dataStore.registerView(typeName, (Union) selectBody); throw new UnsupportedOperationException( "ArcSDEDataStore does not supports registering Union queries"); } else if (selectBody instanceof PlainSelect) { return (PlainSelect) selectBody; } else { throw new IllegalStateException(selectBody.getClass().getName()); } }
Example 10
Project: geotools-2.7.x File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
/** * Registers the sql views provided in <code>params</code> on the * SqlDataStore <code>dataStore</code> * * @param dataStore * @param params * @throws IOException */ public static void registerSqlViews(SqlDataStore dataStore, Map params) throws IOException { Map cleanedUp = cleanUpViewDefinitions(params); for (Iterator it = cleanedUp.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); String typeName = (String) entry.getKey(); String sqlQuery = (String) entry.getValue(); LOGGER.finer("registering view " + typeName); LOGGER.finest("sql query is '" + sqlQuery + "'"); SelectBody selectBody = SqlParser.parse(sqlQuery); if(selectBody instanceof Union){ dataStore.registerView(typeName, (Union)selectBody); }else if(selectBody instanceof PlainSelect){ dataStore.registerView(typeName, (PlainSelect)selectBody); }else{ throw new IllegalStateException(selectBody.getClass().getName()); } //dataStore.registerView(typeName, sqlQuery); } }
Example 11
Project: geotools File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
public static PlainSelect parseSqlQuery(String selectStatement) throws IOException { CCJSqlParserManager pm = new CCJSqlParserManager(); Reader reader = new StringReader(selectStatement); Statement statement; try { statement = pm.parse(reader); } catch (Exception e) { throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(), e); } if (!(statement instanceof Select)) { // either PlainSelect or Union throw new IllegalArgumentException("expected select or union statement: " + statement); } SelectBody selectBody = ((Select) statement).getSelectBody(); if (selectBody instanceof Union) { // dataStore.registerView(typeName, (Union) selectBody); throw new UnsupportedOperationException( "ArcSDEDataStore does not supports registering Union queries"); } else if (selectBody instanceof PlainSelect) { return (PlainSelect) selectBody; } else { throw new IllegalStateException(selectBody.getClass().getName()); } }
Example 12
Project: mdrill File: CCJSqlParser.java View source code | Vote up | 6 votes |
final public SelectBody SelectBody() throws ParseException { SelectBody selectBody = null; if (jj_2_5(2147483647)) { selectBody = Union(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_SELECT: selectBody = PlainSelect(); break; default: jj_la1[23] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } {if (true) return selectBody;} throw new Error("Missing return statement in function"); }
Example 13
Project: mdrill File: SelectDeParser.java View source code | Vote up | 6 votes |
public void visit(Union union) { for (Iterator iter = union.getPlainSelects().iterator(); iter.hasNext();) { buffer.append("("); PlainSelect plainSelect = (PlainSelect) iter.next(); plainSelect.accept(this); buffer.append(")"); if (iter.hasNext()) { buffer.append(" UNION "); } } if (union.getOrderByElements() != null) { deparseOrderBy(union.getOrderByElements()); } if (union.getLimit() != null) { deparseLimit(union.getLimit()); } }
Example 14
Project: geotools-tike File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
public static PlainSelect parseSqlQuery(String selectStatement) throws IOException { CCJSqlParserManager pm = new CCJSqlParserManager(); Reader reader = new StringReader(selectStatement); Statement statement; try { statement = pm.parse(reader); } catch (Exception e) { throw new DataSourceException("parsing select statement: " + e.getCause().getMessage(), e); } if (!(statement instanceof Select)) { // either PlainSelect or Union throw new IllegalArgumentException("expected select or union statement: " + statement); } SelectBody selectBody = ((Select) statement).getSelectBody(); if (selectBody instanceof Union) { // dataStore.registerView(typeName, (Union) selectBody); throw new UnsupportedOperationException( "ArcSDEDataStore does not supports registering Union queries"); } else if (selectBody instanceof PlainSelect) { return (PlainSelect) selectBody; } else { throw new IllegalStateException(selectBody.getClass().getName()); } }
Example 15
Project: geotools-tike File: ViewRegisteringFactoryHelper.java View source code | Vote up | 6 votes |
/** * Registers the sql views provided in <code>params</code> on the * SqlDataStore <code>dataStore</code> * * @param dataStore * @param params * @throws IOException */ public static void registerSqlViews(SqlDataStore dataStore, Map params) throws IOException { Map cleanedUp = cleanUpViewDefinitions(params); for (Iterator it = cleanedUp.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); String typeName = (String) entry.getKey(); String sqlQuery = (String) entry.getValue(); LOGGER.finer("registering view " + typeName); LOGGER.finest("sql query is '" + sqlQuery + "'"); SelectBody selectBody = SqlParser.parse(sqlQuery); if(selectBody instanceof Union){ dataStore.registerView(typeName, (Union)selectBody); }else if(selectBody instanceof PlainSelect){ dataStore.registerView(typeName, (PlainSelect)selectBody); }else{ throw new IllegalStateException(selectBody.getClass().getName()); } //dataStore.registerView(typeName, sqlQuery); } }
Example 16
Project: mimir File: MimirJSqlParser.java View source code | Vote up | 5 votes |
final public Union Union() throws ParseException { Union union = new Union(); List orderByElements = null; Limit limit = null; PlainSelect select = null; ArrayList selects = new ArrayList(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 86: jj_consume_token(86); select = PlainSelect(); selects.add(select); jj_consume_token(87); jj_consume_token(K_UNION); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: case K_DISTINCT: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: jj_consume_token(K_ALL); union.setAll(true); break; case K_DISTINCT: jj_consume_token(K_DISTINCT); union.setDistinct(true); break; default: jj_la1[40] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[41] = jj_gen; ; } jj_consume_token(86); select = PlainSelect(); selects.add(select); jj_consume_token(87); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_UNION: ; break; default: jj_la1[42] = jj_gen; break label_9; } jj_consume_token(K_UNION); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: case K_DISTINCT: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: jj_consume_token(K_ALL); break; case K_DISTINCT: jj_consume_token(K_DISTINCT); break; default: jj_la1[43] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[44] = jj_gen; ; } jj_consume_token(86); select = PlainSelect(); selects.add(select); jj_consume_token(87); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ORDER: orderByElements = OrderByElements(); union.setOrderByElements(orderByElements); break; default: jj_la1[45] = jj_gen; ; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_LIMIT: case K_OFFSET: limit = Limit(); union.setLimit(limit); break; default: jj_la1[46] = jj_gen; ; } break; case K_SELECT: select = PlainSelect(); selects.add(select); jj_consume_token(K_UNION); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: case K_DISTINCT: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: jj_consume_token(K_ALL); union.setAll(true); break; case K_DISTINCT: jj_consume_token(K_DISTINCT); union.setDistinct(true); break; default: jj_la1[47] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[48] = jj_gen; ; } select = PlainSelect(); selects.add(select); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_UNION: ; break; default: jj_la1[49] = jj_gen; break label_10; } jj_consume_token(K_UNION); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: case K_DISTINCT: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case K_ALL: jj_consume_token(K_ALL); break; case K_DISTINCT: jj_consume_token(K_DISTINCT); break; default: jj_la1[50] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: jj_la1[51] = jj_gen; ; } select = PlainSelect(); selects.add(select); } break; default: jj_la1[52] = jj_gen; jj_consume_token(-1); throw new ParseException(); } union.setPlainSelects(selects); {if (true) return union;} throw new Error("Missing return statement in function"); }