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
Modifier and TypeClassDescriptionstatic class
Column in a lattice.static class
Lattice builder.static class
Column in a lattice.static class
Column in a lattice that is based upon a SQL expression.static class
A measure within aLattice
.static class
The information necessary to convert a column to SQL.static class
Materialized aggregate within a lattice.static class
Tile builder. -
Field Summary
Modifier and TypeFieldDescriptionfinal boolean
final long
final boolean
final com.google.common.collect.ImmutableList<Lattice.Column>
final com.google.common.collect.ImmutableList<Lattice.Measure>
final LatticeRootNode
final CalciteSchema
final double
final LatticeStatisticProvider
final com.google.common.collect.ImmutableList<Lattice.Tile>
-
Method Summary
Modifier and TypeMethodDescriptionstatic Lattice.Builder
builder
(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 Lattice
create
(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.int
firstColumn
(String tableAlias) Returns the ordinal, within all of the columns in this Lattice, of the first column in the table with a given alias.double
Returns an estimate of the number of rows in the un-aggregated star.static double
getRowCount
(double factCount, double... columnCounts) Returns an estimate of the number of rows in the tile with the given dimensions.static double
getRowCount
(double factCount, List<Double> columnCounts) Returns an estimate of the number of rows in the tile with the given dimensions.double
getRowCount
(List<Lattice.Column> columns) Returns an estimate of the number of rows in the tile with the given dimensions.boolean
isAlwaysMeasure
(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 + y
the 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,
isAlwaysMeasure
for 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
-