Package org.apache.calcite.prepare
Class RelOptTableImpl
- java.lang.Object
-
- org.apache.calcite.prepare.Prepare.AbstractPreparingTable
-
- org.apache.calcite.prepare.RelOptTableImpl
-
- All Implemented Interfaces:
RelOptTable
,Prepare.PreparingTable
,Wrapper
,SqlValidatorTable
public class RelOptTableImpl extends Prepare.AbstractPreparingTable
Implementation ofRelOptTable
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
RelOptTableImpl.MySchemaPlus
Implementation ofSchemaPlus
that wraps a regular schema and knows its name and parent.-
Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptTable
RelOptTable.ToRelContext, RelOptTable.ViewExpander
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Function<java.lang.Class,Expression>
expressionFunction
private com.google.common.collect.ImmutableList<java.lang.String>
names
private java.lang.Double
rowCount
Estimate for the row count, or null.private RelDataType
rowType
private RelOptSchema
schema
private Table
table
-
Constructor Summary
Constructors Modifier Constructor Description private
RelOptTableImpl(RelOptSchema schema, RelDataType rowType, java.util.List<java.lang.String> names, Table table, java.util.function.Function<java.lang.Class,Expression> expressionFunction, java.lang.Double rowCount)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.List<ColumnStrategy>
columnStrategies(RelOptTable table)
RelOptTableImpl
copy(RelDataType newRowType)
Creates a copy of this RelOptTable.static RelOptTableImpl
create(RelOptSchema schema, RelDataType rowType, java.util.List<java.lang.String> names, Expression expression)
static RelOptTableImpl
create(RelOptSchema schema, RelDataType rowType, CalciteSchema.TableEntry tableEntry, java.lang.Double rowCount)
static RelOptTableImpl
create(RelOptSchema schema, RelDataType rowType, Table table, com.google.common.collect.ImmutableList<java.lang.String> names)
static RelOptTableImpl
create(RelOptSchema schema, RelDataType rowType, Table table, Path path)
boolean
equals(java.lang.Object obj)
protected RelOptTable
extend(Table extendedTable)
Implementation-specific code to instantiate a newRelOptTable
based on aTable
that has been extended.SqlAccessType
getAllowedAccess()
Returns the access type of the tableprivate static java.util.function.Function<java.lang.Class,Expression>
getClassExpressionFunction(CalciteSchema.TableEntry tableEntry, Table table)
private static java.util.function.Function<java.lang.Class,Expression>
getClassExpressionFunction(SchemaPlus schema, java.lang.String tableName, Table table)
java.util.List<RelCollation>
getCollationList()
Returns a description of the physical ordering (or orderings) of the rows returned from this table.RelDistribution
getDistribution()
Returns a description of the physical distribution of the rows in this table.Expression
getExpression(java.lang.Class clazz)
Generates code for this table.SqlMonotonicity
getMonotonicity(java.lang.String columnName)
Returns whether a given column is monotonic.java.util.List<java.lang.String>
getQualifiedName()
Obtains an identifier for this table.java.util.List<RelReferentialConstraint>
getReferentialConstraints()
Returns the referential constraints existing for this table.RelOptSchema
getRelOptSchema()
Returns theRelOptSchema
this table belongs to.double
getRowCount()
Returns an estimate of the number of rows in the table.RelDataType
getRowType()
Describes the type of rows returned by this table.int
hashCode()
boolean
isKey(ImmutableBitSet columns)
Returns whether the given columns are a key or a superset of a unique key of this table.static int
realOrdinal(RelOptTable table, int i)
Converts the ordinal of a field into the ordinal of a stored field.static RelDataType
realRowType(RelOptTable table)
Returns the row type of a table after anyColumnStrategy.VIRTUAL
columns have been removed.boolean
supportsModality(SqlModality modality)
RelNode
toRel(RelOptTable.ToRelContext context)
Converts this table into arelational expression
.<T> T
unwrap(java.lang.Class<T> clazz)
Finds an instance of an interface implemented by this object, or returns null if this object does not support that interface.-
Methods inherited from class org.apache.calcite.prepare.Prepare.AbstractPreparingTable
columnHasDefaultValue, extend, getColumnStrategies
-
-
-
-
Field Detail
-
schema
private final RelOptSchema schema
-
rowType
private final RelDataType rowType
-
table
private final Table table
-
expressionFunction
private final java.util.function.Function<java.lang.Class,Expression> expressionFunction
-
names
private final com.google.common.collect.ImmutableList<java.lang.String> names
-
rowCount
private final java.lang.Double rowCount
Estimate for the row count, or null.If not null, overrides the estimate from the actual table.
Useful when a table that contains a materialized query result is being used to replace a query expression that wildly underestimates the row count. Now the materialized table can tell the same lie.
-
-
Constructor Detail
-
RelOptTableImpl
private RelOptTableImpl(RelOptSchema schema, RelDataType rowType, java.util.List<java.lang.String> names, Table table, java.util.function.Function<java.lang.Class,Expression> expressionFunction, java.lang.Double rowCount)
-
-
Method Detail
-
create
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType, java.util.List<java.lang.String> names, Expression expression)
-
create
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType, Table table, Path path)
-
create
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType, CalciteSchema.TableEntry tableEntry, java.lang.Double rowCount)
-
copy
public RelOptTableImpl copy(RelDataType newRowType)
Creates a copy of this RelOptTable. The new RelOptTable will have newRowType.
-
getClassExpressionFunction
private static java.util.function.Function<java.lang.Class,Expression> getClassExpressionFunction(CalciteSchema.TableEntry tableEntry, Table table)
-
getClassExpressionFunction
private static java.util.function.Function<java.lang.Class,Expression> getClassExpressionFunction(SchemaPlus schema, java.lang.String tableName, Table table)
-
create
public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType, Table table, com.google.common.collect.ImmutableList<java.lang.String> names)
-
unwrap
public <T> T unwrap(java.lang.Class<T> clazz)
Description copied from interface:Wrapper
Finds an instance of an interface implemented by this object, or returns null if this object does not support that interface.
-
getExpression
public Expression getExpression(java.lang.Class clazz)
Description copied from interface:RelOptTable
Generates code for this table.- Parameters:
clazz
- The desired collection class; for exampleQueryable
.
-
extend
protected RelOptTable extend(Table extendedTable)
Description copied from class:Prepare.AbstractPreparingTable
Implementation-specific code to instantiate a newRelOptTable
based on aTable
that has been extended.- Specified by:
extend
in classPrepare.AbstractPreparingTable
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getRowCount
public double getRowCount()
Description copied from interface:RelOptTable
Returns an estimate of the number of rows in the table.
-
getRelOptSchema
public RelOptSchema getRelOptSchema()
Description copied from interface:RelOptTable
Returns theRelOptSchema
this table belongs to.
-
toRel
public RelNode toRel(RelOptTable.ToRelContext context)
Description copied from interface:RelOptTable
Converts this table into arelational expression
.The
planner
calls this method to convert a table into an initial relational expression, generally something abstract, such as aLogicalTableScan
, then optimizes this expression by applyingrules
to transform it into more efficient access methods for this table.
-
getCollationList
public java.util.List<RelCollation> getCollationList()
Description copied from interface:RelOptTable
Returns a description of the physical ordering (or orderings) of the rows returned from this table.- See Also:
RelMetadataQuery.collations(RelNode)
-
getDistribution
public RelDistribution getDistribution()
Description copied from interface:RelOptTable
Returns a description of the physical distribution of the rows in this table.- See Also:
RelMetadataQuery.distribution(RelNode)
-
isKey
public boolean isKey(ImmutableBitSet columns)
Description copied from interface:RelOptTable
Returns whether the given columns are a key or a superset of a unique key of this table.- Parameters:
columns
- Ordinals of key columns- Returns:
- Whether the given columns are a key or a superset of a key
-
getReferentialConstraints
public java.util.List<RelReferentialConstraint> getReferentialConstraints()
Description copied from interface:RelOptTable
Returns the referential constraints existing for this table. These constraints are represented over other tables usingRelReferentialConstraint
nodes.
-
getRowType
public RelDataType getRowType()
Description copied from interface:RelOptTable
Describes the type of rows returned by this table.
-
supportsModality
public boolean supportsModality(SqlModality modality)
-
getQualifiedName
public java.util.List<java.lang.String> getQualifiedName()
Description copied from interface:RelOptTable
Obtains an identifier for this table. The identifier must be unique with respect to the Connection producing this table.- Returns:
- qualified name
-
getMonotonicity
public SqlMonotonicity getMonotonicity(java.lang.String columnName)
Description copied from interface:SqlValidatorTable
Returns whether a given column is monotonic.
-
getAllowedAccess
public SqlAccessType getAllowedAccess()
Description copied from interface:SqlValidatorTable
Returns the access type of the table
-
columnStrategies
public static java.util.List<ColumnStrategy> columnStrategies(RelOptTable table)
-
realOrdinal
public static int realOrdinal(RelOptTable table, int i)
Converts the ordinal of a field into the ordinal of a stored field. That is, it subtracts the number of virtual fields that come before it.
-
realRowType
public static RelDataType realRowType(RelOptTable table)
Returns the row type of a table after anyColumnStrategy.VIRTUAL
columns have been removed. This is the type of the records that are actually stored.
-
-