本文整理汇总了Java中org.apache.calcite.rex.RexLiteral.isNullLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java RexLiteral.isNullLiteral方法的具体用法?Java RexLiteral.isNullLiteral怎么用?Java RexLiteral.isNullLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexLiteral
的用法示例。
在下文中一共展示了RexLiteral.isNullLiteral方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyRowType
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private static void verifyRowType(final ImmutableList<ImmutableList<RexLiteral>> tuples, RelDataType rowType){
for (List<RexLiteral> tuple : tuples) {
assert (tuple.size() == rowType.getFieldCount());
for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) {
RexLiteral literal = (RexLiteral) pair.left;
RelDataType fieldType = ((RelDataTypeField) pair.right).getType();
if ((!(RexLiteral.isNullLiteral(literal)))
&& (!(SqlTypeUtil.canAssignFrom(fieldType, literal.getType())))) {
throw new AssertionError("to " + fieldType + " from " + literal);
}
}
}
}
示例2: verifyRowType
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private static void verifyRowType(final ImmutableList<ImmutableList<RexLiteral>> tuples, RelDataType rowType){
for (List<RexLiteral> tuple : tuples) {
assert (tuple.size() == rowType.getFieldCount());
for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) {
RexLiteral literal = pair.left;
RelDataType fieldType = pair.right.getType();
if ((!(RexLiteral.isNullLiteral(literal)))
&& (!(SqlTypeUtil.canAssignFrom(fieldType, literal.getType())))) {
throw new AssertionError("to " + fieldType + " from " + literal);
}
}
}
}
示例3: translateRexLiteral
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
TblColRef translateRexLiteral(RexLiteral literal) {
if (RexLiteral.isNullLiteral(literal)) {
return TblColRef.newInnerColumn("null", InnerDataTypeEnum.LITERAL);
} else {
return TblColRef.newInnerColumn(literal.getValue().toString(), InnerDataTypeEnum.LITERAL);
}
}
示例4: castNullLiteralIfNeeded
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type) {
if (!RexLiteral.isNullLiteral(node)) {
return node;
}
return rexBuilder.makeCast(type, node);
}
示例5: castNullLiteralIfNeeded
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private RexNode castNullLiteralIfNeeded(RexNode node, RelDataType type) {
if (!RexLiteral.isNullLiteral(node)) {
return node;
}
return rexBuilder.makeCast(type, node);
}
示例6: getPredicates
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
/**
* Infers predicates for a project.
*
* <ol>
* <li>create a mapping from input to projection. Map only positions that
* directly reference an input column.
* <li>Expressions that only contain above columns are retained in the
* Project's pullExpressions list.
* <li>For e.g. expression 'a + e = 9' below will not be pulled up because 'e'
* is not in the projection list.
*
* <blockquote><pre>
* inputPullUpExprs: {a > 7, b + c < 10, a + e = 9}
* projectionExprs: {a, b, c, e / 2}
* projectionPullupExprs: {a > 7, b + c < 10}
* </pre></blockquote>
*
* </ol>
*/
public RelOptPredicateList getPredicates(Project project,
RelMetadataQuery mq) {
final RelNode input = project.getInput();
final RexBuilder rexBuilder = project.getCluster().getRexBuilder();
final RelOptPredicateList inputInfo = mq.getPulledUpPredicates(input);
final List<RexNode> projectPullUpPredicates = new ArrayList<>();
ImmutableBitSet.Builder columnsMappedBuilder = ImmutableBitSet.builder();
Mapping m = Mappings.create(MappingType.PARTIAL_FUNCTION,
input.getRowType().getFieldCount(),
project.getRowType().getFieldCount());
for (Ord<RexNode> o : Ord.zip(project.getProjects())) {
if (o.e instanceof RexInputRef) {
int sIdx = ((RexInputRef) o.e).getIndex();
m.set(sIdx, o.i);
columnsMappedBuilder.set(sIdx);
}
}
// Go over childPullUpPredicates. If a predicate only contains columns in
// 'columnsMapped' construct a new predicate based on mapping.
final ImmutableBitSet columnsMapped = columnsMappedBuilder.build();
for (RexNode r : inputInfo.pulledUpPredicates) {
RexNode r2 = projectPredicate(rexBuilder, input, r, columnsMapped);
if (!r2.isAlwaysTrue()) {
r2 = r2.accept(new RexPermuteInputsShuttle(m, input));
projectPullUpPredicates.add(r2);
}
}
// Project can also generate constants. We need to include them.
for (Ord<RexNode> expr : Ord.zip(project.getProjects())) {
if (RexLiteral.isNullLiteral(expr.e)) {
projectPullUpPredicates.add(
rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL,
rexBuilder.makeInputRef(project, expr.i)));
} else if (RexUtil.isConstant(expr.e)) {
final List<RexNode> args =
ImmutableList.of(rexBuilder.makeInputRef(project, expr.i), expr.e);
final SqlOperator op = args.get(0).getType().isNullable()
|| args.get(1).getType().isNullable()
? SqlStdOperatorTable.IS_NOT_DISTINCT_FROM
: SqlStdOperatorTable.EQUALS;
projectPullUpPredicates.add(rexBuilder.makeCall(op, args));
}
}
return RelOptPredicateList.of(rexBuilder, projectPullUpPredicates);
}
示例7: decomposeConjunction
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
/**
* Decomposes a predicate into a list of expressions that are AND'ed
* together, and a list of expressions that are preceded by NOT.
*
* <p>For example, {@code a AND NOT b AND NOT (c and d) AND TRUE AND NOT
* FALSE} returns {@code rexList = [a], notList = [b, c AND d]}.</p>
*
* <p>TRUE and NOT FALSE expressions are ignored. FALSE and NOT TRUE
* expressions are placed on {@code rexList} and {@code notList} as other
* expressions.</p>
*
* <p>For example, {@code a AND TRUE AND NOT TRUE} returns
* {@code rexList = [a], notList = [TRUE]}.</p>
*
* @param rexPredicate predicate to be analyzed
* @param rexList list of decomposed RexNodes (except those with NOT)
* @param notList list of decomposed RexNodes that were prefixed NOT
*/
public static void decomposeConjunction(
RexNode rexPredicate,
List<RexNode> rexList,
List<RexNode> notList) {
if (rexPredicate == null || rexPredicate.isAlwaysTrue()) {
return;
}
switch (rexPredicate.getKind()) {
case AND:
for (RexNode operand : ((RexCall) rexPredicate).getOperands()) {
decomposeConjunction(operand, rexList, notList);
}
break;
case NOT:
final RexNode e = ((RexCall) rexPredicate).getOperands().get(0);
if (e.isAlwaysFalse()) {
return;
}
switch (e.getKind()) {
case OR:
final List<RexNode> ors = new ArrayList<>();
decomposeDisjunction(e, ors);
for (RexNode or : ors) {
switch (or.getKind()) {
case NOT:
rexList.add(((RexCall) or).operands.get(0));
break;
default:
notList.add(or);
}
}
break;
default:
notList.add(e);
}
break;
case LITERAL:
if (!RexLiteral.isNullLiteral(rexPredicate)
&& RexLiteral.booleanValue(rexPredicate)) {
return; // ignore TRUE
}
// fall through
default:
rexList.add(rexPredicate);
break;
}
}