Example #1
0
 @Override
 protected SqlToRelConverter getSqlToRelConverter(
     SqlValidator validator, CatalogReader catalogReader) {
   SqlToRelConverter sqlToRelConverter =
       new SqlToRelConverter(this, validator, catalogReader, env, planner, rexBuilder);
   sqlToRelConverter.setTrimUnusedFields(false);
   return sqlToRelConverter;
 }
Example #2
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;
 }