org.apache.calcite.schema.impl.AbstractTable Java Examples

The following examples show how to use org.apache.calcite.schema.impl.AbstractTable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BatsOptimizerTest.java    From Bats with Apache License 2.0 6 votes vote down vote up
static Table createTable() {
    return new AbstractTable() {
        @Override
        public RelDataType getRowType(final RelDataTypeFactory typeFactory) {
            RelDataTypeFactory.Builder builder = typeFactory.builder();

            RelDataType t1 = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.INTEGER),
                    true);
            RelDataType t2 = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.INTEGER),
                    true);
            RelDataType t3 = typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.INTEGER),
                    true);

            builder.add("f1", t1);
            builder.add("f2", t2);
            builder.add("f3", t3);
            return builder.build();
        }
    };
}
 
Example #2
Source File: NormalizationTrimFieldTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
public static Frameworks.ConfigBuilder config() {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  rootSchema.add("mv0", new AbstractTable() {
    @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
      return typeFactory.builder()
          .add("deptno", SqlTypeName.INTEGER)
          .add("count_sal", SqlTypeName.BIGINT)
          .build();
    }
  });
  return Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(
          CalciteAssert.addSchema(rootSchema, CalciteAssert.SchemaSpec.SCOTT_WITH_TEMPORAL))
      .traitDefs((List<RelTraitDef>) null);
}
 
Example #3
Source File: LexEscapeTest.java    From calcite with Apache License 2.0 6 votes vote down vote up
private static Planner getPlanner(List<RelTraitDef> traitDefs,
    Config parserConfig, Program... programs) {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  rootSchema.add("TMP", new AbstractTable() {
    @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
      return typeFactory.createStructType(
          ImmutableList.of(typeFactory.createSqlType(SqlTypeName.VARCHAR),
              typeFactory.createSqlType(SqlTypeName.INTEGER)),
          ImmutableList.of("localtime", "current_timestamp"));
    }
  });
  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(parserConfig)
      .defaultSchema(rootSchema)
      .traitDefs(traitDefs)
      .programs(programs)
      .operatorTable(SqlStdOperatorTable.instance())
      .build();
  return Frameworks.getPlanner(config);
}
 
Example #4
Source File: QueryPlanner.java    From samza with Apache License 2.0 5 votes vote down vote up
private static Table createTableFromRelSchema(RelDataType relationalSchema) {
  return new AbstractTable() {
    public RelDataType getRowType(RelDataTypeFactory typeFactory) {
      return relationalSchema;
    }
  };
}