当前位置: 首页>>代码示例>>Java>>正文


Java RexBuilder类代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexBuilder的典型用法代码示例。如果您正苦于以下问题:Java RexBuilder类的具体用法?Java RexBuilder怎么用?Java RexBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RexBuilder类属于org.apache.calcite.rex包,在下文中一共展示了RexBuilder类的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));
}
 
开发者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


注:本文中的org.apache.calcite.rex.RexBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。