Package org.apache.calcite.materialize
Class Lattice.Builder
- java.lang.Object
-
- org.apache.calcite.materialize.Lattice.Builder
-
- Enclosing class:
- Lattice
public static class Lattice.Builder extends java.lang.Object
Lattice builder.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Lattice.Builder.Fixer
Work space for fixing up a tree of mutable nodes.
-
Field Summary
Fields Modifier and Type Field Description private boolean
algorithm
private long
algorithmMaxMillis
private boolean
auto
private com.google.common.collect.ImmutableList<Lattice.BaseColumn>
baseColumns
private com.google.common.collect.ImmutableListMultimap<java.lang.String,Lattice.Column>
columnsByAlias
private java.util.SortedSet<Lattice.Measure>
defaultMeasureSet
private java.util.Map<java.lang.String,Lattice.DerivedColumn>
derivedColumnsByName
private LatticeRootNode
rootNode
private CalciteSchema
rootSchema
private java.lang.Double
rowCountEstimate
private java.lang.String
statisticProvider
private com.google.common.collect.ImmutableList.Builder<Lattice.Tile>
tileListBuilder
-
Constructor Summary
Constructors Constructor Description Builder(LatticeSpace space, CalciteSchema schema, java.lang.String sql)
Builder(LatticeSpace space, CalciteSchema schema, MutableNode mutableNode)
Creates a Builder based upon a mutable node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addMeasure(Lattice.Measure measure)
Adds a measure, if it does not already exist.void
addTile(Lattice.Tile tile)
Lattice.Builder
algorithm(boolean algorithm)
Sets the "algorithm" attribute (default false).Lattice.Builder
algorithmMaxMillis(long algorithmMaxMillis)
Sets the "algorithmMaxMillis" attribute (default -1).Lattice.Builder
auto(boolean auto)
Sets the "auto" attribute (default true).Lattice
build()
Builds a lattice.Lattice.Column
column(int table, int column)
Lattice.Column
expression(RexNode e, java.lang.String alias, java.util.List<java.lang.String> tableAliases)
Adds a lattice column based on a SQL expression, or returns a column based on the same expression seen previously.(package private) Lattice.Column
pathOffsetToColumn(Path path, int offset)
private SqlAggFunction
resolveAgg(java.lang.String aggName)
com.google.common.collect.ImmutableList<Lattice.Column>
resolveArgs(java.lang.Object args)
Resolves the arguments of aJsonMeasure
.Lattice.Column
resolveColumn(java.lang.Object name)
private Lattice.Column
resolveColumnByAlias(java.lang.String name)
Looks up a column in this lattice by alias.Lattice.Measure
resolveMeasure(java.lang.String aggName, boolean distinct, java.lang.Object args)
private Lattice.Column
resolveQualifiedColumn(java.lang.String table, java.lang.String column)
Lattice.Builder
rowCountEstimate(double rowCountEstimate)
Sets the "rowCountEstimate" attribute (default null).Lattice.Builder
statisticProvider(java.lang.String statisticProvider)
Sets the "statisticProvider" attribute.
-
-
-
Field Detail
-
rootNode
private final LatticeRootNode rootNode
-
baseColumns
private final com.google.common.collect.ImmutableList<Lattice.BaseColumn> baseColumns
-
columnsByAlias
private final com.google.common.collect.ImmutableListMultimap<java.lang.String,Lattice.Column> columnsByAlias
-
defaultMeasureSet
private final java.util.SortedSet<Lattice.Measure> defaultMeasureSet
-
tileListBuilder
private final com.google.common.collect.ImmutableList.Builder<Lattice.Tile> tileListBuilder
-
rootSchema
private final CalciteSchema rootSchema
-
algorithm
private boolean algorithm
-
algorithmMaxMillis
private long algorithmMaxMillis
-
auto
private boolean auto
-
rowCountEstimate
private java.lang.Double rowCountEstimate
-
statisticProvider
private java.lang.String statisticProvider
-
derivedColumnsByName
private java.util.Map<java.lang.String,Lattice.DerivedColumn> derivedColumnsByName
-
-
Constructor Detail
-
Builder
public Builder(LatticeSpace space, CalciteSchema schema, java.lang.String sql)
-
Builder
Builder(LatticeSpace space, CalciteSchema schema, MutableNode mutableNode)
Creates a Builder based upon a mutable node.
-
-
Method Detail
-
auto
public Lattice.Builder auto(boolean auto)
Sets the "auto" attribute (default true).
-
algorithm
public Lattice.Builder algorithm(boolean algorithm)
Sets the "algorithm" attribute (default false).
-
algorithmMaxMillis
public Lattice.Builder algorithmMaxMillis(long algorithmMaxMillis)
Sets the "algorithmMaxMillis" attribute (default -1).
-
rowCountEstimate
public Lattice.Builder rowCountEstimate(double rowCountEstimate)
Sets the "rowCountEstimate" attribute (default null).
-
statisticProvider
public Lattice.Builder statisticProvider(java.lang.String statisticProvider)
Sets the "statisticProvider" attribute.If not set, the lattice will use
Lattices.CACHED_SQL
.
-
build
public Lattice build()
Builds a lattice.
-
resolveArgs
public com.google.common.collect.ImmutableList<Lattice.Column> resolveArgs(@Nullable java.lang.Object args)
Resolves the arguments of aJsonMeasure
. They must either be null, a string, or a list of strings. Throws if the structure is invalid, or if any of the columns do not exist in the lattice.
-
resolveColumnByAlias
private Lattice.Column resolveColumnByAlias(java.lang.String name)
Looks up a column in this lattice by alias. The alias must be unique within the lattice.
-
resolveColumn
public Lattice.Column resolveColumn(java.lang.Object name)
-
resolveQualifiedColumn
private Lattice.Column resolveQualifiedColumn(java.lang.String table, java.lang.String column)
-
resolveMeasure
public Lattice.Measure resolveMeasure(java.lang.String aggName, boolean distinct, @Nullable java.lang.Object args)
-
resolveAgg
private SqlAggFunction resolveAgg(java.lang.String aggName)
-
addMeasure
public boolean addMeasure(Lattice.Measure measure)
Adds a measure, if it does not already exist. Returns false if an identical measure already exists.
-
addTile
public void addTile(Lattice.Tile tile)
-
column
public Lattice.Column column(int table, int column)
-
pathOffsetToColumn
Lattice.Column pathOffsetToColumn(Path path, int offset)
-
expression
public Lattice.Column expression(RexNode e, java.lang.String alias, java.util.List<java.lang.String> tableAliases)
Adds a lattice column based on a SQL expression, or returns a column based on the same expression seen previously.
-
-