Package org.apache.calcite.test.catalog
Class MockCatalogReader.MockTable
java.lang.Object
org.apache.calcite.prepare.Prepare.AbstractPreparingTable
org.apache.calcite.test.catalog.MockCatalogReader.MockTable
- All Implemented Interfaces:
RelOptTable
,Prepare.PreparingTable
,BuiltInMetadata.MaxRowCount.Handler
,MetadataHandler<BuiltInMetadata.MaxRowCount>
,Wrapper
,SqlValidatorTable
- Direct Known Subclasses:
MockCatalogReader.MockModifiableViewRelOptTable
,MockCatalogReader.MockRelViewTable
,MockCatalogReader.MockViewTable
,MockCatalogReader.MustFilterMockTable
- Enclosing class:
MockCatalogReader
public static class MockCatalogReader.MockTable
extends Prepare.AbstractPreparingTable
implements BuiltInMetadata.MaxRowCount.Handler
Mock implementation of
Prepare.PreparingTable
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.plan.RelOptTable
RelOptTable.ToRelContext, RelOptTable.ViewExpander
-
Field Summary
Modifier and TypeFieldDescriptionprotected final MockCatalogReader
protected List<RelCollation>
protected final List<Map.Entry<String,
RelDataType>> protected final InitializerExpressionFactory
protected StructKind
protected final Double
protected final List<RelReferentialConstraint>
protected final @Nullable MockCatalogReader.ColumnResolver
protected final double
protected RelDataType
protected final boolean
Wrapped objects that can be obtained by callingunwrap(Class)
. -
Constructor Summary
ModifierConstructorDescriptionprotected
MockTable
(MockCatalogReader catalogReader, boolean stream, boolean temporal, double rowCount, List<Map.Entry<String, RelDataType>> columnList, List<Integer> keyList, RelDataType rowType, List<RelCollation> collationList, List<String> names, Set<String> monotonicColumnSet, StructKind kind, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory) Copy constructor.MockTable
(MockCatalogReader catalogReader, String catalogName, String schemaName, String name, boolean stream, boolean temporal, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory) MockTable
(MockCatalogReader catalogReader, String catalogName, String schemaName, String name, boolean stream, boolean temporal, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory, Double maxRowCount) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addColumn
(String name, RelDataType type) void
addColumn
(String name, RelDataType type, boolean isKey) void
addMonotonic
(String name) void
static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, List<String> names, boolean stream, double rowCount) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, double maxRowCount) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, double maxRowCount) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerExpressionFactory, boolean temporal) static MockCatalogReader.MockTable
create
(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerExpressionFactory, boolean temporal, Double maxRowCount) protected RelOptTable
Implementation-specific code to instantiate a newRelOptTable
based on aTable
that has been extended.Returns the access type of the table.Returns a description of the physical ordering (or orderings) of the rows returned from this table.getDef()
Returns a description of the physical distribution of the rows in this table.getExpression
(Class clazz) Generates code for this table.getKeys()
Returns a list of unique keys, empty list if no key exist, the result should be consistent withisKey
.getKind()
@Nullable Double
getMonotonicity
(String columnName) Returns whether a given column is monotonic.Obtains an identifier for this table.Returns the referential constraints existing for this table.Returns theRelOptSchema
this table belongs to.double
Returns an estimate of the number of rows in the table.Describes the type of rows returned by this table.boolean
isKey
(ImmutableBitSet columns) Returns whether the given columns are a key or a superset of a unique key of this table.boolean
Returns whether the table is temporal.void
onRegister
(RelDataTypeFactory typeFactory) void
registerRolledUpColumn
(String columnName) void
setKind
(StructKind kind) boolean
supportsModality
(SqlModality modality) toRel
(RelOptTable.ToRelContext context) Converts this table into arelational expression
.<T> T
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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.calcite.sql.validate.SqlValidatorTable
table
Methods inherited from interface org.apache.calcite.schema.Wrapper
maybeUnwrap, unwrapOrThrow
-
Field Details
-
catalogReader
-
stream
protected final boolean stream -
rowCount
protected final double rowCount -
columnList
-
keyList
-
referentialConstraints
-
rowType
-
collationList
-
names
-
maxRowCount
-
monotonicColumnSet
-
kind
-
resolver
-
initializerFactory
-
rolledUpColumns
-
wraps
Wrapped objects that can be obtained by callingunwrap(Class)
. Initially an immutable list, but converted to a mutable array list on first assignment.
-
-
Constructor Details
-
MockTable
public MockTable(MockCatalogReader catalogReader, String catalogName, String schemaName, String name, boolean stream, boolean temporal, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory) -
MockTable
public MockTable(MockCatalogReader catalogReader, String catalogName, String schemaName, String name, boolean stream, boolean temporal, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory, Double maxRowCount) -
MockTable
protected MockTable(MockCatalogReader catalogReader, boolean stream, boolean temporal, double rowCount, List<Map.Entry<String, RelDataType>> columnList, List<Integer> keyList, RelDataType rowType, List<RelCollation> collationList, List<String> names, Set<String> monotonicColumnSet, StructKind kind, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerFactory) Copy constructor.
-
-
Method Details
-
registerRolledUpColumn
-
addWrap
-
getMaxRowCount
- Specified by:
getMaxRowCount
in interfaceBuiltInMetadata.MaxRowCount.Handler
-
getDef
- Specified by:
getDef
in interfaceBuiltInMetadata.MaxRowCount.Handler
- Specified by:
getDef
in interfaceMetadataHandler<BuiltInMetadata.MaxRowCount>
-
extend
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
-
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, double maxRowCount) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, List<String> names, boolean stream, double rowCount) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, double maxRowCount) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerExpressionFactory, boolean temporal, Double maxRowCount) -
create
public static MockCatalogReader.MockTable create(MockCatalogReader catalogReader, MockCatalogReader.MockSchema schema, String name, boolean stream, double rowCount, @Nullable MockCatalogReader.ColumnResolver resolver, InitializerExpressionFactory initializerExpressionFactory, boolean temporal) -
unwrap
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. -
getRowCount
public double getRowCount()Description copied from interface:RelOptTable
Returns an estimate of the number of rows in the table.- Specified by:
getRowCount
in interfaceRelOptTable
-
getRelOptSchema
Description copied from interface:RelOptTable
Returns theRelOptSchema
this table belongs to.- Specified by:
getRelOptSchema
in interfaceRelOptTable
-
toRel
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.- Specified by:
toRel
in interfaceRelOptTable
-
getCollationList
Description copied from interface:RelOptTable
Returns a description of the physical ordering (or orderings) of the rows returned from this table.- Specified by:
getCollationList
in interfaceRelOptTable
- See Also:
-
getDistribution
Description copied from interface:RelOptTable
Returns a description of the physical distribution of the rows in this table.- Specified by:
getDistribution
in interfaceRelOptTable
- See Also:
-
isKey
Description copied from interface:RelOptTable
Returns whether the given columns are a key or a superset of a unique key of this table.- Specified by:
isKey
in interfaceRelOptTable
- Parameters:
columns
- Ordinals of key columns- Returns:
- Whether the given columns are a key or a superset of a key
-
getKeys
Description copied from interface:RelOptTable
Returns a list of unique keys, empty list if no key exist, the result should be consistent withisKey
.- Specified by:
getKeys
in interfaceRelOptTable
-
getReferentialConstraints
Description copied from interface:RelOptTable
Returns the referential constraints existing for this table. These constraints are represented over other tables usingRelReferentialConstraint
nodes.- Specified by:
getReferentialConstraints
in interfaceRelOptTable
-
getRowType
Description copied from interface:RelOptTable
Describes the type of rows returned by this table.- Specified by:
getRowType
in interfaceRelOptTable
- Specified by:
getRowType
in interfaceSqlValidatorTable
-
supportsModality
- Specified by:
supportsModality
in interfaceSqlValidatorTable
-
isTemporal
public boolean isTemporal()Description copied from interface:SqlValidatorTable
Returns whether the table is temporal.- Specified by:
isTemporal
in interfaceSqlValidatorTable
-
onRegister
-
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.- Specified by:
getQualifiedName
in interfaceRelOptTable
- Specified by:
getQualifiedName
in interfaceSqlValidatorTable
- Returns:
- qualified name
-
getMonotonicity
Description copied from interface:SqlValidatorTable
Returns whether a given column is monotonic.- Specified by:
getMonotonicity
in interfaceSqlValidatorTable
-
getAllowedAccess
Description copied from interface:SqlValidatorTable
Returns the access type of the table.- Specified by:
getAllowedAccess
in interfaceSqlValidatorTable
-
getExpression
Description copied from interface:RelOptTable
Generates code for this table.- Specified by:
getExpression
in interfaceRelOptTable
- Parameters:
clazz
- The desired collection class; for exampleQueryable
.- Returns:
- the code for the table, or null if code generation is not supported
-
addColumn
-
addColumn
-
addMonotonic
-
setKind
-
getKind
-