本文整理汇总了Java中org.apache.calcite.plan.RelOptUtil.validateValueAgainstConstraint方法的典型用法代码示例。如果您正苦于以下问题:Java RelOptUtil.validateValueAgainstConstraint方法的具体用法?Java RelOptUtil.validateValueAgainstConstraint怎么用?Java RelOptUtil.validateValueAgainstConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.plan.RelOptUtil
的用法示例。
在下文中一共展示了RelOptUtil.validateValueAgainstConstraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkConstraint
import org.apache.calcite.plan.RelOptUtil; //导入方法依赖的package包/类
/**
* Validates updates against the constraint of a modifiable view.
*
* @param validatorTable A {@link SqlValidatorTable} that may wrap a
* ModifiableViewTable
* @param update The UPDATE parse tree node
* @param targetRowType The target type
*/
private void checkConstraint(
SqlValidatorTable validatorTable,
SqlUpdate update,
RelDataType targetRowType) {
final ModifiableViewTable modifiableViewTable =
validatorTable.unwrap(ModifiableViewTable.class);
if (modifiableViewTable != null) {
final Table table = modifiableViewTable.unwrap(Table.class);
final RelDataType tableRowType = table.getRowType(typeFactory);
final Map<Integer, RexNode> projectMap =
RelOptUtil.getColumnConstraints(modifiableViewTable, targetRowType,
typeFactory);
final Map<String, Integer> nameToIndex =
SqlValidatorUtil.mapNameToIndex(tableRowType.getFieldList());
// Validate update values against the view constraint.
final List<SqlNode> targets = update.getTargetColumnList().getList();
final List<SqlNode> sources = update.getSourceExpressionList().getList();
for (final Pair<SqlNode, SqlNode> column : Pair.zip(targets, sources)) {
final String columnName = ((SqlIdentifier) column.left).getSimple();
final Integer columnIndex = nameToIndex.get(columnName);
if (projectMap.containsKey(columnIndex)) {
final RexNode columnConstraint = projectMap.get(columnIndex);
final ValidationError validationError =
new ValidationError(column.right,
RESOURCE.viewConstraintNotSatisfied(columnName,
Util.last(validatorTable.getQualifiedName())));
RelOptUtil.validateValueAgainstConstraint(column.right,
columnConstraint, validationError);
}
}
}
}