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


Java RelNode.getRowType方法代码示例

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


在下文中一共展示了RelNode.getRowType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deriveCopiedRowTypeFromInput

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
/**
 * Derive rowType for the copied WindowPrel based on input.
 * When copy() is called, the input might be different from the current one's input.
 * We have to use the new input's field in the copied WindowPrel.
 */
private RelDataType deriveCopiedRowTypeFromInput(final RelNode input) {
  final RelDataType inputRowType = input.getRowType();
  final RelDataType windowRowType = this.getRowType();

  final List<RelDataTypeField> fieldList = new ArrayList<>(inputRowType.getFieldList());
  final int inputFieldCount = inputRowType.getFieldCount();
  final int windowFieldCount = windowRowType.getFieldCount();

  for (int i = inputFieldCount; i < windowFieldCount; i++) {
    fieldList.add(windowRowType.getFieldList().get(i));
  }

  final RelDataType rowType = this.getCluster().getRexBuilder().getTypeFactory().createStructType(fieldList);

  return rowType;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:WindowPrel.java

示例2: JdbcPrel

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public JdbcPrel(RelOptCluster cluster, RelTraitSet traitSet, JdbcIntermediatePrel prel) {
  super(cluster, traitSet);
  final RelNode input = prel.getInput();
  rows = input.getRows();
  convention = (DrillJdbcConvention) input.getTraitSet().getTrait(ConventionTraitDef.INSTANCE);

  // generate sql for tree.
  final SqlDialect dialect = convention.getPlugin().getDialect();
  final JdbcImplementor jdbcImplementor = new JdbcImplementor(
      dialect,
      (JavaTypeFactory) getCluster().getTypeFactory());
  final JdbcImplementor.Result result =
      jdbcImplementor.visitChild(0, input.accept(new SubsetRemover()));
  sql = result.asQuery().toSqlString(dialect).getSql();
  rowType = input.getRowType();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:JdbcPrel.java

示例3: visit

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  RelNode input = project.getInput().accept(this);
  RelDataType incomingRowType = input.getRowType();
  List<RexNode> newProjects;
  RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false);
  if (modField == null) {
    return project;
  }
  newProjects = FluentIterable.from(project.getProjects())
    .append(new RexInputRef(modField.getIndex(), modField.getType()))
    .toList();
  FieldInfoBuilder fieldInfoBuilder = new FieldInfoBuilder(project.getCluster().getTypeFactory());
  for (RelDataTypeField field : project.getRowType().getFieldList()) {
    fieldInfoBuilder.add(field);
  }
  fieldInfoBuilder.add(UPDATE_COLUMN, modField.getType());
  return new LogicalProject(
    project.getCluster(),
    project.getTraitSet(),
    input,
    newProjects,
    fieldInfoBuilder.build()
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:IncrementalUpdateUtils.java

示例4: onMatch

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
  final FilterRel filter = call.rel(0);
  final FlattenRel flatten = call.rel(1);
  final RelNode child = flatten.getInput();

  RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  List<RexNode> rexProjExprs = new ArrayList<>();
  List<RexNode> rexItemExprs = new ArrayList<>();
  for (int index = 0; index < child.getRowType().getFieldCount(); index++) {
    rexProjExprs.add(rexBuilder.makeInputRef(child.getRowType().getFieldList().get(index).getType(), index));
    rexItemExprs.add(rexBuilder.makeInputRef(child.getRowType().getFieldList().get(index).getType(), index));
  }
  rexItemExprs.add(filter.getCondition());

  ProjectForFlattenRel projectForFlattenRel = new ProjectForFlattenRel(
      flatten.getCluster(),
      flatten.getTraitSet(),
      child,
      child.getRowType(),
      rexProjExprs,
      rexItemExprs);
  FlattenRel newFlatten = new FlattenRel(
      flatten.getCluster(),
      flatten.getTraitSet(),
      projectForFlattenRel,
      flatten.getToFlatten(),
      flatten.getNumProjectsPushed() + 1);
  FilterRel newFilter = new FilterRel(filter.getCluster(), filter.getTraitSet(), newFlatten, filter.getCondition(), true);
  call.transformTo(newFilter);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:PushFiltersProjectPastFlattenRule.java

示例5: getPlan

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  SqlCreateView createView = unwrap(sqlNode, SqlCreateView.class);

  final String newViewName = createView.getName();

  // Store the viewSql as view def SqlNode is modified as part of the resolving the new table definition below.
  final String viewSql = createView.getQuery().toString();

  final ConvertedRelNode convertedRelNode = validateAndConvert(createView.getQuery());
  final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
  final RelNode queryRelNode = convertedRelNode.getConvertedNode();

  final RelNode newViewRelNode = SqlHandlerUtil.resolveNewTableRel(true, createView.getFieldNames(), validatedRowType, queryRelNode);

  final SchemaPlus defaultSchema = context.getNewDefaultSchema();
  final AbstractSchema drillSchema = SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, createView.getSchemaPath());

  final String schemaPath = drillSchema.getFullSchemaName();
  final View view = new View(newViewName, viewSql, newViewRelNode.getRowType(),
      SchemaUtilites.getSchemaPathAsList(defaultSchema));

  final Table existingTable = SqlHandlerUtil.getTableFromSchema(drillSchema, newViewName);

  if (existingTable != null) {
    if (existingTable.getJdbcTableType() != Schema.TableType.VIEW) {
      // existing table is not a view
      throw UserException.validationError()
          .message("A non-view table with given name [%s] already exists in schema [%s]",
              newViewName, schemaPath)
          .build(logger);
    }

    if (existingTable.getJdbcTableType() == Schema.TableType.VIEW && !createView.getReplace()) {
      // existing table is a view and create view has no "REPLACE" clause
      throw UserException.validationError()
          .message("A view with given name [%s] already exists in schema [%s]",
              newViewName, schemaPath)
          .build(logger);
    }
  }

  final boolean replaced = drillSchema.createView(view);
  final String summary = String.format("View '%s' %s successfully in '%s' schema",
      createView.getName(), replaced ? "replaced" : "created", schemaPath);

  return DirectPlan.createDirectPlan(context, true, summary);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:49,代码来源:ViewHandler.java

示例6: toResult

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public List<SimpleCommandResult> toResult(String sql, SqlNode sqlNode) throws Exception {
    SqlCreateView createView = SqlNodeUtil.unwrap(sqlNode, SqlCreateView.class);

    final String newViewName = createView.getName();

    // Store the viewSql as view def SqlNode is modified as part of the resolving the new table definition below.
    final String viewSql = createView.getQuery().toSqlString(new SqlDialect(SqlDialect.CALCITE.getDatabaseProduct(), SqlDialect.CALCITE.getDatabaseProduct().name(), ParserConfig.QUOTING.string)).getSql();
    final ConvertedRelNode convertedRelNode = PrelTransformer.validateAndConvert(config, createView.getQuery());
    final RelDataType validatedRowType = convertedRelNode.getValidatedRowType();
    final RelNode queryRelNode = convertedRelNode.getConvertedNode();

    final RelNode newViewRelNode = SqlHandlerUtil.resolveNewTableRel(true, createView.getFieldNames(), validatedRowType, queryRelNode);

    final SchemaPlus defaultSchema = context.getNewDefaultSchema();
    final AbstractSchema schemaInstance = SchemaUtilities.resolveToMutableSchemaInstance(defaultSchema, createView.getSchemaPath(), systemUser, MutationType.VIEW);

    final String schemaPath = schemaInstance.getFullSchemaName();
    final View view = new View(newViewName, viewSql, newViewRelNode.getRowType(), SchemaUtilities.getSchemaPathAsList(defaultSchema));

    final Table existingTable = SqlHandlerUtil.getTableFromSchema(schemaInstance, newViewName);

    if (existingTable != null) {
      if (existingTable.getJdbcTableType() != Schema.TableType.VIEW) {
        // existing table is not a view
        throw UserException.validationError()
            .message("A non-view table with given name [%s] already exists in schema [%s]",
                newViewName, schemaPath
            )
            .build(logger);
      }

      if (existingTable.getJdbcTableType() == Schema.TableType.VIEW && !createView.getReplace()) {
        // existing table is a view and create view has no "REPLACE" clause
        throw UserException.validationError()
            .message("A view with given name [%s] already exists in schema [%s]",
                newViewName, schemaPath
            )
            .build(logger);
      }
    }

    final boolean replaced = schemaInstance.createView(view);
    return Collections.singletonList(SimpleCommandResult.successful("View '%s' %s successfully in '%s' schema",
        createView.getName(), replaced ? "replaced" : "created", schemaPath));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:47,代码来源:CreateViewHandler.java

示例7: JdbcRelBase

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
public JdbcRelBase(RelOptCluster cluster, RelTraitSet traitSet, RelNode jdbcSubTree) {
  super(cluster, traitSet);
  this.jdbcSubTree = Preconditions.checkNotNull(jdbcSubTree);
  this.rowType = jdbcSubTree.getRowType();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:6,代码来源:JdbcRelBase.java

示例8: execute

import org.apache.calcite.rel.RelNode; //导入方法依赖的package包/类
@Override
public void execute(final StageContext context) {
  final Acceleration acceleration = context.getCurrentAcceleration();
  final JobsService jobsService = context.getJobsService();
  final NamespaceService namespaceService = context.getNamespaceService();
  final OptionManager optionManager = context.getOptionManager();

  final boolean removeProject = optionManager.getOption(ExecConstants.ACCELERATION_RAW_REMOVE_PROJECT);
  final boolean enableMinMax = optionManager.getOption(ExecConstants.ACCELERATION_ENABLE_MIN_MAX);

  final DatasetConfig config = context.getNamespaceService().findDatasetByUUID(acceleration.getId().getId());
  final NamespaceKey path = new NamespaceKey(config.getFullPathList());
  final RelNode accPlan = context.getAccelerationAnalysisPlan();
  final RelNode datasetPlan = removeUpdateColumn(null != accPlan ? accPlan : createAnalyzer(jobsService).getPlan(path));

  final LogicalPlanSerializer serializer = createSerializer(datasetPlan.getCluster());
  final LayoutExpander expander = createExpander(datasetPlan, enableMinMax);

  final Iterable<Layout> layouts = AccelerationUtils.getAllLayouts(acceleration);
  for (final Layout layout : layouts) {
    final RelNode plan = expander.expand(layout);
    // DX-6734
    final Normalizer normalizer = (layout.getLayoutType() == LayoutType.AGGREGATION || removeProject) ? getAggregationViewNormalizer(context) : getRawViewNormalizer(context);

    final RelNode normalizedPlan = normalizer.normalize(plan);
    final ByteString planBytes = ByteString.copyFrom(serializer.serialize(normalizedPlan));

    final boolean incremental = IncrementalUpdateUtils.getIncremental(normalizedPlan, namespaceService);
    final String refreshField = !incremental ? null : IncrementalUpdateUtils.findRefreshField(normalizedPlan, namespaceService);

    // we use normalized schema in storage plugin during expansion to report rowtype
    // NEVER report/leak normalized schema to user because it is meaningless crap
    // user must see a subset of dataset schema not normalized schema.
    final RelDataType normalizedSchema = normalizedPlan.getRowType();
    final RowType schema = new RowType()
        .setFieldList(Views.viewToFieldTypes(Views.relDataTypeToFieldType(normalizedSchema)));

    layout
        .setLogicalPlan(planBytes)
        .setLayoutSchema(schema)
        .setIncremental(incremental)
        .setRefreshField(refreshField);
  }

  context.commit(acceleration);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:47,代码来源:PlanningStage.java


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