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


Java RelDataTypeSystem.DEFAULT属性代码示例

本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeSystem.DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeSystem.DEFAULT属性的具体用法?Java RelDataTypeSystem.DEFAULT怎么用?Java RelDataTypeSystem.DEFAULT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.calcite.rel.type.RelDataTypeSystem的用法示例。


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

示例1: OctopusTable

public OctopusTable(MetaTable metaTable, OctopusSchema schema) {
    super(Object[].class);
    name = metaTable.getName();

    try {
        //tableType = Schema.TableType.valueOf(table.getType().name());
        tableType = Schema.TableType.TABLE; // FIXME
    } catch (IllegalArgumentException e) {
        tableType = Schema.TableType.TABLE;
    }

    RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
    RelDataTypeFactory.FieldInfoBuilder fieldInfo = typeFactory.builder();
    for (MetaColumn metaColumn : metaTable.getColumns()) {
        String columnName = metaColumn.getName();
        //int jdbcType = metaColumn.getType().getJdbcType();
        int jdbcType = metaColumn.getType(); //FIXME
        SqlTypeName typeName = SqlTypeName.getNameForJdbcType(jdbcType);
        RelDataType sqlType = typeFactory.createSqlType(typeName);

        fieldInfo.add(columnName, sqlType);
    }
    protoRowType = RelDataTypeImpl.proto(fieldInfo.build());

    this.schema = schema;
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:26,代码来源:OctopusTable.java

示例2: testDateLiteral

/** Tests {@link RexBuilder#makeDateLiteral(DateString)}. */
@Test public void testDateLiteral() {
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  RelDataType dateType = typeFactory.createSqlType(SqlTypeName.DATE);
  final RexBuilder builder = new RexBuilder(typeFactory);

  // Old way: provide a Calendar
  final Calendar calendar = Util.calendar();
  calendar.set(1969, Calendar.JULY, 21); // one small step
  calendar.set(Calendar.MILLISECOND, 0);
  checkDate(builder.makeLiteral(calendar, dateType, false));

  // Old way #2: Provide in Integer
  checkDate(builder.makeLiteral(MOON_DAY, dateType, false));

  // The new way
  final DateString d = new DateString(1969, 7, 21);
  checkDate(builder.makeLiteral(d, dateType, false));
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:RexBuilderTest.java

示例3: operatorTable

/** Creates an operator table that contains functions in the given class.
 *
 * @see ModelHandler#addFunctions */
public static SqlOperatorTable operatorTable(String className) {
  // Dummy schema to collect the functions
  final CalciteSchema schema =
      CalciteSchema.createRootSchema(false, false);
  ModelHandler.addFunctions(schema.plus(), null, ImmutableList.<String>of(),
      className, "*", true);

  // The following is technical debt; see [CALCITE-2082] Remove
  // RelDataTypeFactory argument from SqlUserDefinedAggFunction constructor
  final SqlTypeFactoryImpl typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);

  final ListSqlOperatorTable table = new ListSqlOperatorTable();
  for (String name : schema.getFunctionNames()) {
    for (Function function : schema.getFunctions(name, true)) {
      final SqlIdentifier id = new SqlIdentifier(name, SqlParserPos.ZERO);
      table.add(
          toOp(typeFactory, id, function));
    }
  }
  return table;
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:CalciteCatalogReader.java

示例4: setUp

@Before public void setUp() {
  typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  rexBuilder = new RexBuilder(typeFactory);
  boolRelDataType = typeFactory.createSqlType(SqlTypeName.BOOLEAN);

  x = new RexInputRef(
      0,
      typeFactory.createTypeWithNullability(boolRelDataType, true));
  y = new RexInputRef(
      1,
      typeFactory.createTypeWithNullability(boolRelDataType, true));
  z = new RexInputRef(
      2,
      typeFactory.createTypeWithNullability(boolRelDataType, true));
  trueRex = rexBuilder.makeLiteral(true);
  falseRex = rexBuilder.makeLiteral(false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RexTransformerTest.java

示例5: setup

@Before
public void setup() {
  MockitoAnnotations.initMocks(this);

  final VolcanoPlanner planner = new VolcanoPlanner();
  typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  RelOptCluster cluster = RelOptCluster.create(planner, new RexBuilder(typeFactory));
  builder = DremioRelFactories.LOGICAL_BUILDER.create(cluster, schema);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:TestLayoutExpander.java

示例6: sqlOverDummyTable

public static CalciteState sqlOverDummyTable(String sql)
        throws RelConversionException, ValidationException, SqlParseException {
    SchemaPlus schema = Frameworks.createRootSchema(true);
    JavaTypeFactory typeFactory = new JavaTypeFactoryImpl
            (RelDataTypeSystem.DEFAULT);
    StreamableTable streamableTable = new CompilerUtil.TableBuilderInfo(typeFactory)
            .field("ID", SqlTypeName.INTEGER)
            .field("NAME", typeFactory.createType(String.class))
            .field("ADDR", typeFactory.createType(String.class))
            .build();
    Table table = streamableTable.stream();
    schema.add("FOO", table);
    schema.add("BAR", table);
    schema.add("MYPLUS", ScalarFunctionImpl.create(MyPlus.class, "eval"));

    List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
    sqlOperatorTables.add(SqlStdOperatorTable.instance());
    sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema),
            false,
            Collections.<String>emptyList(), typeFactory));
    SqlOperatorTable chainedSqlOperatorTable = new ChainedSqlOperatorTable(sqlOperatorTables);
    FrameworkConfig config = Frameworks.newConfigBuilder().defaultSchema(
            schema).operatorTable(chainedSqlOperatorTable).build();
    Planner planner = Frameworks.getPlanner(config);
    SqlNode parse = planner.parse(sql);
    SqlNode validate = planner.validate(parse);
    RelNode tree = planner.convert(validate);
    System.out.println(RelOptUtil.toString(tree, SqlExplainLevel.ALL_ATTRIBUTES));
    return new CalciteState(schema, tree);
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:30,代码来源:TestCompilerUtils.java

示例7: testEnsureTypeWithItself

/**
 * Test RexBuilder.ensureType()
 */
@Test
public void testEnsureTypeWithItself() {
  final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  RexBuilder builder = new RexBuilder(typeFactory);

  RexNode node =  new RexLiteral(
          Boolean.TRUE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN);
  RexNode ensuredNode = builder.ensureType(
          typeFactory.createSqlType(SqlTypeName.BOOLEAN), node, true);

  assertEquals(node, ensuredNode);
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RexBuilderTest.java

示例8: getRelDataType

RelProtoDataType getRelDataType(DatabaseMetaData metaData, String catalogName,
    String schemaName, String tableName) throws SQLException {
  final ResultSet resultSet =
      metaData.getColumns(catalogName, schemaName, tableName, null);

  // Temporary type factory, just for the duration of this method. Allowable
  // because we're creating a proto-type, not a type; before being used, the
  // proto-type will be copied into a real type factory.
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder();
  while (resultSet.next()) {
    final String columnName = resultSet.getString(4);
    final int dataType = resultSet.getInt(5);
    final String typeString = resultSet.getString(6);
    final int precision;
    final int scale;
    switch (SqlType.valueOf(dataType)) {
    case TIMESTAMP:
    case TIME:
      precision = resultSet.getInt(9); // SCALE
      scale = 0;
      break;
    default:
      precision = resultSet.getInt(7); // SIZE
      scale = resultSet.getInt(9); // SCALE
      break;
    }
    RelDataType sqlType =
        sqlType(typeFactory, dataType, precision, scale, typeString);
    boolean nullable = resultSet.getInt(11) != DatabaseMetaData.columnNoNulls;
    fieldInfo.add(columnName, sqlType).nullable(nullable);
  }
  resultSet.close();
  return RelDataTypeImpl.proto(fieldInfo.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:36,代码来源:JdbcSchema.java

示例9: testEnsureTypeWithDifference

/**
 * Test RexBuilder.ensureType()
 */
@Test
public void testEnsureTypeWithDifference() {
  final RelDataTypeFactory typeFactory = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  RexBuilder builder = new RexBuilder(typeFactory);

  RexNode node =  new RexLiteral(
          Boolean.TRUE, typeFactory.createSqlType(SqlTypeName.BOOLEAN), SqlTypeName.BOOLEAN);
  RexNode ensuredNode = builder.ensureType(
          typeFactory.createSqlType(SqlTypeName.INTEGER), node, true);

  assertNotEquals(node, ensuredNode);
  assertEquals(ensuredNode.getType(), typeFactory.createSqlType(SqlTypeName.INTEGER));
}
 
开发者ID:apache,项目名称:calcite,代码行数:16,代码来源:RexBuilderTest.java

示例10: testLoadSorted

@Test public void testLoadSorted() {
  final JavaTypeFactoryImpl typeFactory =
      new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataType rowType =
      typeFactory.builder()
          .add("empid", typeFactory.createType(int.class))
          .add("deptno", typeFactory.createType(int.class))
          .add("name", typeFactory.createType(String.class))
          .build();
  final Enumerable<Object[]> enumerable =
      Linq4j.asEnumerable(
          Arrays.asList(
              new Object[]{100, 10, "Bill"},
              new Object[]{200, 20, "Eric"},
              new Object[]{150, 10, "Sebastian"},
              new Object[]{160, 10, "Theodore"}));
  final ColumnLoader<Object[]> loader =
      new ColumnLoader<Object[]>(typeFactory, enumerable,
          RelDataTypeImpl.proto(rowType), null);
  checkColumn(
      loader.representationValues.get(0),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=0, bitCount=8, primitive=INT, signed=false), value=[100, 150, 160, 200, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(1),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=1, bitCount=5, primitive=INT, signed=false), value=[10, 10, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(2),
      ArrayTable.RepresentationType.OBJECT_ARRAY,
      "Column(representation=ObjectArray(ordinal=2), value=[Bill, Sebastian, Theodore, Eric])");
}
 
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:ArrayTableTest.java

示例11: testLoadSorted2

/** As {@link #testLoadSorted()} but column #1 is the unique column, not
 * column #0. The algorithm needs to go back and permute the values of
 * column #0 after it discovers that column #1 is unique and sorts by it. */
@Test public void testLoadSorted2() {
  final JavaTypeFactoryImpl typeFactory =
      new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataType rowType =
      typeFactory.builder()
          .add("deptno", typeFactory.createType(int.class))
          .add("empid", typeFactory.createType(int.class))
          .add("name", typeFactory.createType(String.class))
          .build();
  final Enumerable<Object[]> enumerable =
      Linq4j.asEnumerable(
          Arrays.asList(
              new Object[]{10, 100, "Bill"},
              new Object[]{20, 200, "Eric"},
              new Object[]{30, 150, "Sebastian"},
              new Object[]{10, 160, "Theodore"}));
  final ColumnLoader<Object[]> loader =
      new ColumnLoader<Object[]>(typeFactory, enumerable,
          RelDataTypeImpl.proto(rowType), null);
  // Note that values have been sorted with {20, 200, Eric} last because the
  // value 200 is the highest value of empid, the unique column.
  checkColumn(
      loader.representationValues.get(0),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=0, bitCount=5, primitive=INT, signed=false), value=[10, 30, 10, 20, 0, 0, 0, 0, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(1),
      ArrayTable.RepresentationType.BIT_SLICED_PRIMITIVE_ARRAY,
      "Column(representation=BitSlicedPrimitiveArray(ordinal=1, bitCount=8, primitive=INT, signed=false), value=[100, 150, 160, 200, 0, 0, 0, 0])");
  checkColumn(
      loader.representationValues.get(2),
      ArrayTable.RepresentationType.OBJECT_ARRAY,
      "Column(representation=ObjectArray(ordinal=2), value=[Bill, Sebastian, Theodore, Eric])");
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:ArrayTableTest.java

示例12: getValidator

@Override public SqlValidator getValidator(SqlTestFactory factory) {
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final SqlConformance conformance = (SqlConformance) get("conformance");
  final boolean caseSensitive = (Boolean) factory.get("caseSensitive");
  return new SqlAdvisorValidator(
      SqlStdOperatorTable.instance(),
      new MockCatalogReader(typeFactory, caseSensitive).init(),
      typeFactory,
      conformance);
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlAdvisorTest.java

示例13: getValidator

@Override public SqlValidator getValidator(SqlTestFactory factory) {
  final RelDataTypeFactory typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  SqlConformance conformance = (SqlConformance) get("conformance");
  final boolean caseSensitive = (Boolean) get("caseSensitive");
  return new FeatureValidator(
      factory.createOperatorTable(factory),
      new MockCatalogReader(typeFactory, caseSensitive).init(),
      typeFactory,
      conformance);
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:SqlValidatorFeatureTest.java

示例14: setUp

@Before
public void setUp() {
  JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  integerDataType = typeFactory.createSqlType(SqlTypeName.INTEGER);
  integerType = SqlTypeUtil.convertTypeToSpec(integerDataType);
  rexBuilder = new RexBuilder(typeFactory);
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:SqlOperatorBindingTest.java

示例15: testArrayAssignment

/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-1804">[CALCITE-1804]
 * Cannot assign NOT NULL array to nullable array</a>. */
@Test public void testArrayAssignment() {
  final SqlTypeFactoryImpl typeFactory =
      new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
  final RelDataType bigint = typeFactory.createSqlType(SqlTypeName.BIGINT);
  final RelDataType bigintNullable =
      typeFactory.createTypeWithNullability(bigint, true);
  final RelDataType bigintNotNull =
      typeFactory.createTypeWithNullability(bigint, false);
  final RelDataType date = typeFactory.createSqlType(SqlTypeName.DATE);
  final RelDataType dateNotNull =
      typeFactory.createTypeWithNullability(date, false);
  assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, bigintNotNull),
      is(true));
  assertThat(SqlTypeUtil.canAssignFrom(bigintNullable, dateNotNull),
      is(false));
  final RelDataType bigintNullableArray =
      typeFactory.createArrayType(bigintNullable, -1);
  final RelDataType bigintArrayNullable =
      typeFactory.createTypeWithNullability(bigintNullableArray, true);
  final RelDataType bigintNotNullArray =
      new ArraySqlType(bigintNotNull, false);
  assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, bigintNotNullArray),
      is(true));
  final RelDataType dateNotNullArray =
      new ArraySqlType(dateNotNull, false);
  assertThat(SqlTypeUtil.canAssignFrom(bigintArrayNullable, dateNotNullArray),
      is(false));
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:SqlValidatorTest.java


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