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


Java RelConversionException类代码示例

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


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

示例1: rewrite

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
  List<SqlNode> selectList =
      ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));

  SqlNode fromClause = new SqlIdentifier(
      ImmutableList.of(IS_SCHEMA_NAME, TAB_SCHEMATA), null, SqlParserPos.ZERO, null);

  SqlNode where = null;
  final SqlNode likePattern = node.getLikePattern();
  if (likePattern != null) {
    where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
                                            SqlStdOperatorTable.LIKE, likePattern);
  } else if (node.getWhereClause() != null) {
    where = node.getWhereClause();
  }

  return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
      fromClause, where, null, null, null, null, null, null);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:ShowSchemasHandler.java

示例2: getPlan

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
/**
 * Function resolves the schema and invokes the drop method. Raises an exception if the schema is
 * immutable.
 * @param sqlNode - Table name identifier
 * @return - Single row indicating drop succeeded, raise exception otherwise
 * @throws ValidationException
 * @throws RelConversionException
 * @throws IOException
 */
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException {

  SqlDropTable dropTableNode = ((SqlDropTable) sqlNode);
  SqlIdentifier tableIdentifier = dropTableNode.getTableIdentifier();

  SchemaPlus defaultSchema = context.getNewDefaultSchema();
  AbstractSchema drillSchema = null;

  if (tableIdentifier != null) {
    drillSchema = SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, dropTableNode.getSchema());
  }

  String tableName = ((SqlDropTable) sqlNode).getName();
  if (drillSchema == null) {
    throw UserException.validationError()
        .message("Invalid table_name [%s]", tableName)
        .build(logger);
  }

  drillSchema.dropTable(tableName);

  return DirectPlan.createDirectPlan(context, true,
      String.format("Table [%s] %s", tableName, "dropped"));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:35,代码来源:DropTableHandler.java

示例3: getPlan

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

示例4: validateNode

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
private TypedSqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
  TypedSqlNode typedSqlNode = planner.validateAndGetType(sqlNode);

  SqlNode sqlNodeValidated = typedSqlNode.getSqlNode();

  // Check if the unsupported functionality is used
  UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(context);
  try {
    sqlNodeValidated.accept(visitor);
  } catch (UnsupportedOperationException ex) {
    // If the exception due to the unsupported functionalities
    visitor.convertException();

    // If it is not, let this exception move forward to higher logic
    throw ex;
  }

  return typedSqlNode;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DefaultSqlHandler.java

示例5: convertToRel

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
private RelNode convertToRel(SqlNode node) throws RelConversionException {
  final RelNode convertedNode = planner.convert(node);

  final RelMetadataProvider provider = convertedNode.getCluster().getMetadataProvider();

  // Register RelMetadataProvider with HepPlanner.
  final List<RelMetadataProvider> list = Lists.newArrayList(provider);
  hepPlanner.registerMetadataProviders(list);
  final RelMetadataProvider cachingMetaDataProvider = new CachingRelMetadataProvider(ChainedRelMetadataProvider.of(list), hepPlanner);
  convertedNode.accept(new MetaDataProviderModifier(cachingMetaDataProvider));

  // HepPlanner is specifically used for Window Function planning only.
  hepPlanner.setRoot(convertedNode);
  RelNode rel = hepPlanner.findBestExp();

  rel.accept(new MetaDataProviderModifier(provider));
  return rel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:DefaultSqlHandler.java

示例6: logicalPlanningVolcanoAndLopt

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
/**
 * Do logical planning using both VolcanoPlanner and LOPT HepPlanner.
 * @param relNode
 * @return
 * @throws RelConversionException
 * @throws SqlUnsupportedException
 */
private RelNode logicalPlanningVolcanoAndLopt(RelNode relNode) throws RelConversionException, SqlUnsupportedException {

  final RelNode convertedRelNode = planner.transform(DrillSqlWorker.LOGICAL_CONVERT_RULES, relNode.getTraitSet().plus(DrillRel.DRILL_LOGICAL), relNode);
  log("VolCalciteRel", convertedRelNode, logger);

  final RelNode loptNode = getLoptJoinOrderTree(
      convertedRelNode,
      DrillJoinRel.class,
      DrillRelFactories.DRILL_LOGICAL_JOIN_FACTORY,
      DrillRelFactories.DRILL_LOGICAL_FILTER_FACTORY,
      DrillRelFactories.DRILL_LOGICAL_PROJECT_FACTORY);

  log("HepCalciteRel", loptNode, logger);

  return loptNode;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DefaultSqlHandler.java

示例7: getPlan

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  SqlDropView dropView = unwrap(sqlNode, SqlDropView.class);
  final String viewToDrop = dropView.getName();
  final AbstractSchema drillSchema =
      SchemaUtilites.resolveToMutableDrillSchema(context.getNewDefaultSchema(), dropView.getSchemaPath());

  final String schemaPath = drillSchema.getFullSchemaName();

  final Table existingTable = SqlHandlerUtil.getTableFromSchema(drillSchema, viewToDrop);
  if (existingTable != null && existingTable.getJdbcTableType() != Schema.TableType.VIEW) {
    throw UserException.validationError()
        .message("[%s] is not a VIEW in schema [%s]", viewToDrop, schemaPath)
        .build(logger);
  } else if (existingTable == null) {
    throw UserException.validationError()
        .message("Unknown view [%s] in schema [%s].", viewToDrop, schemaPath)
        .build(logger);
  }

  drillSchema.dropView(viewToDrop);

  return DirectPlan.createDirectPlan(context, true,
      String.format("View [%s] deleted successfully from schema [%s].", viewToDrop, schemaPath));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:26,代码来源:ViewHandler.java

示例8: getPlan

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

示例9: rewrite

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlExplain node = unwrap(sqlNode, SqlExplain.class);
  SqlLiteral op = node.operand(2);
  SqlExplain.Depth depth = (SqlExplain.Depth) op.getValue();
  if (node.getDetailLevel() != null) {
    level = node.getDetailLevel();
  }
  switch (depth) {
  case LOGICAL:
    mode = ResultMode.LOGICAL;
    break;
  case PHYSICAL:
    mode = ResultMode.PHYSICAL;
    break;
  default:
    throw new UnsupportedOperationException("Unknown depth " + depth);
  }

  return node.operand(0);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:ExplainHandler.java

示例10: convertToDrel

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
private static Rel convertToDrel(
    SqlHandlerConfig config,
    RelNode relNode,
    AbstractSchema schema,
    String tableName,
    WriterOptions options,
    RelDataType queryRowType,
    final Map<String, Object> storageOptions)
    throws RelConversionException, SqlUnsupportedException {

  Rel convertedRelNode = PrelTransformer.convertToDrel(config, relNode);

  // Put a non-trivial topProject to ensure the final output field name is preserved, when necessary.
  // Only insert project when the field count from the child is same as that of the queryRowType.

  convertedRelNode = new WriterRel(convertedRelNode.getCluster(),
      convertedRelNode.getCluster().traitSet().plus(Rel.LOGICAL),
      convertedRelNode, schema.createNewTable(tableName, options, storageOptions), queryRowType);

  convertedRelNode = SqlHandlerUtil.storeQueryResultsIfNeeded(config.getConverter().getParserConfig(),
      config.getContext(), convertedRelNode);

  return new ScreenRel(convertedRelNode.getCluster(), convertedRelNode.getTraitSet(), convertedRelNode);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:25,代码来源:CreateTableHandler.java

示例11: coerceException

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
public static Exception coerceException(Logger logger, String sql, Exception e, boolean coerceToPlan){
  if(e instanceof UserException){
    return e;
  } else if(e instanceof ValidationException){
    throw validationError(sql, (ValidationException) e).build(logger);
  } else if (e instanceof AccessControlException){
  throw UserException.permissionError(e)
      .addContext("Sql Query", sql)
      .build(logger);
  } else if (e instanceof SqlUnsupportedException){
  throw UserException.unsupportedError(e)
      .addContext("Sql Query", sql)
      .build(logger);
  } else if (e instanceof IOException || e instanceof RelConversionException){
    return new QueryInputException("Failure handling SQL.", e);
  } else if (coerceToPlan){
    throw UserException.planError(e)
    .addContext("Sql Query", sql)
    .build(logger);
  }
  return e;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:SqlExceptionHelper.java

示例12: validateNode

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
private TypedSqlNode validateNode(SqlNode sqlNode) throws ValidationException, RelConversionException, ForemanSetupException {
  final SqlNode sqlNodeValidated = config.getConverter().validate(sqlNode);
  final TypedSqlNode typedSqlNode = new TypedSqlNode(sqlNodeValidated, config.getConverter().getOutputType(
      sqlNodeValidated));

  // Check if the unsupported functionality is used
  UnsupportedOperatorsVisitor visitor = UnsupportedOperatorsVisitor.createVisitor(context);
  try {
    sqlNodeValidated.accept(visitor);
  } catch (UnsupportedOperationException ex) {
    // If the exception due to the unsupported functionalities
    visitor.convertException();

    // If it is not, let this exception move forward to higher logic
    throw ex;
  }

  return typedSqlNode;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:DefaultSqlHandler.java

示例13: getPlan

import org.apache.calcite.tools.RelConversionException; //导入依赖的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("Calcite", queryRelNode, logger, null);
  DrillRel drel = convertToDrel(queryRelNode);

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

  Prel prel = convertToPrel(drel, validatedRowType);
  logAndSetTextPlan("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:axbaretto,项目名称:drill,代码行数:23,代码来源:ExplainHandler.java

示例14: convertToDrel

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
private DrillRel convertToDrel(RelNode relNode,
                               AbstractSchema schema,
                               String tableName,
                               List<String> partitionColumns,
                               RelDataType queryRowType,
                               StorageStrategy storageStrategy)
    throws RelConversionException, SqlUnsupportedException {
  final DrillRel convertedRelNode = convertToRawDrel(relNode);

  // Put a non-trivial topProject to ensure the final output field name is preserved, when necessary.
  // Only insert project when the field count from the child is same as that of the queryRowType.
  final DrillRel topPreservedNameProj = queryRowType.getFieldCount() == convertedRelNode.getRowType().getFieldCount() ?
      addRenamedProject(convertedRelNode, queryRowType) : convertedRelNode;

  final RelTraitSet traits = convertedRelNode.getCluster().traitSet().plus(DrillRel.DRILL_LOGICAL);
  final DrillWriterRel writerRel = new DrillWriterRel(convertedRelNode.getCluster(),
      traits, topPreservedNameProj, schema.createNewTable(tableName, partitionColumns, storageStrategy));
  return new DrillScreenRel(writerRel.getCluster(), writerRel.getTraitSet(), writerRel);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:CreateTableHandler.java

示例15: rel

import org.apache.calcite.tools.RelConversionException; //导入依赖的package包/类
public RelRoot rel(SqlNode sql) throws RelConversionException {
  ensure(State.STATE_4_VALIDATED);
  assert validatedSqlNode != null;
  final RexBuilder rexBuilder = createRexBuilder();
  final RelOptCluster cluster = RelOptCluster.create(planner, rexBuilder);
  final SqlToRelConverter.Config config = SqlToRelConverter.configBuilder()
      .withConfig(sqlToRelConverterConfig)
      .withTrimUnusedFields(false)
      .withConvertTableAccess(false)
      .build();
  final SqlToRelConverter sqlToRelConverter =
      new SqlToRelConverter(new ViewExpanderImpl(), validator,
          createCatalogReader(), cluster, convertletTable, config);
  root =
      sqlToRelConverter.convertQuery(validatedSqlNode, false, true);
  root = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true));
  root = root.withRel(RelDecorrelator.decorrelateQuery(root.rel));
  state = State.STATE_5_CONVERTED;
  return root;
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:PlannerImpl.java


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