本文整理汇总了Java中org.apache.calcite.rex.RexBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RexBuilder类的具体用法?Java RexBuilder怎么用?Java RexBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RexBuilder类属于org.apache.calcite.rex包,在下文中一共展示了RexBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ConvertletTable.java
示例2: visitCall
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
public RexNode visitCall(RexCall call) {
String functionName = call.getOperator().getName();
List<RexNode> newOps = new ArrayList();
for (RexNode operand : call.operands) {
newOps.add(operand.accept(this));
}
if (funcReg.isFunctionComplexOutput(functionName) ) {
RexBuilder builder = new RexBuilder(factory);
RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
lastUsedIndex++;
complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
return ret;
}
return call.clone(call.getType(), newOps);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:RexVisitorComplexExprSplitter.java
示例3: addTrivialOrderedProjectPrel
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
private Prel addTrivialOrderedProjectPrel(Prel prel) {
RelDataType t = prel.getRowType();
RexBuilder b = prel.getCluster().getRexBuilder();
List<RexNode> projections = Lists.newArrayList();
int projectCount = t.getFieldList().size();
// no point in reordering if we only have one column
if (projectCount < 2) {
return prel;
}
for (int i = 0; i < projectCount; i++) {
projections.add(b.makeInputRef(prel, i));
}
return new ProjectPrel(prel.getCluster(), prel.getTraitSet(), prel, projections, prel.getRowType());
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:FinalColumnReorderer.java
示例4: 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);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DrillExtractConvertlet.java
示例5: addRenamedProject
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
protected DrillRel addRenamedProject(DrillRel rel, RelDataType validatedRowType) {
RelDataType t = rel.getRowType();
RexBuilder b = rel.getCluster().getRexBuilder();
List<RexNode> projections = Lists.newArrayList();
int projectCount = t.getFieldList().size();
for (int i =0; i < projectCount; i++) {
projections.add(b.makeInputRef(rel, i));
}
final List<String> fieldNames2 = SqlValidatorUtil.uniquify(validatedRowType.getFieldNames(), SqlValidatorUtil.F_SUGGESTER2);
RelDataType newRowType = RexUtil.createStructType(rel.getCluster().getTypeFactory(), projections, fieldNames2);
DrillProjectRel topProj = DrillProjectRel.create(rel.getCluster(), rel.getTraitSet(), rel, projections, newRowType);
// Add a final non-trivial Project to get the validatedRowType, if child is not project.
if (rel instanceof Project && DrillRelOptUtil.isTrivialProject(topProj, true)) {
return rel;
} else{
return topProj;
}
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:25,代码来源:DefaultSqlHandler.java
示例6: createProjectRel
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
/**
* Create a project that converts the native scan output to expected output of Hive scan.
*/
private DrillProjectRel createProjectRel(final DrillScanRel hiveScanRel,
final Map<String, String> partitionColMapping, final DrillScanRel nativeScanRel) {
final List<RexNode> rexNodes = Lists.newArrayList();
final RexBuilder rb = hiveScanRel.getCluster().getRexBuilder();
final RelDataType hiveScanRowType = hiveScanRel.getRowType();
for (String colName : hiveScanRowType.getFieldNames()) {
final String dirColName = partitionColMapping.get(colName);
if (dirColName != null) {
rexNodes.add(createPartitionColumnCast(hiveScanRel, nativeScanRel, colName, dirColName, rb));
} else {
rexNodes.add(createColumnFormatConversion(hiveScanRel, nativeScanRel, colName, rb));
}
}
return DrillProjectRel.create(
hiveScanRel.getCluster(), hiveScanRel.getTraitSet(), nativeScanRel, rexNodes,
hiveScanRowType /* project rowtype and HiveScanRel rowtype should be the same */);
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:ConvertHiveParquetScanToDrillParquetScan.java
示例7: 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;
}
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:ConvertHiveParquetScanToDrillParquetScan.java
示例8: visit
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
@Override
public RelNode visit(TableScan tableScan) {
if (tableScan instanceof ConvertibleScan) {
return ((ConvertibleScan) tableScan).convert().accept(this);
}
if (!(tableScan instanceof IncrementallyUpdateable)) {
return tableScan;
}
final RelNode newScan = updateScan((IncrementallyUpdateable) tableScan);
// build new filter to apply refresh condition.
final RexBuilder rexBuilder = tableScan.getCluster().getRexBuilder();
final RexNode inputRef = rexBuilder.makeInputRef(newScan, newScan.getRowType().getField(UPDATE_COLUMN, false, false).getIndex());
final RexNode literal = generateLiteral(rexBuilder, tableScan.getCluster().getTypeFactory());
final RexNode condition = tableScan.getCluster().getRexBuilder().makeCall(SqlStdOperatorTable.GREATER_THAN, ImmutableList.of(inputRef, literal));
return LogicalFilter.create(newScan, condition);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:IncrementalUpdateUtils.java
示例9: buildJoinCondition
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
List<RexNode> equijoinList = Lists.newArrayList();
final int numLeftFields = convertedLeft.getRowType().getFieldCount();
List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();
for (int i=0; i < leftKeys.size(); i++) {
int leftKeyOrdinal = leftKeys.get(i).intValue();
int rightKeyOrdinal = rightKeys.get(i).intValue();
equijoinList.add(builder.makeCall(
filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
));
}
return RexUtil.composeConjunction(builder, equijoinList, false);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:JoinRule.java
示例10: replaceItemInputRefIndex
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
private static RexNode replaceItemInputRefIndex(RexBuilder rexBuilder, RexNode rexNode, int orig, int replace) {
if (rexNode == null) {
return null;
}
if (rexNode instanceof RexInputRef) {
assert ((RexInputRef) rexNode).getIndex() == orig;
return rexBuilder.makeInputRef(rexNode.getType(), replace);
}
if (rexNode instanceof RexCall) {
String functionName = ((RexCall) rexNode).getOperator().getName();
if (functionName.equalsIgnoreCase("item")) {
assert ((RexCall) rexNode).getOperands().size() == 2;
RexNode newInput0 = replaceItemInputRefIndex(rexBuilder, ((RexCall) rexNode).getOperands().get(0), orig, replace);
RexNode newInput1 = replaceItemInputRefIndex(rexBuilder, ((RexCall) rexNode).getOperands().get(1), orig, replace);
return rexBuilder.makeCall(((RexCall) rexNode).getOperator(), newInput0, newInput1);
}
}
return rexNode;
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:PushProjectPastFlattenRule.java
示例11: visit
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
private Prel visit(ExchangePrel hashPrel, List<DistributionTrait.DistributionField> fields, Prel child) {
final List<String> childFields = child.getRowType().getFieldNames();
// Insert Project SqlOperatorImpl with new column that will be a hash for HashToRandomExchange fields
final ProjectPrel addColumnprojectPrel = HashPrelUtil.addHashProject(fields, child, null);
final Prel newPrel = (Prel) hashPrel.copy(addColumnprojectPrel.getTraitSet(), Collections.<RelNode>singletonList(addColumnprojectPrel));
int validRows = newPrel.getRowType().getFieldCount() - 1;
final List<RelDataTypeField> all = newPrel.getRowType().getFieldList();
final List<RexNode> keptExprs = new ArrayList<>(validRows);
final RexBuilder rexBuilder = newPrel.getCluster().getRexBuilder();
for(int i = 0; i < validRows; i++){
RexNode rex = rexBuilder.makeInputRef(all.get(i).getType(), i);
keptExprs.add(rex);
}
// remove earlier inserted Project SqlOperatorImpl - since it creates issues down the road in HashJoin
RelDataType removeRowType = RexUtil.createStructType(newPrel.getCluster().getTypeFactory(), keptExprs, childFields);
return new ProjectPrel(newPrel.getCluster(), newPrel.getTraitSet(), newPrel, keptExprs, removeRowType);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:InsertHashProjectVisitor.java
示例12: 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);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:FlattenConvertlet.java
示例13: 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);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:ExtractConvertlet.java
示例14: 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);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:SqlDatePartOperator.java
示例15: 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);
// }
}
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:AuxiliaryConverter.java
示例16: buildJoinCondition
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
List<RexNode> equijoinList = Lists.newArrayList();
final int numLeftFields = convertedLeft.getRowType().getFieldCount();
List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();
for (int i=0; i < leftKeys.size(); i++) {
int leftKeyOrdinal = leftKeys.get(i).intValue();
int rightKeyOrdinal = rightKeys.get(i).intValue();
equijoinList.add(builder.makeCall(
filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
));
}
return RexUtil.composeConjunction(builder, equijoinList, false);
}
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:DrillJoinRule.java
示例17: visitCall
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {
String functionName = call.getOperator().getName();
List<RexNode> newOps = new ArrayList<>();
for (RexNode operand : call.operands) {
newOps.add(operand.accept(this));
}
if (funcReg.isFunctionComplexOutput(functionName) ) {
RexBuilder builder = new RexBuilder(factory);
RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
lastUsedIndex++;
complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
return ret;
}
return call.clone(call.getType(), newOps);
}
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:RexVisitorComplexExprSplitter.java
示例18: 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;
}
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:ConvertHiveParquetScanToDrillParquetScan.java
示例19: visit
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
@Override
public RelInfo visit(RelContext context, RelNode node, List<RelInfo> inputStreams)
{
Project project = (Project)node;
if (inputStreams.size() == 0 || inputStreams.size() > 1) {
throw new UnsupportedOperationException("Project is a SingleRel");
}
FilterTransformOperator operator = context.dag
.addOperator(OperatorUtils.getUniqueOperatorName(project.getRelTypeName()), FilterTransformOperator.class);
Map<String, String> expMap = new HashMap<>();
ExpressionCompiler compiler = new ExpressionCompiler(new RexBuilder(project.getCluster().getTypeFactory()));
for (Pair<RelDataTypeField, RexNode> pair : Pair.zip(project.getRowType().getFieldList(),
project.getProjects())) {
String fieldName = OperatorUtils.getFieldName(pair.left);
String expression = compiler.getExpression(pair.right, project.getInput().getRowType(), project.getRowType());
expMap.put(fieldName, expression);
}
operator.setExpressionMap(expMap);
return new RelInfo("Project", Lists.<Operator.InputPort>newArrayList(operator.input), operator, operator.output,
project.getRowType());
}
开发者ID:apache,项目名称:apex-malhar,代码行数:25,代码来源:ApexRelNode.java
示例20: perform
import org.apache.calcite.rex.RexBuilder; //导入依赖的package包/类
/** Executes a prepare action. */
public <R> R perform(CalciteServerStatement statement,
Frameworks.PrepareAction<R> action) {
final CalcitePrepare.Context prepareContext =
statement.createPrepareContext();
final JavaTypeFactory typeFactory = prepareContext.getTypeFactory();
final CalciteSchema schema =
action.getConfig().getDefaultSchema() != null
? CalciteSchema.from(action.getConfig().getDefaultSchema())
: prepareContext.getRootSchema();
CalciteCatalogReader catalogReader =
new CalciteCatalogReader(schema.root(),
prepareContext.config().caseSensitive(),
schema.path(null),
typeFactory);
final RexBuilder rexBuilder = new RexBuilder(typeFactory);
final RelOptPlanner planner =
createPlanner(prepareContext,
action.getConfig().getContext(),
action.getConfig().getCostFactory());
final RelOptCluster cluster = createCluster(planner, rexBuilder);
return action.apply(cluster, catalogReader,
prepareContext.getRootSchema().plus(), statement);
}
开发者ID:apache,项目名称:kylin,代码行数:25,代码来源:CalcitePrepareImpl.java
注:本文中的org.apache.calcite.rex.RexBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论