本文整理汇总了Java中org.apache.calcite.rex.RexBuilder.makeCall方法的典型用法代码示例。如果您正苦于以下问题:Java RexBuilder.makeCall方法的具体用法?Java RexBuilder.makeCall怎么用?Java RexBuilder.makeCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexBuilder
的用法示例。
在下文中一共展示了RexBuilder.makeCall方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertCall
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/** Converts a {@link SqlCall} to a {@link RexCall} with a perhaps different
* operator. */
private RexNode convertCall(
SqlRexContext cx,
SqlCall call,
SqlOperator op) {
final List<SqlNode> operands = call.getOperandList();
final RexBuilder rexBuilder = cx.getRexBuilder();
final SqlOperandTypeChecker.Consistency consistency =
op.getOperandTypeChecker() == null
? SqlOperandTypeChecker.Consistency.NONE
: op.getOperandTypeChecker().getConsistency();
final List<RexNode> exprs =
convertExpressionList(cx, operands, consistency);
RelDataType type = rexBuilder.deriveReturnType(op, exprs);
return rexBuilder.makeCall(type, op, RexUtil.flatten(exprs, op));
}
示例2: convertCall
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final List<SqlNode> operands = call.getOperandList();
final List<RexNode> exprs = new LinkedList<>();
RelDataTypeFactory typeFactory = cx.getTypeFactory();
//RelDataType nullableReturnType =
for (SqlNode node: operands) {
exprs.add(cx.convertExpression(node));
}
// Determine NULL-able using 2nd argument's Null-able.
RelDataType returnType = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
示例3: createColumnFormatConversion
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
* Apply any data format conversion expressions.
*/
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
final String colName, final RexBuilder rb) {
final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());
if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
// TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
// INT96 format data to TIMESTAMP
return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
}
return inputRef;
}
示例4: convertCall
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
SqlFlattenOperator operator = (SqlFlattenOperator) call.getOperator();
final List<RexNode> exprs = new LinkedList<>();
for (SqlNode node : call.getOperandList()) {
exprs.add(cx.convertExpression(node));
}
SqlFlattenOperator indexedOperator = operator.withIndex(((SqlValidatorImpl)cx.getValidator()).nextFlattenIndex());
final RexBuilder rexBuilder = cx.getRexBuilder();
// Since we don't have any way of knowing if the output of the flatten is nullable, we should always assume it is.
// This is especially important when accelerating a count(column) query, because the normalizer will convert it to
// a count(1) if it thinks this column is non-nullable, and then remove the flatten altogether. This is actually a
// problem with the fact that flatten is not really a project operator (because it can output more than one row per input).
RelDataType type = rexBuilder
.getTypeFactory()
.createTypeWithNullability(
rexBuilder
.getTypeFactory()
.createSqlType(SqlTypeName.ANY),
true
);
return rexBuilder.makeCall(type, indexedOperator, exprs);
}
示例5: convertCall
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final List<SqlNode> operands = call.getOperandList();
final List<RexNode> exprs = new LinkedList<>();
String timeUnit = ((SqlIntervalQualifier) operands.get(0)).timeUnitRange.toString();
RelDataTypeFactory typeFactory = cx.getTypeFactory();
//RelDataType nullableReturnType =
for (SqlNode node: operands) {
exprs.add(cx.convertExpression(node));
}
final RelDataType returnType
= typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
return rexBuilder.makeCall(returnType, call.getOperator(), exprs);
}
示例6: convertCall
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
final RexBuilder rexBuilder = cx.getRexBuilder();
final SqlLiteral literal = (SqlLiteral) call.getOperandList().get(0);
final String value = ((NlsString)literal.getValue()).getValue();
TimeUnitRange range = VALID_PERIODS.get(value.toLowerCase());
Preconditions.checkNotNull(range, "Unhandle range type: %s.", value);
List<RexNode> exprs = new ArrayList<>();
exprs.add(rexBuilder.makeFlag(range));
exprs.add(cx.convertExpression(call.getOperandList().get(1)));
RelDataTypeFactory typeFactory = cx.getTypeFactory();
final RelDataType returnType
= typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.BIGINT), exprs.get(1).getType().isNullable());
return rexBuilder.makeCall(returnType, SqlStdOperatorTable.EXTRACT, exprs);
}
示例7: convert
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public RexNode convert(RexBuilder rexBuilder, RexNode groupCall,
RexNode e) {
return rexBuilder.makeCall(this.f, e);
// FLINK QUICK FIX
// we do not use this logic right now
// switch (f.getKind()) {
// case TUMBLE_START:
// case HOP_START:
// case SESSION_START:
// case SESSION_END: // TODO: ?
// return e;
// case TUMBLE_END:
// return rexBuilder.makeCall(
// SqlStdOperatorTable.PLUS, e,
// ((RexCall) groupCall).operands.get(1));
// case HOP_END:
// return rexBuilder.makeCall(
// SqlStdOperatorTable.PLUS, e,
// ((RexCall) groupCall).operands.get(2));
// default:
// throw new AssertionError("unknown: " + f);
// }
}
示例8: createColumnFormatConversion
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
* Apply any data format conversion expressions.
*/
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
final String colName, final RexBuilder rb) {
final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());
if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
// TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
// INT96 format data to TIMESTAMP
// TODO: Remove this conversion once "store.parquet.reader.int96_as_timestamp" will be true by default
return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
}
return inputRef;
}
示例9: apply
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode apply(RexBuilderContext context) {
RelOptCluster cluster = context.getCluster();
RelDataTypeFactory typeFactory = cluster.getTypeFactory();
final SqlFunction UDF =
new SqlUserDefinedFunction(
new SqlIdentifier("RESOLVE_SIMPLE", SqlParserPos.ZERO),
ReturnTypes.explicit(typeFactory.createJavaType(Object.class)),
null,
OperandTypes.ANY_ANY,
ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false),
typeFactory.createJavaType(int.class)),
ScalarFunctionImpl.create(IObjectMethods.class, "resolveSimpleValue"));
RexBuilder b = context.getBuilder();
RexNode rexNode = b.makeCall(UDF, context.getIObject(), b.makeLiteral(name));
return b.makeCast(dataType, rexNode);
}
示例10: getSelectivity
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public Double getSelectivity(SemiJoin rel, RelMetadataQuery mq,
RexNode predicate) {
// create a RexNode representing the selectivity of the
// semijoin filter and pass it to getSelectivity
RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
RexNode newPred = RelMdUtil.makeSemiJoinSelectivityRexNode(mq, rel);
if (predicate != null) {
newPred =
rexBuilder.makeCall(
SqlStdOperatorTable.AND,
newPred,
predicate);
}
return mq.getSelectivity(rel.getLeft(), newPred);
}
示例11: singleton
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* <p>{@code COUNT(*)}, and {@code COUNT} applied to all NOT NULL arguments,
* become {@code 1}; otherwise
* {@code CASE WHEN arg0 IS NOT NULL THEN 1 ELSE 0 END}.
*/
public RexNode singleton(RexBuilder rexBuilder, RelDataType inputRowType,
AggregateCall aggregateCall) {
final List<RexNode> predicates = new ArrayList<>();
for (Integer arg : aggregateCall.getArgList()) {
final RelDataType type = inputRowType.getFieldList().get(arg).getType();
if (type.isNullable()) {
predicates.add(
rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
rexBuilder.makeInputRef(type, arg)));
}
}
final RexNode predicate =
RexUtil.composeConjunction(rexBuilder, predicates, true);
if (predicate == null) {
return rexBuilder.makeExactLiteral(BigDecimal.ONE);
} else {
return rexBuilder.makeCall(SqlStdOperatorTable.CASE, predicate,
rexBuilder.makeExactLiteral(BigDecimal.ONE),
rexBuilder.makeExactLiteral(BigDecimal.ZERO));
}
}
示例12: convert
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public RexNode convert(RexBuilder rexBuilder, RexNode groupCall,
RexNode e) {
switch (f.getKind()) {
case TUMBLE_START:
case HOP_START:
case SESSION_START:
case SESSION_END: // TODO: ?
return e;
case TUMBLE_END:
return rexBuilder.makeCall(
SqlStdOperatorTable.PLUS, e,
((RexCall) groupCall).operands.get(1));
case HOP_END:
return rexBuilder.makeCall(
SqlStdOperatorTable.PLUS, e,
((RexCall) groupCall).operands.get(2));
default:
throw new AssertionError("unknown: " + f);
}
}
示例13: andJoinFilters
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
* Ands two sets of join filters together, either of which can be null.
*
* @param rexBuilder rexBuilder to create AND expression
* @param left filter on the left that the right will be AND'd to
* @param right filter on the right
* @return AND'd filter
*
* @see org.apache.calcite.rex.RexUtil#composeConjunction
*/
public static RexNode andJoinFilters(
RexBuilder rexBuilder,
RexNode left,
RexNode right) {
// don't bother AND'ing in expressions that always evaluate to
// true
if ((left != null) && !left.isAlwaysTrue()) {
if ((right != null) && !right.isAlwaysTrue()) {
left =
rexBuilder.makeCall(
SqlStdOperatorTable.AND,
left,
right);
}
} else {
left = right;
}
// Joins must have some filter
if (left == null) {
left = rexBuilder.makeLiteral(true);
}
return left;
}
示例14: composeDisjunction
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
private RexNode composeDisjunction(final RexBuilder rexBuilder, List<RexNode> compFuncs) {
final DrillSqlOperator booleanOrFunc
= new DrillSqlOperator("orNoShortCircuit", 2, MajorType.getDefaultInstance(), true);
RexNode node = compFuncs.remove(0);
while (!compFuncs.isEmpty()) {
node = rexBuilder.makeCall(booleanOrFunc, node, compFuncs.remove(0));
}
return node;
}
示例15: addHashProject
import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public static ProjectPrel addHashProject(List<DistributionField> distFields, Prel input, Integer ringCount){
// Insert Project SqlOperatorImpl with new column that will be a hash for HashToRandomExchange fields
final List<String> outputFieldNames = Lists.newArrayList(input.getRowType().getFieldNames());
final String fieldName = ringCount == null ? HashPrelUtil.HASH_EXPR_NAME : WriterPrel.BUCKET_NUMBER_FIELD;
outputFieldNames.add(fieldName);
final RexBuilder rexBuilder = input.getCluster().getRexBuilder();
final List<RelDataTypeField> childRowTypeFields = input.getRowType().getFieldList();
// create new hashed field.
final HashExpressionCreatorHelper<RexNode> hashHelper = new RexNodeBasedHashExpressionCreatorHelper(rexBuilder);
final List<RexNode> distFieldRefs = Lists.newArrayListWithExpectedSize(distFields.size());
for(int i = 0; i < distFields.size(); i++) {
final int fieldId = distFields.get(i).getFieldId();
distFieldRefs.add(rexBuilder.makeInputRef(childRowTypeFields.get(fieldId).getType(), fieldId));
}
final List <RexNode> updatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size() + 1);
for ( RelDataTypeField field : childRowTypeFields) {
RexNode rex = rexBuilder.makeInputRef(field.getType(), field.getIndex());
updatedExpr.add(rex);
}
RexNode hashExpression = HashPrelUtil.createHashBasedPartitionExpression(distFieldRefs, hashHelper);
if(ringCount != null){
RelDataType intType = input.getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER);
hashExpression = rexBuilder.makeCall(SqlStdOperatorTable.MOD, ImmutableList.of(hashExpression, rexBuilder.makeExactLiteral(BigDecimal.valueOf(ringCount), intType)));
hashExpression = rexBuilder.makeCall(SqlStdOperatorTable.ABS, Collections.singletonList(hashExpression));
}
updatedExpr.add(hashExpression);
RelDataType rowType = RexUtil.createStructType(input.getCluster().getTypeFactory(), updatedExpr, outputFieldNames);
ProjectPrel addColumnprojectPrel = new ProjectPrel(input.getCluster(), input.getTraitSet(), input, updatedExpr, rowType);
return addColumnprojectPrel;
}