Package org.apache.calcite.schema.impl
Class ModifiableViewTable
- java.lang.Object
-
- org.apache.calcite.schema.impl.AbstractTable
-
- org.apache.calcite.adapter.java.AbstractQueryableTable
-
- org.apache.calcite.schema.impl.ViewTable
-
- org.apache.calcite.schema.impl.ModifiableViewTable
-
- All Implemented Interfaces:
ModifiableView
,QueryableTable
,Table
,TranslatableTable
,Wrapper
public class ModifiableViewTable extends ViewTable implements ModifiableView, Wrapper
Extension toViewTable
that is modifiable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ModifiableViewTable.ModifiableViewTableInitializerExpressionFactory
Initializes columns based on the view constraint.
-
Field Summary
Fields Modifier and Type Field Description private ImmutableIntList
columnMapping
private RexNode
constraint
private InitializerExpressionFactory
initializerExpressionFactory
private Table
table
private Path
tablePath
-
Fields inherited from class org.apache.calcite.adapter.java.AbstractQueryableTable
elementType
-
-
Constructor Summary
Constructors Constructor Description ModifiableViewTable(java.lang.reflect.Type elementType, RelProtoDataType rowType, java.lang.String viewSql, java.util.List<java.lang.String> schemaPath, java.util.List<java.lang.String> viewPath, Table table, Path tablePath, RexNode constraint, ImmutableIntList columnMapping)
Creates a ModifiableViewTable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ModifiableViewTable
extend(java.util.List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory)
Extends the underlying table and returns a new view with updated row-type and column-mapping.protected ModifiableViewTable
extend(Table extendedTable, RelProtoDataType protoRowType, ImmutableIntList newColumnMapping)
ImmutableIntList
getColumnMapping()
Returns the column mapping onto another table.RexNode
getConstraint(RexBuilder rexBuilder, RelDataType tableRowType)
Returns a constraint that each candidate row must satisfy.private static ImmutableIntList
getNewColumnMapping(Table underlying, ImmutableIntList oldColumnMapping, java.util.List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory)
Creates a mapping from the view index to the index in the underlying table.Table
getTable()
Returns the underlying table.Path
getTablePath()
Returns the full path of the underlying table.<C> C
unwrap(java.lang.Class<C> aClass)
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.schema.impl.ViewTable
asQueryable, getJdbcTableType, getRowType, getSchemaPath, getViewPath, getViewSql, toRel, viewMacro, viewMacro, viewMacro
-
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
-
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.schema.Table
getJdbcTableType, getRowType, getStatistic, isRolledUp, rolledUpColumnValidInsideAgg
-
-
-
-
Field Detail
-
table
private final Table table
-
tablePath
private final Path tablePath
-
constraint
private final RexNode constraint
-
columnMapping
private final ImmutableIntList columnMapping
-
initializerExpressionFactory
private final InitializerExpressionFactory initializerExpressionFactory
-
-
Constructor Detail
-
ModifiableViewTable
public ModifiableViewTable(java.lang.reflect.Type elementType, RelProtoDataType rowType, java.lang.String viewSql, java.util.List<java.lang.String> schemaPath, java.util.List<java.lang.String> viewPath, Table table, Path tablePath, RexNode constraint, ImmutableIntList columnMapping)
Creates a ModifiableViewTable.
-
-
Method Detail
-
getConstraint
public RexNode getConstraint(RexBuilder rexBuilder, RelDataType tableRowType)
Description copied from interface:ModifiableView
Returns a constraint that each candidate row must satisfy.Never null; if there is no constraint, returns "true".
- Specified by:
getConstraint
in interfaceModifiableView
- Parameters:
rexBuilder
- Rex buildertableRowType
- Row type of the table that this view maps onto
-
getColumnMapping
public ImmutableIntList getColumnMapping()
Description copied from interface:ModifiableView
Returns the column mapping onto another table.mapping[i]
contains the column of the underlying table that thei
th column of the view comes from, or -1 if it is based on an expression.- Specified by:
getColumnMapping
in interfaceModifiableView
-
getTable
public Table getTable()
Description copied from interface:ModifiableView
Returns the underlying table.- Specified by:
getTable
in interfaceModifiableView
-
getTablePath
public Path getTablePath()
Description copied from interface:ModifiableView
Returns the full path of the underlying table.- Specified by:
getTablePath
in interfaceModifiableView
-
unwrap
public <C> C unwrap(java.lang.Class<C> aClass)
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.- Specified by:
unwrap
in interfaceWrapper
- Overrides:
unwrap
in classAbstractTable
-
extend
public final ModifiableViewTable extend(java.util.List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory)
Extends the underlying table and returns a new view with updated row-type and column-mapping.The type factory is used to perform some scratch calculations, viz the type mapping, but the "real" row-type will be assigned later, when the table has been bound to the statement's type factory. The is important, because adding types to type factories that do not belong to a statement could potentially leak memory.
- Parameters:
extendedColumns
- Extended fieldstypeFactory
- Type factory
-
getNewColumnMapping
private static ImmutableIntList getNewColumnMapping(Table underlying, ImmutableIntList oldColumnMapping, java.util.List<RelDataTypeField> extendedColumns, RelDataTypeFactory typeFactory)
Creates a mapping from the view index to the index in the underlying table.
-
extend
protected ModifiableViewTable extend(Table extendedTable, RelProtoDataType protoRowType, ImmutableIntList newColumnMapping)
-
-