本文整理汇总了Java中org.apache.calcite.rel.type.RelDataTypeSystem类的典型用法代码示例。如果您正苦于以下问题:Java RelDataTypeSystem类的具体用法?Java RelDataTypeSystem怎么用?Java RelDataTypeSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RelDataTypeSystem类属于org.apache.calcite.rel.type包,在下文中一共展示了RelDataTypeSystem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getColumnList
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
public List<String> getColumnList(final String username, DatasetPath path) {
final SchemaConfig schemaConfig = SchemaConfig.newBuilder(username)
.setProvider(new SchemaInfoProvider() {
private final ViewExpansionContext viewExpansionContext = new ViewExpansionContext(this, schemaProvider, username);
@Override
public ViewExpansionContext getViewExpansionContext() {
return viewExpansionContext;
}
@Override
public OptionValue getOption(String optionKey) {
throw new UnsupportedOperationException();
}
})
.build();
final SchemaPlus schema = schemaProvider.getRootSchema(schemaConfig);
final Table table = path.getTable(schema);
return table.getRowType(new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT)).getFieldNames();
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:QueryExecutor.java
示例2: CalciteConnectionImpl
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/**
* Creates a CalciteConnectionImpl.
* <p/>
* <p>Not public; method is called only from the driver.</p>
*
* @param driver Driver
* @param factory Factory for JDBC objects
* @param url Server URL
* @param info Other connection properties
* @param rootSchema Root schema, or null
* @param typeFactory Type factory, or null
*/
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
String url, Properties info, CalciteSchema rootSchema,
JavaTypeFactory typeFactory) {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
this.prepareFactory = driver.getPrepareFactory();
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.rootSchema =
Preconditions.checkNotNull(rootSchema != null
? rootSchema
: CalciteSchema.createRootSchema(true));
Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:36,代码来源:CalciteConnectionImpl.java
示例3: OctopusTable
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
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,代码行数:27,代码来源:OctopusTable.java
示例4: QuarkConnectionImpl
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
protected QuarkConnectionImpl(QuarkDriver driver, AvaticaFactory factory, String url,
Properties info, CalciteRootSchema rootSchema,
JavaTypeFactory typeFactory) throws SQLException {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
开发者ID:qubole,项目名称:quark,代码行数:21,代码来源:QuarkConnectionImpl.java
示例5: getAllDefaultType
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
private ImmutableList<MetaTypeInfo> getAllDefaultType() {
final ImmutableList.Builder<MetaTypeInfo> allTypeList =
new ImmutableList.Builder<>();
final RelDataTypeSystem typeSystem = getConnection().getTypeFactory().getTypeSystem();
for (SqlTypeName sqlTypeName : SqlTypeName.values()) {
allTypeList.add(
new MetaTypeInfo(sqlTypeName.getName(),
sqlTypeName.getJdbcOrdinal(),
typeSystem.getMaxPrecision(sqlTypeName),
typeSystem.getLiteral(sqlTypeName, true),
typeSystem.getLiteral(sqlTypeName, false),
// All types are nullable
(short) DatabaseMetaData.typeNullable,
typeSystem.isCaseSensitive(sqlTypeName),
// Making all type searchable; we may want to
// be specific and declare under SqlTypeName
(short) DatabaseMetaData.typeSearchable,
false,
false,
typeSystem.isAutoincrement(sqlTypeName),
(short) sqlTypeName.getMinScale(),
(short) typeSystem.getMaxScale(sqlTypeName),
typeSystem.getNumTypeRadix(sqlTypeName)));
}
return allTypeList.build();
}
开发者ID:qubole,项目名称:quark,代码行数:27,代码来源:QuarkMetaImpl.java
示例6: buildPlanner
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
private Planner buildPlanner(QueryContext context) {
final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
traitDefs.add(ConventionTraitDef.INSTANCE);
traitDefs.add(RelCollationTraitDef.INSTANCE);
final ChainedSqlOperatorTable opTab =
new ChainedSqlOperatorTable(
ImmutableList.of(SqlStdOperatorTable.instance(),
HiveSqlOperatorTable.instance(), catalogReader));
FrameworkConfig config = Frameworks.newConfigBuilder() //
.parserConfig(SqlParser.configBuilder()
.setQuotedCasing(Casing.UNCHANGED)
.setUnquotedCasing(Casing.TO_UPPER)
.setQuoting(Quoting.DOUBLE_QUOTE)
.build()) //
.defaultSchema(context.getDefaultSchema()) //
.operatorTable(opTab) //
.traitDefs(traitDefs) //
.convertletTable(StandardConvertletTable.INSTANCE)//
.programs(getPrograms()) //
.typeSystem(RelDataTypeSystem.DEFAULT) //
.build();
return Frameworks.getPlanner(config);
}
开发者ID:qubole,项目名称:quark,代码行数:24,代码来源:SqlWorker.java
示例7: CalciteConnectionImpl
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/**
* Creates a CalciteConnectionImpl.
*
* <p>Not public; method is called only from the driver.</p>
*
* @param driver Driver
* @param factory Factory for JDBC objects
* @param url Server URL
* @param info Other connection properties
* @param rootSchema Root schema, or null
* @param typeFactory Type factory, or null
*/
protected CalciteConnectionImpl(Driver driver, AvaticaFactory factory,
String url, Properties info, CalciteSchema rootSchema,
JavaTypeFactory typeFactory) {
super(driver, factory, url, info);
CalciteConnectionConfig cfg = new CalciteConnectionConfigImpl(info);
this.prepareFactory = driver.prepareFactory;
if (typeFactory != null) {
this.typeFactory = typeFactory;
} else {
final RelDataTypeSystem typeSystem =
cfg.typeSystem(RelDataTypeSystem.class, RelDataTypeSystem.DEFAULT);
this.typeFactory = new JavaTypeFactoryImpl(typeSystem);
}
this.rootSchema =
Preconditions.checkNotNull(rootSchema != null
? rootSchema
: CalciteSchema.createRootSchema(true));
Preconditions.checkArgument(this.rootSchema.isRoot(), "must be root schema");
this.properties.put(InternalProperty.CASE_SENSITIVE, cfg.caseSensitive());
this.properties.put(InternalProperty.UNQUOTED_CASING, cfg.unquotedCasing());
this.properties.put(InternalProperty.QUOTED_CASING, cfg.quotedCasing());
this.properties.put(InternalProperty.QUOTING, cfg.quoting());
}
开发者ID:apache,项目名称:calcite,代码行数:36,代码来源:CalciteConnectionImpl.java
示例8: operatorTable
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/** 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,代码行数:26,代码来源:CalciteCatalogReader.java
示例9: withPrepare
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/**
* Initializes a container then calls user-specified code with a planner
* and statement.
*
* @param action Callback containing user-specified code
* @return Return value from action
*/
public static <R> R withPrepare(PrepareAction<R> action) {
try {
final Properties info = new Properties();
if (action.config.getTypeSystem() != RelDataTypeSystem.DEFAULT) {
info.setProperty(CalciteConnectionProperty.TYPE_SYSTEM.camelName(),
action.config.getTypeSystem().getClass().getName());
}
Connection connection =
DriverManager.getConnection("jdbc:calcite:", info);
final CalciteServerStatement statement =
connection.createStatement()
.unwrap(CalciteServerStatement.class);
return new CalcitePrepareImpl().perform(statement, action);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:Frameworks.java
示例10: StdFrameworkConfig
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
StdFrameworkConfig(Context context,
SqlRexConvertletTable convertletTable,
SqlOperatorTable operatorTable,
ImmutableList<Program> programs,
ImmutableList<RelTraitDef> traitDefs,
SqlParser.Config parserConfig,
SqlToRelConverter.Config sqlToRelConverterConfig,
SchemaPlus defaultSchema,
RelOptCostFactory costFactory,
RelDataTypeSystem typeSystem,
RexExecutor executor) {
this.context = context;
this.convertletTable = convertletTable;
this.operatorTable = operatorTable;
this.programs = programs;
this.traitDefs = traitDefs;
this.parserConfig = parserConfig;
this.sqlToRelConverterConfig = sqlToRelConverterConfig;
this.defaultSchema = defaultSchema;
this.costFactory = costFactory;
this.typeSystem = typeSystem;
this.executor = executor;
}
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:Frameworks.java
示例11: setUp
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
@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,代码行数:18,代码来源:RexTransformerTest.java
示例12: testDateLiteral
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/** 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,代码行数:21,代码来源:RexBuilderTest.java
示例13: getRelDataType
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
@Override
RelProtoDataType getRelDataType(
DatabaseMetaData metaData,
String catalogName,
String schemaName,
String tableName
) throws SQLException {
if (journalledTableKeys.containsKey(tableName)) {
// 1: Find columns for journal table
RelDataType relDataType = super
.getRelDataType(metaData, catalogName, schemaName, journalNameFor(tableName))
.apply(new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT) {
@Override
public RelDataType copyType(RelDataType type) {
return type;
}
});
RelDataTypeFactory.FieldInfoBuilder fieldInfo = new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT).builder();
// 2: Filter out journal-implementation columns
for (RelDataTypeField field : relDataType.getFieldList()) {
String fieldName = field.getName();
if (fieldName.equals(versionField) || fieldName.equals(subsequentVersionField)) {
continue;
}
fieldInfo.add(field);
}
return RelDataTypeImpl.proto(fieldInfo.build());
} else {
return super.getRelDataType(metaData, catalogName, schemaName, tableName);
}
}
开发者ID:tzolov,项目名称:calcite-sql-rewriter,代码行数:35,代码来源:JournalledJdbcSchema.java
示例14: setup
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
@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,代码行数:10,代码来源:TestLayoutExpander.java
示例15: encodeAndDecode
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
@Test
public void encodeAndDecode() throws Exception {
final RelProtoDataType protoRowType = new RelProtoDataType() {
@Override
public RelDataType apply(RelDataTypeFactory a0) {
return a0.builder()
.add("col_tinyint", SqlTypeName.TINYINT)
.add("col_smallint", SqlTypeName.SMALLINT)
.add("col_integer", SqlTypeName.INTEGER)
.add("col_bigint", SqlTypeName.BIGINT)
.add("col_float", SqlTypeName.FLOAT)
.add("col_double", SqlTypeName.DOUBLE)
.add("col_decimal", SqlTypeName.DECIMAL)
.add("col_string_varchar", SqlTypeName.VARCHAR)
.add("col_time", SqlTypeName.TIME)
.add("col_timestamp", SqlTypeName.TIMESTAMP)
.add("col_boolean", SqlTypeName.BOOLEAN)
.build();
}
};
BeamRecordSqlType beamSQLRowType = CalciteUtils.toBeamRowType(
protoRowType.apply(new JavaTypeFactoryImpl(
RelDataTypeSystem.DEFAULT)));
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
BeamRecord row = new BeamRecord(beamSQLRowType
, Byte.valueOf("1"), Short.valueOf("1"), 1, 1L, 1.1F, 1.1
, BigDecimal.ZERO, "hello", calendar, new Date(), true);
BeamRecordCoder coder = beamSQLRowType.getRecordCoder();
CoderProperties.coderDecodeEncodeEqual(coder, row);
}
开发者ID:apache,项目名称:beam,代码行数:36,代码来源:BeamSqlRowCoderTest.java
示例16: getAllDefaultType
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
private ImmutableList<MetaTypeInfo> getAllDefaultType() {
final ImmutableList.Builder<MetaTypeInfo> allTypeList =
new ImmutableList.Builder<>();
final CalciteConnectionImpl conn = (CalciteConnectionImpl) connection;
final RelDataTypeSystem typeSystem = conn.getTypeFactory().getTypeSystem();
for (SqlTypeName sqlTypeName : SqlTypeName.values()) {
allTypeList.add(
new MetaTypeInfo(sqlTypeName.getName(),
sqlTypeName.getJdbcOrdinal(),
typeSystem.getMaxPrecision(sqlTypeName),
typeSystem.getLiteral(sqlTypeName, true),
typeSystem.getLiteral(sqlTypeName, false),
// All types are nullable
DatabaseMetaData.typeNullable,
typeSystem.isCaseSensitive(sqlTypeName),
// Making all type searchable; we may want to
// be specific and declare under SqlTypeName
DatabaseMetaData.typeSearchable,
false,
false,
typeSystem.isAutoincrement(sqlTypeName),
sqlTypeName.getMinScale(),
typeSystem.getMaxScale(sqlTypeName),
typeSystem.getNumTypeRadix(sqlTypeName)));
}
return allTypeList.build();
}
开发者ID:bitnine-oss,项目名称:octopus,代码行数:28,代码来源:CalciteMetaImpl.java
示例17: sqlOverDummyTable
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
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,代码行数:31,代码来源:TestCompilerUtils.java
示例18: CassandraEnumerator
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
/** Creates a CassandraEnumerator.
*
* @param results Cassandra result set ({@link com.datastax.driver.core.ResultSet})
* @param protoRowType The type of resulting rows
*/
CassandraEnumerator(ResultSet results, RelProtoDataType protoRowType) {
this.iterator = results.iterator();
this.current = null;
final RelDataTypeFactory typeFactory =
new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
this.fieldTypes = protoRowType.apply(typeFactory).getFieldList();
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:CassandraEnumerator.java
示例19: getAllDefaultType
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
private ImmutableList<MetaTypeInfo> getAllDefaultType() {
final ImmutableList.Builder<MetaTypeInfo> allTypeList =
ImmutableList.builder();
final CalciteConnectionImpl conn = (CalciteConnectionImpl) connection;
final RelDataTypeSystem typeSystem = conn.typeFactory.getTypeSystem();
for (SqlTypeName sqlTypeName : SqlTypeName.values()) {
allTypeList.add(
new MetaTypeInfo(sqlTypeName.getName(),
sqlTypeName.getJdbcOrdinal(),
typeSystem.getMaxPrecision(sqlTypeName),
typeSystem.getLiteral(sqlTypeName, true),
typeSystem.getLiteral(sqlTypeName, false),
// All types are nullable
(short) DatabaseMetaData.typeNullable,
typeSystem.isCaseSensitive(sqlTypeName),
// Making all type searchable; we may want to
// be specific and declare under SqlTypeName
(short) DatabaseMetaData.typeSearchable,
false,
false,
typeSystem.isAutoincrement(sqlTypeName),
(short) sqlTypeName.getMinScale(),
(short) typeSystem.getMaxScale(sqlTypeName),
typeSystem.getNumTypeRadix(sqlTypeName)));
}
return allTypeList.build();
}
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:CalciteMetaImpl.java
示例20: getRelDataType
import org.apache.calcite.rel.type.RelDataTypeSystem; //导入依赖的package包/类
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,代码行数:37,代码来源:JdbcSchema.java
注:本文中的org.apache.calcite.rel.type.RelDataTypeSystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论