Exemplo n.º 1
0
 public RelNode convertSqlToRel(String sql) {
   Util.pre(sql != null, "sql != null");
   final SqlNode sqlQuery;
   try {
     sqlQuery = parseQuery(sql);
   } catch (Exception e) {
     throw Util.newInternal(e); // todo: better handling
   }
   final RelDataTypeFactory typeFactory = getTypeFactory();
   final Prepare.CatalogReader catalogReader = createCatalogReader(typeFactory);
   final SqlValidator validator = createValidator(catalogReader, typeFactory);
   final SqlToRelConverter converter =
       createSqlToRelConverter(validator, catalogReader, typeFactory);
   converter.setTrimUnusedFields(true);
   final SqlNode validatedQuery = validator.validate(sqlQuery);
   final RelNode rel = converter.convertQuery(validatedQuery, false, true);
   Util.post(rel != null, "return != null");
   return rel;
 }
 /**
  * Validates this node in an expression context.
  *
  * <p>Usually, this method does much the same as {@link #validate}, but a {@link SqlIdentifier}
  * can occur in expression and non-expression contexts.
  */
 public void validateExpr(SqlValidator validator, SqlValidatorScope scope) {
   validate(validator, scope);
   Util.discard(validator.deriveType(scope, this));
 }