Package org.apache.calcite.test
Class LatticeTest
- java.lang.Object
-
- org.apache.calcite.test.LatticeTest
-
public class LatticeTest extends java.lang.Object
Unit test for lattices.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
AUTO_LATTICE
private static java.lang.String
INVENTORY_LATTICE
private static java.lang.String
SALES_LATTICE
-
Constructor Summary
Constructors Constructor Description LatticeTest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
check(int n)
private void
checkTileAlgorithm(java.lang.String statisticProvider, java.lang.String expectedExplain)
private static CalciteAssert.AssertThat
foodmartLatticeModel(java.lang.String statisticProvider)
private static CalciteAssert.AssertThat
foodmartModel(java.lang.String... extras)
private CalciteAssert.AssertThat
foodmartModelWithOneTile()
private static CalciteAssert.AssertThat
modelWithLattice(java.lang.String name, java.lang.String sql, java.lang.String... extras)
private static CalciteAssert.AssertThat
modelWithLattices(java.lang.String... lattices)
private static void
runJdbc()
void
testAllFoodmartQueries()
Runs all queries against the Foodmart schema, using a lattice.void
testColumnCount()
Unit test forLattice.getRowCount(double, List)
.void
testDimensionIsInvalidColumn()
void
testDistinctCount()
Tests a distinct-count query.void
testDistinctCount2()
void
testGroupByEmpty()
Tests a query that uses no columns from the fact table.void
testGroupByEmpty2()
Tests a query that uses no dimension columns and one measure column.void
testGroupByEmpty3()
Tests that two queries of the same dimensionality that use different measures can use the same materialization.void
testGroupByEmptyWithPrelude()
CallstestDistinctCount()
followed bytestGroupByEmpty()
.void
testJG()
Tests a query that is created withintestTileAlgorithm()
.void
testLattice()
Tests some of the properties of theLattice
data structure.void
testLatticeInvalidSql()
Tests a lattice with invalid SQL (for a lattice).void
testLatticeInvalidSql2()
Left join is invalid in a lattice.void
testLatticeInvalidSql3()
Each lattice table must have a parent.void
testLatticeInvalidSqlFails()
Tests a lattice whose SQL is invalid.void
testLatticeRecognizeGroupJoin()
Tests an aggregate on a 2-way join query can use an aggregate table.void
testLatticeRecognizeJoin()
Tests that a 2-way join query can be mapped 4-way join lattice.void
testLatticeSql()
Tests that it's OK for a lattice to have the same name as a table in the schema.void
testLatticeSqlWithGroupByFails()
Tests a lattice whose SQL is invalid because it contains a GROUP BY.void
testLatticeSqlWithJoin()
Tests a lattice with valid join SQL.void
testLatticeSqlWithOrderByFails()
Tests a lattice whose SQL is invalid because it contains a ORDER BY.void
testLatticeSqlWithUnionFails()
Tests a lattice whose SQL is invalid because it contains a UNION ALL.void
testLatticeStarTable()
When a lattice is registered, there is a table with the same name.void
testLatticeWithBadRowCountEstimate()
void
testLatticeWithNoMeasures()
A lattice with no default measure list should get "count(*)" is its default measure.void
testLatticeWithPreDefinedTiles()
Tests a model with pre-defined tiles.void
testLatticeWithPreDefinedTilesFewerMeasures()
A query that uses a pre-defined aggregate table, at the same granularity but fewer calls to aggregate functions.void
testLatticeWithPreDefinedTilesRollUp()
Tests a query that uses a pre-defined aggregate table at a lower granularity.void
testLatticeWithSameNameAsTable()
Tests that it's OK for a lattice to have the same name as a table in the schema.void
testMeasureAggIsInvalid()
void
testMeasureArgIsInvalidColumn()
void
testMeasureArgIsNotUniqueAlias()
It is an error for "customer_id" to be a measure arg, because is not a unique alias.void
testOneLatticeOneMV()
void
testSuggester()
void
testSum()
Rolling up SUM.void
testTileAlgorithm()
Tests a model that uses an algorithm to generate an initial set of tiles.void
testTileAlgorithm2()
AstestTileAlgorithm()
, but uses theLattices.CACHED_SQL
statistics provider.void
testTileAlgorithm3()
AstestTileAlgorithm()
, but uses theLattices.PROFILER
statistics provider.void
testTileWithNoMeasures()
A tile with no measures should inherit default measure list from the lattice.void
testTwoLattices()
void
testTwoLatticesWithSameNameFails()
Tests that it's an error to have two lattices with the same name in a schema.
-
-
-
Field Detail
-
SALES_LATTICE
private static final java.lang.String SALES_LATTICE
- See Also:
- Constant Field Values
-
INVENTORY_LATTICE
private static final java.lang.String INVENTORY_LATTICE
- See Also:
- Constant Field Values
-
AUTO_LATTICE
private static final java.lang.String AUTO_LATTICE
- See Also:
- Constant Field Values
-
-
Method Detail
-
modelWithLattice
private static CalciteAssert.AssertThat modelWithLattice(java.lang.String name, java.lang.String sql, java.lang.String... extras)
-
modelWithLattices
private static CalciteAssert.AssertThat modelWithLattices(java.lang.String... lattices)
-
testLatticeSql
public void testLatticeSql() throws java.lang.Exception
Tests that it's OK for a lattice to have the same name as a table in the schema.- Throws:
java.lang.Exception
-
testLattice
public void testLattice() throws java.lang.Exception
Tests some of the properties of theLattice
data structure.- Throws:
java.lang.Exception
-
testLatticeWithSameNameAsTable
public void testLatticeWithSameNameAsTable()
Tests that it's OK for a lattice to have the same name as a table in the schema.
-
testTwoLatticesWithSameNameFails
public void testTwoLatticesWithSameNameFails()
Tests that it's an error to have two lattices with the same name in a schema.
-
testLatticeInvalidSqlFails
public void testLatticeInvalidSqlFails()
Tests a lattice whose SQL is invalid.
-
testLatticeSqlWithGroupByFails
public void testLatticeSqlWithGroupByFails()
Tests a lattice whose SQL is invalid because it contains a GROUP BY.
-
testLatticeSqlWithOrderByFails
public void testLatticeSqlWithOrderByFails()
Tests a lattice whose SQL is invalid because it contains a ORDER BY.
-
testLatticeSqlWithUnionFails
public void testLatticeSqlWithUnionFails()
Tests a lattice whose SQL is invalid because it contains a UNION ALL.
-
testLatticeSqlWithJoin
public void testLatticeSqlWithJoin()
Tests a lattice with valid join SQL.
-
testLatticeInvalidSql
public void testLatticeInvalidSql()
Tests a lattice with invalid SQL (for a lattice).
-
testLatticeInvalidSql2
public void testLatticeInvalidSql2()
Left join is invalid in a lattice.
-
testLatticeInvalidSql3
public void testLatticeInvalidSql3()
Each lattice table must have a parent.
-
testLatticeStarTable
public void testLatticeStarTable()
When a lattice is registered, there is a table with the same name. It can be used for explain, but not for queries.
-
testLatticeRecognizeJoin
public void testLatticeRecognizeJoin()
Tests that a 2-way join query can be mapped 4-way join lattice.
-
testLatticeRecognizeGroupJoin
public void testLatticeRecognizeGroupJoin()
Tests an aggregate on a 2-way join query can use an aggregate table.
-
testLatticeWithPreDefinedTiles
public void testLatticeWithPreDefinedTiles()
Tests a model with pre-defined tiles.
-
testLatticeWithPreDefinedTilesFewerMeasures
public void testLatticeWithPreDefinedTilesFewerMeasures()
A query that uses a pre-defined aggregate table, at the same granularity but fewer calls to aggregate functions.
-
testLatticeWithPreDefinedTilesRollUp
public void testLatticeWithPreDefinedTilesRollUp()
Tests a query that uses a pre-defined aggregate table at a lower granularity. Includes a measure computed from a grouping column, a measure based on COUNT rolled up using SUM, and an expression on a measure.
-
testTileAlgorithm
public void testTileAlgorithm()
Tests a model that uses an algorithm to generate an initial set of tiles.Test case for [CALCITE-428] Use optimization algorithm to suggest which tiles of a lattice to materialize.
-
testTileAlgorithm2
public void testTileAlgorithm2()
AstestTileAlgorithm()
, but uses theLattices.CACHED_SQL
statistics provider.
-
testTileAlgorithm3
public void testTileAlgorithm3()
AstestTileAlgorithm()
, but uses theLattices.PROFILER
statistics provider.
-
checkTileAlgorithm
private void checkTileAlgorithm(java.lang.String statisticProvider, java.lang.String expectedExplain)
-
foodmartLatticeModel
private static CalciteAssert.AssertThat foodmartLatticeModel(java.lang.String statisticProvider)
-
testJG
public void testJG()
Tests a query that is created withintestTileAlgorithm()
.
-
testGroupByEmpty
public void testGroupByEmpty()
Tests a query that uses no columns from the fact table.
-
testGroupByEmptyWithPrelude
public void testGroupByEmptyWithPrelude()
CallstestDistinctCount()
followed bytestGroupByEmpty()
.
-
testGroupByEmpty2
public void testGroupByEmpty2()
Tests a query that uses no dimension columns and one measure column.
-
testGroupByEmpty3
public void testGroupByEmpty3()
Tests that two queries of the same dimensionality that use different measures can use the same materialization.
-
testSum
public void testSum()
Rolling up SUM.
-
testDistinctCount
public void testDistinctCount()
Tests a distinct-count query.We can't just roll up count(distinct ...) as we do count(...), but we can still use the aggregate table if we're smart.
-
testDistinctCount2
public void testDistinctCount2()
-
testAllFoodmartQueries
public void testAllFoodmartQueries() throws java.io.IOException
Runs all queries against the Foodmart schema, using a lattice.Disabled for normal runs, because it is slow.
- Throws:
java.io.IOException
-
check
private void check(int n) throws java.io.IOException
- Throws:
java.io.IOException
-
testTileWithNoMeasures
public void testTileWithNoMeasures()
A tile with no measures should inherit default measure list from the lattice.
-
testLatticeWithNoMeasures
public void testLatticeWithNoMeasures()
A lattice with no default measure list should get "count(*)" is its default measure.
-
testDimensionIsInvalidColumn
public void testDimensionIsInvalidColumn()
-
testMeasureArgIsInvalidColumn
public void testMeasureArgIsInvalidColumn()
-
testMeasureArgIsNotUniqueAlias
public void testMeasureArgIsNotUniqueAlias()
It is an error for "customer_id" to be a measure arg, because is not a unique alias. Both "c" and "t" have "customer_id".
-
testMeasureAggIsInvalid
public void testMeasureAggIsInvalid()
-
testTwoLattices
public void testTwoLattices()
-
testOneLatticeOneMV
public void testOneLatticeOneMV()
-
testLatticeWithBadRowCountEstimate
public void testLatticeWithBadRowCountEstimate()
-
testSuggester
public void testSuggester()
-
foodmartModel
private static CalciteAssert.AssertThat foodmartModel(java.lang.String... extras)
-
foodmartModelWithOneTile
private CalciteAssert.AssertThat foodmartModelWithOneTile()
-
runJdbc
private static void runJdbc() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
testColumnCount
public void testColumnCount()
Unit test forLattice.getRowCount(double, List)
.
-
-