Java Code Examples for org.apache.calcite.sql.SqlMerge

The following examples show how to use org.apache.calcite.sql.SqlMerge. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void validateMerge(SqlMerge call) {
	SqlSelect sqlSelect = call.getSourceSelect();
	// REVIEW zfong 5/25/06 - Does an actual type have to be passed into
	// validateSelect()?

	// REVIEW jvs 6-June-2006:  In general, passing unknownType like
	// this means we won't be able to correctly infer the types
	// for dynamic parameter markers (SET x = ?).  But
	// maybe validateUpdate and validateInsert below will do
	// the job?

	// REVIEW ksecretan 15-July-2011: They didn't get a chance to
	// since validateSelect() would bail.
	// Let's use the update/insert targetRowType when available.
	IdentifierNamespace targetNamespace =
		(IdentifierNamespace) getNamespace(call.getTargetTable());
	validateNamespace(targetNamespace, unknownType);

	SqlValidatorTable table = targetNamespace.getTable();
	validateAccess(call.getTargetTable(), table, SqlAccessEnum.UPDATE);

	RelDataType targetRowType = unknownType;

	if (call.getUpdateCall() != null) {
		targetRowType = createTargetRowType(
			table,
			call.getUpdateCall().getTargetColumnList(),
			true);
	}
	if (call.getInsertCall() != null) {
		targetRowType = createTargetRowType(
			table,
			call.getInsertCall().getTargetColumnList(),
			false);
	}

	validateSelect(sqlSelect, targetRowType);

	if (call.getUpdateCall() != null) {
		validateUpdate(call.getUpdateCall());
	}
	if (call.getInsertCall() != null) {
		validateInsert(call.getInsertCall());
	}
}
 
Example 2
Source Project: Flink-CEPplus   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
MergeNamespace(SqlValidatorImpl validator, SqlMerge node,
	SqlNode enclosingNode, SqlValidatorScope parentScope) {
	super(validator, node.getTargetTable(), enclosingNode, parentScope);
	this.node = Objects.requireNonNull(node);
}
 
Example 3
Source Project: Flink-CEPplus   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public SqlMerge getNode() {
	return node;
}
 
Example 4
Source Project: flink   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public void validateMerge(SqlMerge call) {
	SqlSelect sqlSelect = call.getSourceSelect();
	// REVIEW zfong 5/25/06 - Does an actual type have to be passed into
	// validateSelect()?

	// REVIEW jvs 6-June-2006:  In general, passing unknownType like
	// this means we won't be able to correctly infer the types
	// for dynamic parameter markers (SET x = ?).  But
	// maybe validateUpdate and validateInsert below will do
	// the job?

	// REVIEW ksecretan 15-July-2011: They didn't get a chance to
	// since validateSelect() would bail.
	// Let's use the update/insert targetRowType when available.
	IdentifierNamespace targetNamespace =
		(IdentifierNamespace) getNamespace(call.getTargetTable());
	validateNamespace(targetNamespace, unknownType);

	SqlValidatorTable table = targetNamespace.getTable();
	validateAccess(call.getTargetTable(), table, SqlAccessEnum.UPDATE);

	RelDataType targetRowType = unknownType;

	if (call.getUpdateCall() != null) {
		targetRowType = createTargetRowType(
			table,
			call.getUpdateCall().getTargetColumnList(),
			true);
	}
	if (call.getInsertCall() != null) {
		targetRowType = createTargetRowType(
			table,
			call.getInsertCall().getTargetColumnList(),
			false);
	}

	validateSelect(sqlSelect, targetRowType);

	if (call.getUpdateCall() != null) {
		validateUpdate(call.getUpdateCall());
	}
	if (call.getInsertCall() != null) {
		validateInsert(call.getInsertCall());
	}
}
 
Example 5
Source Project: flink   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
MergeNamespace(SqlValidatorImpl validator, SqlMerge node,
	SqlNode enclosingNode, SqlValidatorScope parentScope) {
	super(validator, node.getTargetTable(), enclosingNode, parentScope);
	this.node = Objects.requireNonNull(node);
}
 
Example 6
Source Project: flink   Source File: SqlValidatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public SqlMerge getNode() {
	return node;
}
 
Example 7
Source Project: Bats   Source File: SqlValidator.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Validates a MERGE statement.
 *
 * @param merge MERGE statement
 */
void validateMerge(SqlMerge merge);
 
Example 8
Source Project: calcite   Source File: SqlValidator.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Validates a MERGE statement.
 *
 * @param merge MERGE statement
 */
void validateMerge(SqlMerge merge);