Package org.apache.calcite.adapter.jdbc
Class JdbcTable
- java.lang.Object
-
- org.apache.calcite.schema.impl.AbstractTable
-
- org.apache.calcite.adapter.java.AbstractQueryableTable
-
- org.apache.calcite.adapter.jdbc.JdbcTable
-
- All Implemented Interfaces:
ModifiableTable
,QueryableTable
,ScannableTable
,Table
,TranslatableTable
,Wrapper
public class JdbcTable extends AbstractQueryableTable implements TranslatableTable, ScannableTable, ModifiableTable
Queryable that gets its data from a table within a JDBC connection.The idea is not to read the whole table, however. The idea is to use this as a building block for a query, by applying Queryable operators such as
ExtendedEnumerable.where(org.apache.calcite.linq4j.function.Predicate2)
. The resulting queryable can then be converted to a SQL query, which can be executed efficiently on the JDBC server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
JdbcTable.JdbcTableQueryable<T>
Enumerable that returns the contents of aJdbcTable
by connecting to the JDBC data source.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
jdbcCatalogName
private JdbcSchema
jdbcSchema
private java.lang.String
jdbcSchemaName
private java.lang.String
jdbcTableName
private Schema.TableType
jdbcTableType
private RelProtoDataType
protoRowType
-
Fields inherited from class org.apache.calcite.adapter.java.AbstractQueryableTable
elementType
-
-
Constructor Summary
Constructors Constructor Description JdbcTable(JdbcSchema jdbcSchema, java.lang.String jdbcCatalogName, java.lang.String jdbcSchemaName, java.lang.String tableName, Schema.TableType jdbcTableType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Queryable<T>
asQueryable(QueryProvider queryProvider, SchemaPlus schema, java.lang.String tableName)
Converts this table into aQueryable
.private java.util.List<Pair<org.apache.calcite.avatica.ColumnMetaData.Rep,java.lang.Integer>>
fieldClasses(JavaTypeFactory typeFactory)
(package private) SqlString
generateSql()
Schema.TableType
getJdbcTableType()
Type of table.java.util.Collection
getModifiableCollection()
Returns the modifiable collection.RelDataType
getRowType(RelDataTypeFactory typeFactory)
Returns this table's row type.Enumerable<java.lang.Object[]>
scan(DataContext root)
Returns an enumerator over the rows in this Table.(package private) SqlIdentifier
tableName()
TableModify
toModificationRel(RelOptCluster cluster, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, java.util.List<java.lang.String> updateColumnList, java.util.List<RexNode> sourceExpressionList, boolean flattened)
Creates a relational expression that modifies this table.RelNode
toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable)
Converts this table into arelational expression
.java.lang.String
toString()
-
Methods inherited from class org.apache.calcite.adapter.java.AbstractQueryableTable
getElementType, getExpression
-
Methods inherited from class org.apache.calcite.schema.impl.AbstractTable
getStatistic, isRolledUp, rolledUpColumnValidInsideAgg, unwrap
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.calcite.schema.QueryableTable
getElementType, getExpression
-
Methods inherited from interface org.apache.calcite.schema.Table
getStatistic, isRolledUp, rolledUpColumnValidInsideAgg
-
-
-
-
Field Detail
-
protoRowType
private RelProtoDataType protoRowType
-
jdbcSchema
private final JdbcSchema jdbcSchema
-
jdbcCatalogName
private final java.lang.String jdbcCatalogName
-
jdbcSchemaName
private final java.lang.String jdbcSchemaName
-
jdbcTableName
private final java.lang.String jdbcTableName
-
jdbcTableType
private final Schema.TableType jdbcTableType
-
-
Constructor Detail
-
JdbcTable
JdbcTable(JdbcSchema jdbcSchema, java.lang.String jdbcCatalogName, java.lang.String jdbcSchemaName, java.lang.String tableName, Schema.TableType jdbcTableType)
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getJdbcTableType
public Schema.TableType getJdbcTableType()
Description copied from interface:Table
Type of table.- Specified by:
getJdbcTableType
in interfaceTable
- Overrides:
getJdbcTableType
in classAbstractTable
-
getRowType
public RelDataType getRowType(RelDataTypeFactory typeFactory)
Description copied from interface:Table
Returns this table's row type.This is a struct type whose fields describe the names and types of the columns in this table.
The implementer must use the type factory provided. This ensures that the type is converted into a canonical form; other equal types in the same query will use the same object.
- Specified by:
getRowType
in interfaceTable
- Parameters:
typeFactory
- Type factory with which to create the type- Returns:
- Row type
-
fieldClasses
private java.util.List<Pair<org.apache.calcite.avatica.ColumnMetaData.Rep,java.lang.Integer>> fieldClasses(JavaTypeFactory typeFactory)
-
generateSql
SqlString generateSql()
-
tableName
SqlIdentifier tableName()
-
toRel
public RelNode toRel(RelOptTable.ToRelContext context, RelOptTable relOptTable)
Description copied from interface:TranslatableTable
Converts this table into arelational expression
.- Specified by:
toRel
in interfaceTranslatableTable
-
asQueryable
public <T> Queryable<T> asQueryable(QueryProvider queryProvider, SchemaPlus schema, java.lang.String tableName)
Description copied from interface:QueryableTable
Converts this table into aQueryable
.- Specified by:
asQueryable
in interfaceQueryableTable
-
scan
public Enumerable<java.lang.Object[]> scan(DataContext root)
Description copied from interface:ScannableTable
Returns an enumerator over the rows in this Table. Each row is represented as an array of its column values.- Specified by:
scan
in interfaceScannableTable
-
getModifiableCollection
public java.util.Collection getModifiableCollection()
Description copied from interface:ModifiableTable
Returns the modifiable collection. Modifying the collection will change the table's contents.- Specified by:
getModifiableCollection
in interfaceModifiableTable
-
toModificationRel
public TableModify toModificationRel(RelOptCluster cluster, RelOptTable table, Prepare.CatalogReader catalogReader, RelNode input, TableModify.Operation operation, java.util.List<java.lang.String> updateColumnList, java.util.List<RexNode> sourceExpressionList, boolean flattened)
Description copied from interface:ModifiableTable
Creates a relational expression that modifies this table.- Specified by:
toModificationRel
in interfaceModifiableTable
-
-