org.apache.calcite.sql.JoinType Java Examples
The following examples show how to use
org.apache.calcite.sql.JoinType.
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: FlinkCalciteSqlValidator.java From flink with Apache License 2.0 | 6 votes |
@Override protected void validateJoin(SqlJoin join, SqlValidatorScope scope) { // Due to the improper translation of lateral table left outer join in Calcite, we need to // temporarily forbid the common predicates until the problem is fixed (see FLINK-7865). if (join.getJoinType() == JoinType.LEFT && SqlUtil.stripAs(join.getRight()).getKind() == SqlKind.COLLECTION_TABLE) { final SqlNode condition = join.getCondition(); if (condition != null && (!SqlUtil.isLiteral(condition) || ((SqlLiteral) condition).getValueAs(Boolean.class) != Boolean.TRUE)) { throw new ValidationException( String.format( "Left outer joins with a table function do not accept a predicate such as %s. " + "Only literal TRUE is accepted.", condition)); } } super.validateJoin(join, scope); }
Example #2
Source File: FlinkCalciteSqlValidator.java From flink with Apache License 2.0 | 6 votes |
@Override protected void validateJoin(SqlJoin join, SqlValidatorScope scope) { // Due to the improper translation of lateral table left outer join in Calcite, we need to // temporarily forbid the common predicates until the problem is fixed (see FLINK-7865). if (join.getJoinType() == JoinType.LEFT && SqlUtil.stripAs(join.getRight()).getKind() == SqlKind.COLLECTION_TABLE) { final SqlNode condition = join.getCondition(); if (condition != null && (!SqlUtil.isLiteral(condition) || ((SqlLiteral) condition).getValueAs(Boolean.class) != Boolean.TRUE)) { throw new ValidationException( String.format( "Left outer joins with a table function do not accept a predicate such as %s. " + "Only literal TRUE is accepted.", condition)); } } super.validateJoin(join, scope); }
Example #3
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 #4
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 #5
Source File: ISideFunction.java From alchemy with Apache License 2.0 | 5 votes |
default List<Row> dealMissKey(Row input, JoinType joinType) { if (joinType == JoinType.LEFT) { return fillRecord(input, null); } else { return null; } }
Example #6
Source File: SideStream.java From alchemy with Apache License 2.0 | 5 votes |
private static SideTable createSideTable(TableSchema leftSchema, RowTypeInfo sideType, JoinType joinType, SqlSelect rightSelect, List<String> equalFields, Alias sideAlias, Side side) { List<Integer> indexFields = createFieldIndex(leftSchema, equalFields); SideTable sideTable = new SideTable(); sideTable.setConditionIndexs(indexFields); sideTable.setConditions(equalFields); sideTable.setSide(side); sideTable.setJoinType(joinType); sideTable.setRowSize(leftSchema.getFieldCount() + sideType.getArity()); sideTable.setSideAlias(sideAlias); sideTable.setSideType(sideType); sideTable.setSql(rightSelect.toString()); return sideTable; }
Example #7
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 #8
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 #9
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); }
Example #10
Source File: SparkSqlDialect.java From Bats with Apache License 2.0 | 4 votes |
@Override public JoinType emulateJoinTypeForCrossJoin() { return JoinType.CROSS; }
Example #11
Source File: SideTable.java From alchemy with Apache License 2.0 | 4 votes |
public JoinType getJoinType() { return joinType; }
Example #12
Source File: SideTable.java From alchemy with Apache License 2.0 | 4 votes |
public void setJoinType(JoinType joinType) { this.joinType = joinType; }
Example #13
Source File: JoinInfo.java From sylph with Apache License 2.0 | 4 votes |
public JoinType getJoinType() { return joinType; }
Example #14
Source File: DremioSqlDialect.java From dremio-oss with Apache License 2.0 | 4 votes |
/** * Indicates if the dialect supports the given join type. */ public boolean supportsJoin(JoinType type) { return true; }
Example #15
Source File: SparkSqlDialect.java From calcite with Apache License 2.0 | 4 votes |
@Override public JoinType emulateJoinTypeForCrossJoin() { return JoinType.CROSS; }