org.apache.calcite.sql.SqlSetOperator Java Examples
The following examples show how to use
org.apache.calcite.sql.SqlSetOperator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SqlImplementor.java From Bats with Apache License 2.0 | 5 votes |
public Result setOpToSql(SqlSetOperator operator, RelNode rel) { SqlNode node = null; for (Ord<RelNode> input : Ord.zip(rel.getInputs())) { final Result result = visitChild(input.i, input.e); if (node == null) { node = result.asSelect(); } else { node = operator.createCall(POS, node, result.asSelect()); } } final List<Clause> clauses = FluentListUtils.list(Clause.SET_OP); return result(node, clauses, rel, null); }
Example #2
Source File: BigQuerySqlDialect.java From Bats with Apache License 2.0 | 5 votes |
@Override public void unparseCall(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) { switch (call.getKind()) { case POSITION: final SqlWriter.Frame frame = writer.startFunCall("STRPOS"); writer.sep(","); call.operand(1).unparse(writer, leftPrec, rightPrec); writer.sep(","); call.operand(0).unparse(writer, leftPrec, rightPrec); if (3 == call.operandCount()) { throw new RuntimeException("3rd operand Not Supported for Function STRPOS in Big Query"); } writer.endFunCall(frame); break; case UNION: if (!((SqlSetOperator) call.getOperator()).isAll()) { SqlSyntax.BINARY.unparse(writer, UNION_DISTINCT, call, leftPrec, rightPrec); } break; case EXCEPT: if (!((SqlSetOperator) call.getOperator()).isAll()) { SqlSyntax.BINARY.unparse(writer, EXCEPT_DISTINCT, call, leftPrec, rightPrec); } break; case INTERSECT: if (!((SqlSetOperator) call.getOperator()).isAll()) { SqlSyntax.BINARY.unparse(writer, INTERSECT_DISTINCT, call, leftPrec, rightPrec); } break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } }
Example #3
Source File: SqlImplementor.java From dremio-oss with Apache License 2.0 | 5 votes |
public Result setOpToSql(SqlSetOperator operator, RelNode rel) { SqlNode node = null; for (Ord<RelNode> input : Ord.zip(rel.getInputs())) { final Result result = visitChild(input.i, input.e); if (node == null) { node = result.asSelect(); } else { node = operator.createCall(POS, node, result.asSelect()); } } final List<Clause> clauses = Expressions.list(Clause.SET_OP); return result(node, clauses, rel, null); }
Example #4
Source File: RelToSqlConverter.java From quark with Apache License 2.0 | 5 votes |
private Result setOpToSql(SqlSetOperator operator, RelNode rel) { List<SqlNode> list = Expressions.list(); for (Ord<RelNode> input : Ord.zip(rel.getInputs())) { final Result result = this.visitChild(input.i, input.e); list.add(result.asSelect()); } final SqlCall node = operator.createCall(new SqlNodeList(list, POS)); final List<Clause> clauses = Expressions.list(Clause.SET_OP); return result(node, clauses, rel); }
Example #5
Source File: RelToSqlConverter.java From quark with Apache License 2.0 | 5 votes |
/** * Converts a non-query node into a SELECT node. Set operators (UNION, * INTERSECT, EXCEPT) remain as is. */ public SqlNode asQuery() { if (node instanceof SqlCall && ((SqlCall) node).getOperator() instanceof SqlSetOperator) { return node; } return asSelect(); }
Example #6
Source File: SqlImplementor.java From calcite with Apache License 2.0 | 5 votes |
public Result setOpToSql(SqlSetOperator operator, RelNode rel) { SqlNode node = null; for (Ord<RelNode> input : Ord.zip(rel.getInputs())) { final Result result = visitChild(input.i, input.e); if (node == null) { node = result.asSelect(); } else { node = operator.createCall(POS, node, result.asSelect()); } } final List<Clause> clauses = Expressions.list(Clause.SET_OP); return result(node, clauses, rel, null); }
Example #7
Source File: RelToSqlConverter.java From quark with Apache License 2.0 | 4 votes |
public Result visitUnion(Union e) { final SqlSetOperator operator = e.all ? SqlStdOperatorTable.UNION_ALL : SqlStdOperatorTable.UNION; return setOpToSql(operator, e); }
Example #8
Source File: BigQuerySqlDialect.java From calcite with Apache License 2.0 | 4 votes |
@Override public void unparseCall(final SqlWriter writer, final SqlCall call, final int leftPrec, final int rightPrec) { switch (call.getKind()) { case POSITION: final SqlWriter.Frame frame = writer.startFunCall("STRPOS"); writer.sep(","); call.operand(1).unparse(writer, leftPrec, rightPrec); writer.sep(","); call.operand(0).unparse(writer, leftPrec, rightPrec); if (3 == call.operandCount()) { throw new RuntimeException("3rd operand Not Supported for Function STRPOS in Big Query"); } writer.endFunCall(frame); break; case UNION: if (((SqlSetOperator) call.getOperator()).isAll()) { super.unparseCall(writer, call, leftPrec, rightPrec); } else { SqlSyntax.BINARY.unparse(writer, UNION_DISTINCT, call, leftPrec, rightPrec); } break; case EXCEPT: if (((SqlSetOperator) call.getOperator()).isAll()) { throw new RuntimeException("BigQuery does not support EXCEPT ALL"); } SqlSyntax.BINARY.unparse(writer, EXCEPT_DISTINCT, call, leftPrec, rightPrec); break; case INTERSECT: if (((SqlSetOperator) call.getOperator()).isAll()) { throw new RuntimeException("BigQuery does not support INTERSECT ALL"); } SqlSyntax.BINARY.unparse(writer, INTERSECT_DISTINCT, call, leftPrec, rightPrec); break; case TRIM: unparseTrim(writer, call, leftPrec, rightPrec); break; default: super.unparseCall(writer, call, leftPrec, rightPrec); } }