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


Java RelDataType类代码示例

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


RelDataType类属于org.apache.calcite.rel.type包,在下文中一共展示了RelDataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: qualifyColumnsWithGranularity

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
public List<NameAndGranularity> qualifyColumnsWithGranularity(List<NameAndGranularity> strings){
  final RelDataType type = table.getRowType(new JavaTypeFactoryImpl());
  return FluentIterable.from(strings).transform(new Function<NameAndGranularity, NameAndGranularity>(){

    @Override
    public NameAndGranularity apply(NameAndGranularity input) {
      RelDataTypeField field = type.getField(input.getName(), false, false);
      if(field == null){
        throw UserException.validationError()
          .message("Unable to find field %s in table %s. Available fields were: %s.",
              input.getName(),
              SqlUtils.quotedCompound(path),
              FluentIterable.from(type.getFieldNames()).transform(SqlUtils.QUOTER).join(Joiner.on(", "))
            ).build(logger);
      }

      return new NameAndGranularity(field.getName(), input.getGranularity());
    }

  }).toList();

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:SchemaUtilities.java

示例2: toRel

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
static RelNode toRel(RelOptCluster cluster, RelOptSchema relOptSchema, JdbcTable table, List<String> qualifiedName) {
	RelOptTable.ToRelContext toRelContext = new RelOptTable.ToRelContext() {
		@Override
		public RelOptCluster getCluster() {
			return cluster;
		}

		@Override
		public RelRoot expandView(RelDataType rowType, String queryString, List<String> schemaPath, List<String> viewPath) {
			throw new UnsupportedOperationException();
		}
	};

	return table.toRel(
			toRelContext,
			relOptSchema.getTableForMember(qualifiedName)
	);
}
 
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:19,代码来源:JdbcTableUtils.java

示例3: createCalciteTypeWithNullability

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
private RelDataType createCalciteTypeWithNullability(RelDataTypeFactory typeFactory,
                                                     SqlTypeName sqlTypeName,
                                                     boolean isNullable) {
  RelDataType type;
  if (sqlTypeName == SqlTypeName.INTERVAL_DAY_TIME) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.DAY,
            TimeUnit.MINUTE,
            SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.INTERVAL_YEAR_MONTH) {
    type = typeFactory.createSqlIntervalType(
        new SqlIntervalQualifier(
            TimeUnit.YEAR,
            TimeUnit.MONTH,
           SqlParserPos.ZERO));
  } else if (sqlTypeName == SqlTypeName.VARCHAR) {
    type = typeFactory.createSqlType(sqlTypeName, TypeHelper.VARCHAR_DEFAULT_CAST_LEN);
  } else {
    type = typeFactory.createSqlType(sqlTypeName);
  }
  return typeFactory.createTypeWithNullability(type, isNullable);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillConstExecutor.java

示例4: visit

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
@Override
public RelNode visit(LogicalAggregate aggregate) {
  RelNode input = aggregate.getInput().accept(this);
  RelDataType incomingRowType = input.getRowType();
  RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false);
  if (modField == null) {
    return aggregate;
  }

  final AggregateCall aggCall = AggregateCall.create(SqlStdOperatorTable.MAX, false, ImmutableList.of(modField.getIndex()), -1, modField.getType(), UPDATE_COLUMN);
  final List<AggregateCall> aggCalls = FluentIterable.from(aggregate.getAggCallList())
    .append(aggCall)
    .toList();
  return aggregate.copy(
    aggregate.getTraitSet(),
    input,
    aggregate.indicator,
    aggregate.getGroupSet(),
    null,
    aggCalls
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:IncrementalUpdateUtils.java

示例5: convertCall

import org.apache.calcite.rel.type.RelDataType; //导入依赖的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

示例6: insertProjUnderScreenOrWriter

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
private Prel insertProjUnderScreenOrWriter(Prel prel, RelDataType origRowType, Prel child) {

    ProjectPrel proj = null;
    List<RelNode> children = Lists.newArrayList();

    List<RexNode> exprs = Lists.newArrayList();
    for (int i = 0; i < origRowType.getFieldCount(); i++) {
      RexNode expr = child.getCluster().getRexBuilder().makeInputRef(origRowType.getFieldList().get(i).getType(), i);
      exprs.add(expr);
    }

    RelDataType newRowType = RexUtil.createStructType(child.getCluster().getTypeFactory(), exprs, origRowType.getFieldNames());

    int fieldCount = prel.getRowType().isStruct()? prel.getRowType().getFieldCount():1;

    // Insert PUS/PUW : remove the prefix and keep the original field name.
    if (fieldCount > 1) { // // no point in allowing duplicates if we only have one column
      proj = new ProjectAllowDupPrel(child.getCluster(), child.getTraitSet(), child, exprs, newRowType);
    } else {
      proj = new ProjectPrel(child.getCluster(), child.getTraitSet(), child, exprs, newRowType);
    }

    children.add(proj);
    return (Prel) prel.copy(prel.getTraitSet(), children);
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:StarColumnConverter.java

示例7: instanceExtract

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
public VirtualDatasetState instanceExtract(SqlQuery query, QueryMetadata metadata) {
  RelDataType relDataType = metadata.getRowType();
  VirtualDatasetState state;
  try {
    state = extract(query.getSql(), metadata.getSqlNode().get(), relDataType);
  } catch (RuntimeException e) {
    state = fallback("Error parsing", null, query.getSql(), e);
  }
  if (state.getColumnsList() == null || state.getColumnsList().isEmpty()) {
    populateSemanticFields(relDataType, state);
  }
  Optional<List<String>> referredTables = metadata.getReferredTables();
  if (referredTables.isPresent()) {
    state.setReferredTablesList(referredTables.get());
  }
  state.setContextList(query.getContext());
  return state;

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:QuerySemantics.java

示例8: addTrivialOrderedProjectPrel

import org.apache.calcite.rel.type.RelDataType; //导入依赖的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:dremio,项目名称:dremio-oss,代码行数:18,代码来源:FinalColumnReorderer.java

示例9: convertCall

import org.apache.calcite.rel.type.RelDataType; //导入依赖的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

示例10: setProjectedRowType

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
private void setProjectedRowType(List<SchemaPath> projectedColumns){
  if(projectedColumns != null){
    LinkedHashSet<String> firstLevelPaths = new LinkedHashSet<>();
    for(SchemaPath p : projectedColumns){
      firstLevelPaths.add(p.getRootSegment().getNameSegment().getPath());
    }

    final RelDataTypeFactory factory = getCluster().getTypeFactory();
    final FieldInfoBuilder builder = new FieldInfoBuilder(factory);
    final Map<String, RelDataType> fields = new HashMap<>();
    for(Field field : getBatchSchema()){
      if(firstLevelPaths.contains(field.getName())){
        fields.put(field.getName(), CompleteType.fromField(field).toCalciteType(factory));
      }
    }

    Preconditions.checkArgument(firstLevelPaths.size() == fields.size(), "Projected column base size %d is not equal to outcome rowtype %d.", firstLevelPaths.size(), fields.size());

    for(String path : firstLevelPaths){
      builder.add(path, fields.get(path));
    }
    this.rowType = builder.build();
  } else {
    this.rowType = deriveRowType();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:ScanRelBase.java

示例11: getPlan

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  final ConvertedRelNode convertedRelNode = validateAndConvert(sqlNode);
  final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
  final RelNode queryRelNode = convertedRelNode.getConvertedNode();

  log("Optiq Logical", queryRelNode, logger);
  DrillRel drel = convertToDrel(queryRelNode, validatedRowType);

  log("Drill Logical", drel, logger);
  Prel prel = convertToPrel(drel);
  log("Drill Physical", prel, logger);
  PhysicalOperator pop = convertToPop(prel);
  PhysicalPlan plan = convertToPlan(pop);
  log("Drill Plan", plan, logger);
  return plan;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:DefaultSqlHandler.java

示例12: QueryMetadata

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
public QueryMetadata(List<SqlIdentifier> ancestors,
                     List<FieldOrigin> fieldOrigins, List<JoinInfo> joins, List<ParentDatasetInfo> parents,
                     SqlNode sqlNode, RelDataType rowType,
                     List<ParentDataset> grandParents, final RelOptCost cost, final PlanningSet planningSet,
                     final RelNode serializableLogicalPlan,
                     BatchSchema batchSchema) {
  this.rowType = rowType;

  this.ancestors = Optional.fromNullable(ancestors);
  this.fieldOrigins = Optional.fromNullable(fieldOrigins);
  this.joins = Optional.fromNullable(joins);
  this.parents = Optional.fromNullable(parents);
  this.sqlNode = Optional.fromNullable(sqlNode);
  this.grandParents = Optional.fromNullable(grandParents);
  this.cost = Optional.fromNullable(cost);
  this.planningSet = Optional.fromNullable(planningSet);
  this.serializableLogicalPlan = Optional.fromNullable(serializableLogicalPlan);
  this.batchSchema = batchSchema;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:QueryMetadata.java

示例13: ProjectRelBase

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
protected ProjectRelBase(Convention convention,
                              RelOptCluster cluster,
                              RelTraitSet traits,
                              RelNode child,
                              List<? extends RexNode> exps,
                              RelDataType rowType) {
  super(cluster, traits, child, exps, rowType, Flags.BOXED);
  assert getConvention() == convention;
  nonSimpleFieldCount = this.getRowType().getFieldCount() - getSimpleFieldCount();

  boolean foundContains = false;
  int i = 0;
  for (RexNode rex : this.getChildExps()) {
    if (ContainsRexVisitor.hasContainsCheckOrigin(this, rex, i)) {
      foundContains = true;
      break;
    }
    i++;
  }
  this.hasContains = foundContains;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:ProjectRelBase.java

示例14: convertCall

import org.apache.calcite.rel.type.RelDataType; //导入依赖的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: getPlan

import org.apache.calcite.rel.type.RelDataType; //导入依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  final ConvertedRelNode convertedRelNode = validateAndConvert(sqlNode);
  final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
  final RelNode queryRelNode = convertedRelNode.getConvertedNode();

  log("Optiq Logical", queryRelNode, logger);
  DrillRel drel = convertToDrel(queryRelNode, validatedRowType);
  log("Drill Logical", drel, logger);

  if (mode == ResultMode.LOGICAL) {
    LogicalExplain logicalResult = new LogicalExplain(drel, level, context);
    return DirectPlan.createDirectPlan(context, logicalResult);
  }

  Prel prel = convertToPrel(drel);
  log("Drill Physical", prel, logger);
  PhysicalOperator pop = convertToPop(prel);
  PhysicalPlan plan = convertToPlan(pop);
  log("Drill Plan", plan, logger);
  PhysicalExplain physicalResult = new PhysicalExplain(prel, plan, level, context);
  return DirectPlan.createDirectPlan(context, physicalResult);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:ExplainHandler.java


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