org.apache.calcite.sql.JoinConditionType Java Examples
The following examples show how to use
org.apache.calcite.sql.JoinConditionType.
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: RelToSqlConverter.java From quark with Apache License 2.0 | 6 votes |
public Result visitJoin(Join e) { final Result leftResult = visitChild(0, e.getLeft()); final Result rightResult = visitChild(1, e.getRight()); final Context leftContext = leftResult.qualifiedContext(); final Context rightContext = rightResult.qualifiedContext(); SqlNode sqlCondition = convertConditionToSqlNode(e.getCondition(), leftContext, rightContext, e.getLeft().getRowType().getFieldCount()); SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType(e.getJoinType()).symbol(POS), rightResult.asFrom(), JoinConditionType.ON.symbol(POS), sqlCondition); return result(join, leftResult, rightResult); }
Example #2
Source File: RelToSqlConverter.java From calcite with Apache License 2.0 | 6 votes |
/** @see #dispatch */ public Result visit(Correlate e) { final Result leftResult = visitChild(0, e.getLeft()) .resetAlias(e.getCorrelVariable(), e.getRowType()); parseCorrelTable(e, leftResult); final Result rightResult = visitChild(1, e.getRight()); final SqlNode rightLateral = SqlStdOperatorTable.LATERAL.createCall(POS, rightResult.node); final SqlNode rightLateralAs = SqlStdOperatorTable.AS.createCall(POS, rightLateral, new SqlIdentifier(rightResult.neededAlias, POS)); final SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), JoinType.COMMA.symbol(POS), rightLateralAs, JoinConditionType.NONE.symbol(POS), null); return result(join, leftResult, rightResult); }
Example #3
Source File: RelToSqlConverter.java From Bats with Apache License 2.0 | 5 votes |
/** @see #dispatch */ public Result visit(Join e) { final Result leftResult = visitChild(0, e.getLeft()).resetAlias(); final Result rightResult = visitChild(1, e.getRight()).resetAlias(); final Context leftContext = leftResult.qualifiedContext(); final Context rightContext = rightResult.qualifiedContext(); SqlNode sqlCondition = null; SqlLiteral condType = JoinConditionType.ON.symbol(POS); JoinType joinType = joinType(e.getJoinType()); if (isCrossJoin(e)) { joinType = dialect.emulateJoinTypeForCrossJoin(); condType = JoinConditionType.NONE.symbol(POS); } else { sqlCondition = convertConditionToSqlNode(e.getCondition(), leftContext, rightContext, e.getLeft().getRowType().getFieldCount()); } SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType.symbol(POS), rightResult.asFrom(), condType, sqlCondition); return result(join, leftResult, rightResult); }
Example #4
Source File: SqlValidatorImpl.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private void lookupJoinHints( SqlJoin join, SqlValidatorScope scope, SqlParserPos pos, Collection<SqlMoniker> hintList) { SqlNode left = join.getLeft(); SqlNode right = join.getRight(); SqlNode condition = join.getCondition(); lookupFromHints(left, scope, pos, hintList); if (hintList.size() > 0) { return; } lookupFromHints(right, scope, pos, hintList); if (hintList.size() > 0) { return; } final JoinConditionType conditionType = join.getConditionType(); final SqlValidatorScope joinScope = scopes.get(join); switch (conditionType) { case ON: condition.findValidOptions(this, joinScope, pos, hintList); return; default: // No suggestions. // Not supporting hints for other types such as 'Using' yet. return; } }
Example #5
Source File: SqlValidatorImpl.java From flink with Apache License 2.0 | 5 votes |
private void lookupJoinHints( SqlJoin join, SqlValidatorScope scope, SqlParserPos pos, Collection<SqlMoniker> hintList) { SqlNode left = join.getLeft(); SqlNode right = join.getRight(); SqlNode condition = join.getCondition(); lookupFromHints(left, scope, pos, hintList); if (hintList.size() > 0) { return; } lookupFromHints(right, scope, pos, hintList); if (hintList.size() > 0) { return; } final JoinConditionType conditionType = join.getConditionType(); final SqlValidatorScope joinScope = scopes.get(join); switch (conditionType) { case ON: condition.findValidOptions(this, joinScope, pos, hintList); return; default: // No suggestions. // Not supporting hints for other types such as 'Using' yet. return; } }
Example #6
Source File: RelToSqlConverter.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * @see #dispatch */ public Result visit(Join e) { final Result leftResult = visitChild(0, e.getLeft()).resetAlias(); final Result rightResult = visitChild(1, e.getRight()).resetAlias(); final Context leftContext = leftResult.qualifiedContext(); final Context rightContext = rightResult.qualifiedContext(); SqlNode sqlCondition = null; SqlLiteral condType = JoinConditionType.ON.symbol(POS); JoinType joinType = joinType(e.getJoinType()); if (e.getJoinType() == JoinRelType.INNER && e.getCondition().isAlwaysTrue()) { joinType = JoinType.COMMA; condType = JoinConditionType.NONE.symbol(POS); } else { final RexNode condition = e.getCondition() != null ? simplifyDatetimePlus(e.getCondition(), e.getCluster().getRexBuilder()) : null; sqlCondition = convertConditionToSqlNode( condition, leftContext, rightContext, e.getLeft().getRowType().getFieldCount()); } SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType.symbol(POS), rightResult.asFrom(), condType, sqlCondition); return result(join, leftResult, rightResult); }
Example #7
Source File: DremioRelToSqlConverter.java From dremio-oss with Apache License 2.0 | 5 votes |
/** * @see #dispatch */ @Override public SqlImplementor.Result visit(Join e) { final DremioRelToSqlConverter.Result leftResult = (DremioRelToSqlConverter.Result) visitChild(0, e.getLeft()).resetAlias(); final DremioRelToSqlConverter.Result rightResult = (DremioRelToSqlConverter.Result) visitChild(1, e.getRight()).resetAlias(); SqlNode sqlCondition = null; SqlLiteral condType = JoinConditionType.ON.symbol(POS); JoinType joinType = joinType(e.getJoinType()); final Context leftContext = leftResult.qualifiedContext(); final Context rightContext = rightResult.qualifiedContext(); final Context joinContext = leftContext.implementor().joinContext(leftContext, rightContext); final RexNode condition = e.getCondition() == null ? null : this.simplifyDatetimePlus(e.getCondition(), e.getCluster().getRexBuilder()); sqlCondition = joinContext.toSql(null, condition); final SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType.symbol(POS), rightResult.asFrom(), condType, sqlCondition); return result(join, leftResult, rightResult); }
Example #8
Source File: RelToSqlConverter.java From calcite with Apache License 2.0 | 5 votes |
/** @see #dispatch */ public Result visit(Join e) { if (e.getJoinType() == JoinRelType.ANTI || e.getJoinType() == JoinRelType.SEMI) { return visitAntiOrSemiJoin(e); } final Result leftResult = visitChild(0, e.getLeft()).resetAlias(); final Result rightResult = visitChild(1, e.getRight()).resetAlias(); final Context leftContext = leftResult.qualifiedContext(); final Context rightContext = rightResult.qualifiedContext(); SqlNode sqlCondition = null; SqlLiteral condType = JoinConditionType.ON.symbol(POS); JoinType joinType = joinType(e.getJoinType()); if (isCrossJoin(e)) { joinType = dialect.emulateJoinTypeForCrossJoin(); condType = JoinConditionType.NONE.symbol(POS); } else { sqlCondition = convertConditionToSqlNode(e.getCondition(), leftContext, rightContext, e.getLeft().getRowType().getFieldCount(), dialect); } SqlNode join = new SqlJoin(POS, leftResult.asFrom(), SqlLiteral.createBoolean(false, POS), joinType.symbol(POS), rightResult.asFrom(), condType, sqlCondition); return result(join, leftResult, rightResult); }