com.lucidera.opt.test
Class LoptMetadataTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.eigenbase.test.DiffTestCase
              extended by net.sf.farrago.test.ResultSetTestCase
                  extended by net.sf.farrago.test.FarragoTestCase
                      extended by net.sf.farrago.test.FarragoSqlToRelTestBase
                          extended by com.lucidera.opt.test.LoptMetadataTest
All Implemented Interfaces:
Test

public class LoptMetadataTest
extends FarragoSqlToRelTestBase

LoptMetadataTest tests the relational expression metadata queries relied on by the LucidDB optimizer.

NOTE jvs 11-Apr-2006: We don't actually diff the plans used as input to the metadata queries, because that's not what we're testing here. To see what you're getting while developing new tests (or when old ones break), set trace net.sf.farrago.query.plandump.level=FINE and check the trace output; you'll also be able to see rowcounts and cumulative costs for all expressions.

Version:
$Id: //open/dev/farrago/src/com/lucidera/opt/test/LoptMetadataTest.java#32 $
Author:
John V. Sichi

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.farrago.test.FarragoTestCase
FarragoTestCase.Cleanup, FarragoTestCase.CleanupFactory
 
Field Summary
private static long COLSTORE_DEPTS_ROWCOUNT
           
private static long COLSTORE_EMPS_ROWCOUNT
           
private static double DEFAULT_EQUAL_SELECTIVITY
           
private static double DEFAULT_ROWCOUNT
           
private static double DEFAULT_SARGABLE_SELECTIVITY
           
private static boolean doneStaticSetup
           
private static double EPSILON
           
private  HepProgram program
           
private  RexBuilder rexBuilder
           
private  RelNode rootRel
           
private static long SALES_EMPS_ROWCOUNT
           
private  RelStatSource tableStats
           
private  FarragoReposTxnContext txn
           
 
Fields inherited from class net.sf.farrago.test.FarragoTestCase
allocOwner, connection, preparedStmt, repos, stmt, tracer
 
Fields inherited from class net.sf.farrago.test.ResultSetTestCase
resultSet
 
Fields inherited from class org.eigenbase.test.DiffTestCase
logFile, logOutputStream, refFile
 
Constructor Summary
LoptMetadataTest(String testName)
          Creates a new LoptMetadataTest object.
 
Method Summary
protected  void checkAbstract(FarragoPreparingStmt stmt, RelNode relBefore)
           
private  void checkColumn(int ordinal, RexNode rexPredicate, Double selectivity, Double cardinality)
           
private  void checkCost(double costExpected, RelOptCost costActual)
           
private  void checkDistinctRowCount(String sql, BitSet groupKey, Double expected)
           
private  void checkDouble(Double expected, Double value, double epsilon)
           
private  void checkNoSimpleColumnOrigin(String sql)
           
private  void checkPredicate(int ordinal, SqlBinaryOperator operator, BigDecimal value, Double selectivity, Double cardinality)
           
private  void checkRowCount(String table, Double rowCount)
           
private  void checkRowCountJoin(String sql, Double expected)
           
static void checkSimpleColumnOrigin(RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived)
           
private  Set<RelColumnOrigin> checkSimpleColumnOrigin(String sql)
           
private  void checkSingleColumnOrigin(String sql, String expectedTableName, String expectedColumnName, boolean expectedDerived)
           
protected  void initPlanner(FarragoPreparingStmt stmt)
           
private  void localSetUp()
           
private  void localTearDown()
           
private  RexNode makeAndNode(RexNode a, RexNode b)
           
private  RexNode makeIntNode(int ordinal, SqlBinaryOperator operator, BigDecimal value)
           
private  RexNode makeOrNode(RexNode a, RexNode b)
           
private  RexNode makeSearchNode(int ordinal, RexLiteral value)
           
private  RexNode makeStringNode(int ordinal, SqlBinaryOperator operator, String str)
           
private  void searchColumn(int ordinal, RexLiteral value, Double selectivity, Double cardinality)
           
protected  void setUp()
           
static Test suite()
           
 void tearDown()
           
 void testCumulativeCostAggregate()
           
 void testCumulativeCostFilter()
           
 void testCumulativeCostFilteredProjection()
           
 void testCumulativeCostFilteredProjectionSort()
           
 void testCumulativeCostRowScanWithInputs()
           
 void testCumulativeCostSelfJoin()
           
 void testCumulativeCostSemiJoin()
           
 void testCumulativeCostTable()
           
 void testCumulativeCostUnion()
           
 void testDistinctRowCountHashJoin()
           
 void testDistinctRowCountNonSargableFilter()
           
 void testDistinctRowCountNoStatsFilter()
           
 void testDistinctRowCountProjectedLcsTable()
           
 void testDistinctRowCountSargableFilter()
           
 void testDistinctRowCountSargAndNonSargFilters()
           
 void testDistinctRowCountTabNoFilter()
           
 void testDistinctRowCountUniqueTab()
           
 void testEmptyStatistics()
           
 void testFilteredStatistics()
           
 void testNotUniqueIfRidAboveJoin()
           
 void testPopulationHashJoin()
           
 void testPopulationNoProjExprs()
           
private  void testPopulationProjectedLcsTable(String sql, BitSet groupKey, double expected, double epsilon)
           
 void testPopulationProjFuncExpr()
           
 void testPopulationProjTimesExpr()
           
 void testRowCountDistinctUnion()
           
 void testRowCountHashJoin()
           
 void testRowCountJoinBigStats()
           
 void testRowCountJoinFtrs()
           
 void testRowCountJoinLcs()
           
 void testRowCountJoinNoColStats()
           
 void testRowCountJoinNonEquiJoin()
           
 void testRowCountLeftOuterJoinNoColStats()
           
 void testRowCountLeftSemiJoin()
           
 void testRowCountRightAntiJoin()
           
 void testRowCountRightOuterJoinNoColStats()
           
 void testRowCountRowScanWithInputs()
           
 void testSelectivityJoin()
           
 void testSelectivityLcsTableNoStats()
           
 void testSimpleColumnOriginProjectedRowScan()
           
 void testSimpleColumnOriginsAggregate()
           
 void testSimpleColumnOriginsJoin()
           
 void testSimpleColumnOriginsProjFilter()
           
 void testSimpleColumnOriginsUnion()
           
 void testTypedStatistics()
           
 void testUniqueKeysProjectedLcsTable()
           
 void testUniqueKeysProjectedLcsTableWhenNullsFiltered()
           
 void testUniqueRidColumn()
           
private  void transformQuery(HepProgram program, String sql)
           
private  void transformQuery(String sql)
           
 
Methods inherited from class net.sf.farrago.test.FarragoSqlToRelTestBase
addRulesAndCheckQuery, checkQuery
 
Methods inherited from class net.sf.farrago.test.FarragoTestCase
forceShutdown, getJdbcUri, getSession, getTestlogRoot, getTestlogRootStatic, newConnection, newJdbcEngineDriver, restoreParameters, restoreParameters, runCleanup, runSqlLineTest, runSqlLineTest, saveParameters, saveParameters, setRefFileDiffMasks, shouldDiff, staticSetUp, staticTearDown, tearDownImpl, wrappedSuite, wrappedSuite
 
Methods inherited from class net.sf.farrago.test.ResultSetTestCase
compareResultList, compareResultLists, compareResultSet, compareResultSetWithDelta, compareResultSetWithPattern, getResultSetCount
 
Methods inherited from class org.eigenbase.test.DiffTestCase
addDiffMask, addIgnorePattern, diffFile, diffLines, diffTestLog, fileContents, openTestLog, openTestLogOutputStream, setGC, setVerbose
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

doneStaticSetup

private static boolean doneStaticSetup

EPSILON

private static final double EPSILON
See Also:
Constant Field Values

SALES_EMPS_ROWCOUNT

private static final long SALES_EMPS_ROWCOUNT
See Also:
Constant Field Values

COLSTORE_EMPS_ROWCOUNT

private static final long COLSTORE_EMPS_ROWCOUNT
See Also:
Constant Field Values

COLSTORE_DEPTS_ROWCOUNT

private static final long COLSTORE_DEPTS_ROWCOUNT
See Also:
Constant Field Values

DEFAULT_EQUAL_SELECTIVITY

private static final double DEFAULT_EQUAL_SELECTIVITY
See Also:
Constant Field Values

DEFAULT_SARGABLE_SELECTIVITY

private static final double DEFAULT_SARGABLE_SELECTIVITY
See Also:
Constant Field Values

DEFAULT_ROWCOUNT

private static final double DEFAULT_ROWCOUNT
See Also:
Constant Field Values

program

private HepProgram program

rootRel

private RelNode rootRel

tableStats

private RelStatSource tableStats

rexBuilder

private RexBuilder rexBuilder

txn

private FarragoReposTxnContext txn
Constructor Detail

LoptMetadataTest

public LoptMetadataTest(String testName)
                 throws Exception
Creates a new LoptMetadataTest object.

Parameters:
testName - JUnit test name
Throws:
Exception - .
Method Detail

suite

public static Test suite()

setUp

protected void setUp()
              throws Exception
Overrides:
setUp in class FarragoTestCase
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class FarragoTestCase
Throws:
Exception

localSetUp

private void localSetUp()

localTearDown

private void localTearDown()

checkAbstract

protected void checkAbstract(FarragoPreparingStmt stmt,
                             RelNode relBefore)
                      throws Exception
Specified by:
checkAbstract in class FarragoSqlToRelTestBase
Throws:
Exception

transformQuery

private void transformQuery(HepProgram program,
                            String sql)
                     throws Exception
Throws:
Exception

transformQuery

private void transformQuery(String sql)
                     throws Exception
Throws:
Exception

initPlanner

protected void initPlanner(FarragoPreparingStmt stmt)
Specified by:
initPlanner in class FarragoSqlToRelTestBase

checkCost

private void checkCost(double costExpected,
                       RelOptCost costActual)

checkRowCount

private void checkRowCount(String table,
                           Double rowCount)
                    throws Exception
Throws:
Exception

checkColumn

private void checkColumn(int ordinal,
                         RexNode rexPredicate,
                         Double selectivity,
                         Double cardinality)

checkDouble

private void checkDouble(Double expected,
                         Double value,
                         double epsilon)

checkPredicate

private void checkPredicate(int ordinal,
                            SqlBinaryOperator operator,
                            BigDecimal value,
                            Double selectivity,
                            Double cardinality)

makeIntNode

private RexNode makeIntNode(int ordinal,
                            SqlBinaryOperator operator,
                            BigDecimal value)

makeStringNode

private RexNode makeStringNode(int ordinal,
                               SqlBinaryOperator operator,
                               String str)

makeOrNode

private RexNode makeOrNode(RexNode a,
                           RexNode b)

makeAndNode

private RexNode makeAndNode(RexNode a,
                            RexNode b)

makeSearchNode

private RexNode makeSearchNode(int ordinal,
                               RexLiteral value)

searchColumn

private void searchColumn(int ordinal,
                          RexLiteral value,
                          Double selectivity,
                          Double cardinality)

testCumulativeCostTable

public void testCumulativeCostTable()
                             throws Exception
Throws:
Exception

testCumulativeCostFilter

public void testCumulativeCostFilter()
                              throws Exception
Throws:
Exception

testCumulativeCostRowScanWithInputs

public void testCumulativeCostRowScanWithInputs()
                                         throws Exception
Throws:
Exception

testCumulativeCostFilteredProjection

public void testCumulativeCostFilteredProjection()
                                          throws Exception
Throws:
Exception

testCumulativeCostFilteredProjectionSort

public void testCumulativeCostFilteredProjectionSort()
                                              throws Exception
Throws:
Exception

testCumulativeCostUnion

public void testCumulativeCostUnion()
                             throws Exception
Throws:
Exception

testCumulativeCostSelfJoin

public void testCumulativeCostSelfJoin()
                                throws Exception
Throws:
Exception

testCumulativeCostSemiJoin

public void testCumulativeCostSemiJoin()
                                throws Exception
Throws:
Exception

testCumulativeCostAggregate

public void testCumulativeCostAggregate()
                                 throws Exception
Throws:
Exception

testEmptyStatistics

public void testEmptyStatistics()
                         throws Exception
Throws:
Exception

testFilteredStatistics

public void testFilteredStatistics()
                            throws Exception
Throws:
Exception

testTypedStatistics

public void testTypedStatistics()
                         throws Exception
Throws:
Exception

testRowCountRowScanWithInputs

public void testRowCountRowScanWithInputs()
                                   throws Exception
Throws:
Exception

checkRowCountJoin

private void checkRowCountJoin(String sql,
                               Double expected)
                        throws Exception
Throws:
Exception

testRowCountJoinFtrs

public void testRowCountJoinFtrs()
                          throws Exception
Throws:
Exception

testRowCountJoinLcs

public void testRowCountJoinLcs()
                         throws Exception
Throws:
Exception

testRowCountJoinNoColStats

public void testRowCountJoinNoColStats()
                                throws Exception
Throws:
Exception

testRowCountJoinBigStats

public void testRowCountJoinBigStats()
                              throws Exception
Throws:
Exception

testRowCountLeftOuterJoinNoColStats

public void testRowCountLeftOuterJoinNoColStats()
                                         throws Exception
Throws:
Exception

testRowCountRightOuterJoinNoColStats

public void testRowCountRightOuterJoinNoColStats()
                                          throws Exception
Throws:
Exception

testRowCountJoinNonEquiJoin

public void testRowCountJoinNonEquiJoin()
                                 throws Exception
Throws:
Exception

testRowCountHashJoin

public void testRowCountHashJoin()
                          throws Exception
Throws:
Exception

testRowCountLeftSemiJoin

public void testRowCountLeftSemiJoin()
                              throws Exception
Throws:
Exception

testRowCountRightAntiJoin

public void testRowCountRightAntiJoin()
                               throws Exception
Throws:
Exception

testRowCountDistinctUnion

public void testRowCountDistinctUnion()
                               throws Exception
Throws:
Exception

testSelectivityJoin

public void testSelectivityJoin()
                         throws Exception
Throws:
Exception

checkDistinctRowCount

private void checkDistinctRowCount(String sql,
                                   BitSet groupKey,
                                   Double expected)
                            throws Exception
Throws:
Exception

testDistinctRowCountTabNoFilter

public void testDistinctRowCountTabNoFilter()
                                     throws Exception
Throws:
Exception

testDistinctRowCountSargableFilter

public void testDistinctRowCountSargableFilter()
                                        throws Exception
Throws:
Exception

testDistinctRowCountNonSargableFilter

public void testDistinctRowCountNonSargableFilter()
                                           throws Exception
Throws:
Exception

testDistinctRowCountSargAndNonSargFilters

public void testDistinctRowCountSargAndNonSargFilters()
                                               throws Exception
Throws:
Exception

testDistinctRowCountNoStatsFilter

public void testDistinctRowCountNoStatsFilter()
                                       throws Exception
Throws:
Exception

testDistinctRowCountUniqueTab

public void testDistinctRowCountUniqueTab()
                                   throws Exception
Throws:
Exception

testSelectivityLcsTableNoStats

public void testSelectivityLcsTableNoStats()
                                    throws Exception
Throws:
Exception

testDistinctRowCountProjectedLcsTable

public void testDistinctRowCountProjectedLcsTable()
                                           throws Exception
Throws:
Exception

testDistinctRowCountHashJoin

public void testDistinctRowCountHashJoin()
                                  throws Exception
Throws:
Exception

testPopulationProjectedLcsTable

private void testPopulationProjectedLcsTable(String sql,
                                             BitSet groupKey,
                                             double expected,
                                             double epsilon)
                                      throws Exception
Throws:
Exception

testPopulationNoProjExprs

public void testPopulationNoProjExprs()
                               throws Exception
Throws:
Exception

testPopulationProjFuncExpr

public void testPopulationProjFuncExpr()
                                throws Exception
Throws:
Exception

testPopulationProjTimesExpr

public void testPopulationProjTimesExpr()
                                 throws Exception
Throws:
Exception

testPopulationHashJoin

public void testPopulationHashJoin()
                            throws Exception
Throws:
Exception

testUniqueKeysProjectedLcsTable

public void testUniqueKeysProjectedLcsTable()
                                     throws Exception
Throws:
Exception

testUniqueKeysProjectedLcsTableWhenNullsFiltered

public void testUniqueKeysProjectedLcsTableWhenNullsFiltered()
                                                      throws Exception
Throws:
Exception

testUniqueRidColumn

public void testUniqueRidColumn()
                         throws Exception
Throws:
Exception

testNotUniqueIfRidAboveJoin

public void testNotUniqueIfRidAboveJoin()
                                 throws Exception
Throws:
Exception

checkSimpleColumnOrigin

private Set<RelColumnOrigin> checkSimpleColumnOrigin(String sql)
                                              throws Exception
Throws:
Exception

checkNoSimpleColumnOrigin

private void checkNoSimpleColumnOrigin(String sql)
                                throws Exception
Throws:
Exception

checkSimpleColumnOrigin

public static void checkSimpleColumnOrigin(RelColumnOrigin rco,
                                           String expectedTableName,
                                           String expectedColumnName,
                                           boolean expectedDerived)

checkSingleColumnOrigin

private void checkSingleColumnOrigin(String sql,
                                     String expectedTableName,
                                     String expectedColumnName,
                                     boolean expectedDerived)
                              throws Exception
Throws:
Exception

testSimpleColumnOriginsProjFilter

public void testSimpleColumnOriginsProjFilter()
                                       throws Exception
Throws:
Exception

testSimpleColumnOriginsAggregate

public void testSimpleColumnOriginsAggregate()
                                      throws Exception
Throws:
Exception

testSimpleColumnOriginsUnion

public void testSimpleColumnOriginsUnion()
                                  throws Exception
Throws:
Exception

testSimpleColumnOriginsJoin

public void testSimpleColumnOriginsJoin()
                                 throws Exception
Throws:
Exception

testSimpleColumnOriginProjectedRowScan

public void testSimpleColumnOriginProjectedRowScan()
                                            throws Exception
Throws:
Exception