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


Java ValidationException类代码示例

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


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

示例1: setDefaultSchemaPath

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
/**
 * Update the schema path for the session.
 * @param newDefaultSchemaPath New default schema path to set. It could be relative to the current default schema or
 *                             absolute schema.
 * @param currentDefaultSchema Current default schema.
 * @throws ValidationException If the given default schema path is invalid in current schema tree.
 */
public void setDefaultSchemaPath(String newDefaultSchemaPath, SchemaPlus currentDefaultSchema)
    throws ValidationException {
  final List<String> newDefaultPathAsList = Lists.newArrayList(newDefaultSchemaPath.split("\\."));
  SchemaPlus newDefault;

  // First try to find the given schema relative to the current default schema.
  newDefault = SchemaUtilites.findSchema(currentDefaultSchema, newDefaultPathAsList);

  if (newDefault == null) {
    // If we fail to find the schema relative to current default schema, consider the given new default schema path as
    // absolute schema path.
    newDefault = SchemaUtilites.findSchema(currentDefaultSchema, newDefaultPathAsList);
  }

  if (newDefault == null) {
    SchemaUtilites.throwSchemaNotFoundException(currentDefaultSchema, newDefaultSchemaPath);
  }

  setProp(SCHEMA, SchemaUtilites.getSchemaPath(newDefault));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:28,代码来源:UserSession.java

示例2: getPlan

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

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

示例6: getPlan

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

示例7: validationError

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
public static UserException.Builder validationError(String query, ValidationException ex) {
  Throwable cause = ex;
  if (ex.getCause() != null) {
    // ValidationException generally wraps the "real" cause that we are interested in
    cause = ex.getCause();
  }
  UserException.Builder b = UserException.validationError(cause)
    .addContext("Sql Query", query);

  // CalciteContextException alters the error message including the start/end positions
  // we need to extract the original error message and add the remaining information as context
  if (cause instanceof CalciteContextException && cause.getCause() != null) {
    CalciteContextException cce = (CalciteContextException) cause;
    b.message(cce.getCause().getMessage())
            .addContext("startLine", cce.getPosLine())
            .addContext("startColumn", cce.getPosColumn())
            .addContext("endLine", cce.getEndPosLine())
            .addContext("endColumn", cce.getEndPosColumn());
  }
  return b;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:SqlExceptionHelper.java

示例8: coerceException

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

示例9: setDefaultSchemaPath

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
/**
   * Update the schema path for the session.
   * @param newDefaultSchemaPath New default schema path to set. It could be relative to the current default schema or
   *                             absolute schema.
   * @param currentDefaultSchema Current default schema.
   * @throws ValidationException If the given default schema path is invalid in current schema tree.
   */
  public void setDefaultSchemaPath(String newDefaultSchemaPath, SchemaPlus currentDefaultSchema)
      throws ValidationException {
    final List<String> newDefaultPathAsList = SqlUtils.parseSchemaPath(newDefaultSchemaPath);

    SchemaPlus newDefault = null;

    // First try to find the given schema relative to the current default schema.
    // TODO validate if schema exists
//    newDefault = SchemaUtilities.findSchema(currentDefaultSchema, newDefaultPathAsList);

    if (newDefault == null) {
      // If we fail to find the schema relative to current default schema, consider the given new default schema path as
      // absolute schema path.
      newDefault = SchemaUtilities.findSchema(currentDefaultSchema, newDefaultPathAsList);
    }

    if (newDefault == null) {
      SchemaUtilities.throwSchemaNotFoundException(currentDefaultSchema, newDefaultSchemaPath);
    }

    setProp(SCHEMA, SchemaUtilities.getSchemaPath(newDefault));
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:30,代码来源:UserSession.java

示例10: setDefaultSchemaPath

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
/**
 * Update the schema path for the session.
 * @param newDefaultSchemaPath New default schema path to set. It could be relative to the current default schema or
 *                             absolute schema.
 * @param currentDefaultSchema Current default schema.
 * @throws ValidationException If the given default schema path is invalid in current schema tree.
 */
public void setDefaultSchemaPath(String newDefaultSchemaPath, SchemaPlus currentDefaultSchema)
    throws ValidationException {
  final List<String> newDefaultPathAsList = Lists.newArrayList(newDefaultSchemaPath.split("\\."));
  SchemaPlus newDefault;

  // First try to find the given schema relative to the current default schema.
  newDefault = SchemaUtilites.findSchema(currentDefaultSchema, newDefaultPathAsList);

  if (newDefault == null) {
    // If we fail to find the schema relative to current default schema, consider the given new default schema path as
    // absolute schema path.
    newDefault = SchemaUtilites.findSchema(currentDefaultSchema, newDefaultPathAsList);
  }

  if (newDefault == null) {
    SchemaUtilites.throwSchemaNotFoundException(currentDefaultSchema, newDefaultSchemaPath);
  }

  properties.setProperty(DrillProperties.SCHEMA, SchemaUtilites.getSchemaPath(newDefault));
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:28,代码来源:UserSession.java

示例11: validateNode

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

示例12: getPlan

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

示例13: validate

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
public SqlNode validate(SqlNode sqlNode) throws ValidationException {
  ensure(State.STATE_3_PARSED);
  final SqlConformance conformance = conformance();
  final CalciteCatalogReader catalogReader = createCatalogReader();
  this.validator =
      new CalciteSqlValidator(operatorTable, catalogReader, typeFactory,
          conformance);
  this.validator.setIdentifierExpansion(true);
  try {
    validatedSqlNode = validator.validate(sqlNode);
  } catch (RuntimeException e) {
    throw new ValidationException(e);
  }
  state = State.STATE_4_VALIDATED;
  return validatedSqlNode;
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:PlannerImpl.java

示例14: runProjectQueryWithLex

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
private static void runProjectQueryWithLex(Lex lex, String sql)
    throws SqlParseException, ValidationException, RelConversionException {
  Config javaLex = SqlParser.configBuilder().setLex(lex).build();
  Planner planner = getPlanner(null, javaLex, Programs.ofRules(Programs.RULE_SET));
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet =
      planner.getEmptyTraitSet().replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(transform, instanceOf(EnumerableProject.class));
  List<String> fieldNames = transform.getRowType().getFieldNames();
  assertThat(fieldNames.size(), is(2));
  if (lex.caseSensitive) {
    assertThat(fieldNames.get(0), is("EMPID"));
    assertThat(fieldNames.get(1), is("empid"));
  } else {
    assertThat(fieldNames.get(0) + "-" + fieldNames.get(1),
        anyOf(is("EMPID-empid0"), is("EMPID0-empid")));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LexCaseSensitiveTest.java

示例15: getPlan

import org.apache.calcite.tools.ValidationException; //导入依赖的package包/类
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException, RelConversionException, IOException, ForemanSetupException {
  final SqlUseSchema useSchema = unwrap(sqlNode, SqlUseSchema.class);
  final String newDefaultSchemaPath = useSchema.getSchema();

  context.getSession().setDefaultSchemaPath(newDefaultSchemaPath, context.getNewDefaultSchema());

  return DirectPlan.createDirectPlan(context, true,
      String.format("Default schema changed to [%s]", context.getSession().getDefaultSchemaPath()));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:UseSchemaHandler.java


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