Package org.apache.calcite.materialize
Class Lattice
java.lang.Object
org.apache.calcite.materialize.Lattice
Structure that allows materialized views based upon a star schema to be
recognized and recommended.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classColumn in a lattice.static classLattice builder.static classColumn in a lattice.static classColumn in a lattice that is based upon a SQL expression.static classA measure within aLattice.static classThe information necessary to convert a column to SQL.static classMaterialized aggregate within a lattice.static classTile builder. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanfinal longfinal booleanfinal com.google.common.collect.ImmutableList<Lattice.Column>final com.google.common.collect.ImmutableList<Lattice.Measure>final LatticeRootNodefinal CalciteSchemafinal doublefinal LatticeStatisticProviderfinal com.google.common.collect.ImmutableList<Lattice.Tile> -
Method Summary
Modifier and TypeMethodDescriptionstatic Lattice.Builderbuilder(CalciteSchema calciteSchema, String sql) Iterable<? extends Lattice.Tile>countSql(ImmutableBitSet groupSet) Returns a SQL query that counts the number of distinct values of the attributes given ingroupSet.static Latticecreate(CalciteSchema schema, String sql, boolean auto) Creates a Lattice.createSqlWriter(SqlDialect dialect, StringBuilder buf, IntFunction<SqlNode> field) Creates a context to which SQL can be generated.intfirstColumn(String tableAlias) Returns the ordinal, within all of the columns in this Lattice, of the first column in the table with a given alias.doubleReturns an estimate of the number of rows in the un-aggregated star.static doublegetRowCount(double factCount, double... columnCounts) Returns an estimate of the number of rows in the tile with the given dimensions.static doublegetRowCount(double factCount, List<Double> columnCounts) Returns an estimate of the number of rows in the tile with the given dimensions.doublegetRowCount(List<Lattice.Column> columns) Returns an estimate of the number of rows in the tile with the given dimensions.booleanisAlwaysMeasure(Lattice.Column column) Returns whether every use of a column is as an argument to a measure.sql(ImmutableBitSet groupSet, boolean group, List<Lattice.Measure> aggCallList) Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures, optionally grouping.sql(ImmutableBitSet groupSet, boolean group, List<Lattice.Measure> aggCallList, SqlDialect dialect) Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures, optionally grouping and dialect.sql(ImmutableBitSet groupSet, List<Lattice.Measure> aggCallList) Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures.tables()Returns the set of tables in this lattice.toMeasures(List<AggregateCall> aggCallList) toString()
-
Field Details
-
rootSchema
-
rootNode
-
columns
-
auto
public final boolean auto -
algorithm
public final boolean algorithm -
algorithmMaxMillis
public final long algorithmMaxMillis -
rowCountEstimate
public final double rowCountEstimate -
defaultMeasures
-
tiles
-
columnUses
-
statisticProvider
-
-
Method Details
-
create
Creates a Lattice. -
toString
-
sql
Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures. -
sql
Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures, optionally grouping. -
sql
public String sql(ImmutableBitSet groupSet, boolean group, List<Lattice.Measure> aggCallList, SqlDialect dialect) Generates a SQL query to populate a tile of the lattice specified by a given set of columns and measures, optionally grouping and dialect. -
createSqlWriter
public Lattice.SqlWriter createSqlWriter(SqlDialect dialect, StringBuilder buf, IntFunction<SqlNode> field) Creates a context to which SQL can be generated. -
countSql
Returns a SQL query that counts the number of distinct values of the attributes given ingroupSet. -
createStarTable
-
builder
-
toMeasures
-
computeTiles
-
getFactRowCount
public double getFactRowCount()Returns an estimate of the number of rows in the un-aggregated star. -
getRowCount
Returns an estimate of the number of rows in the tile with the given dimensions. -
getRowCount
public static double getRowCount(double factCount, double... columnCounts) Returns an estimate of the number of rows in the tile with the given dimensions. -
getRowCount
Returns an estimate of the number of rows in the tile with the given dimensions. -
uniqueColumnNames
-
tables
Returns the set of tables in this lattice. -
firstColumn
Returns the ordinal, within all of the columns in this Lattice, of the first column in the table with a given alias. Returns -1 if the table is not found. -
isAlwaysMeasure
Returns whether every use of a column is as an argument to a measure.For example, in the query
select sum(x + y), sum(a + b) from t group by x + ythe expression "x + y" is used once as an argument to a measure, and once as a dimension.Therefore, in a lattice created from that one query,
isAlwaysMeasurefor the derived column corresponding to "x + y" returns false, and for "a + b" returns true.- Parameters:
column- Column or derived column- Returns:
- Whether all uses are as arguments to aggregate functions
-