net.sf.farrago.test
Class FarragoMetadataTest

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 net.sf.farrago.test.FarragoMetadataTest
All Implemented Interfaces:
Test

public class FarragoMetadataTest
extends FarragoSqlToRelTestBase

FarragoMetadataTest tests the relational expression metadata queries that require additional sql statement support in order to test, above and beyond what can be tested in RelMetadataTest.

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/test/FarragoMetadataTest.java#22 $
Author:
Zelaine Fong

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.farrago.test.FarragoTestCase
FarragoTestCase.Cleanup, FarragoTestCase.CleanupFactory
 
Field Summary
private static double DEFAULT_COMP_SELECTIVITY
           
private static double DEFAULT_EQUAL_SELECTIVITY
           
private static double DEFAULT_EQUAL_SELECTIVITY_SQUARED
           
private static boolean doneStaticSetup
           
private static double EPSILON
           
private  HepProgram program
           
private  RelNode rootRel
           
private static double TAB_ROWCOUNT
           
 
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
FarragoMetadataTest(String testName)
          Creates a new FarragoMetadataTest object.
 
Method Summary
private  void addConcatUniqueKeys(Set<BitSet> keySet, Set<BitSet> nonUniqueKeySet)
           
protected  void checkAbstract(FarragoPreparingStmt stmt, RelNode relBefore)
           
private  void checkColumnUniqueness(Set<BitSet> keySet, Boolean expected)
           
private  void checkDistinctRowCount(RelNode rel, BitSet groupKey, Double expected)
           
private  void checkPopulation(String sql, BitSet groupKey, Double expected)
           
private  void checkUniqueKeys(String sql, Set<BitSet> expected, Set<BitSet> nonUniqueKeys, Boolean nonUniqueExpected)
           
private  void checkUniqueKeysJoin(String sql, Set<BitSet> expected, Set<BitSet> nonUniqueKeySet)
           
protected  void initPlanner(FarragoPreparingStmt stmt)
           
private  void localSetUp()
           
private  void localTearDown()
           
protected  void setUp()
           
static Test suite()
           
 void tearDown()
           
 void testAreColumnsUniqueWithCast()
           
 void testAreColumnsUniqueWithLiteral()
           
 void testDistinctRowCountAgg()
           
 void testDistinctRowCountFilter()
           
 void testDistinctRowCountJoin()
           
 void testDistinctRowCountSort()
           
 void testDistinctRowCountUnion()
           
 void testPopulationAgg()
           
 void testPopulationFilter()
           
 void testPopulationJoin()
           
 void testPopulationSort()
           
 void testPopulationTabPrimary()
           
 void testPopulationTabUniqueNotNull()
           
 void testPopulationTabUniqueNull()
           
 void testPopulationUnion()
           
 void testUniqueKeysAgg()
           
 void testUniqueKeysCartesianProduct()
           
 void testUniqueKeysCorrelateRel()
           
 void testUniqueKeysFullTableAgg()
           
 void testUniqueKeysJoinLeft()
           
 void testUniqueKeysJoinNotUnique()
           
 void testUniqueKeysJoinRight()
           
 void testUniqueKeysLeftOuterJoin()
           
 void testUniqueKeysProj1()
           
 void testUniqueKeysProj2()
           
 void testUniqueKeysProj3()
           
 void testUniqueKeysRightOuterJoin()
           
 void testUniqueKeysTab()
           
 void testUniqueKeysWhenNullsFiltered()
           
private  void transformQuery(HepProgram program, String sql)
           
private  void transformQueryWithoutImplementation(HepProgram program, 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

TAB_ROWCOUNT

private static final double TAB_ROWCOUNT
See Also:
Constant Field Values

DEFAULT_EQUAL_SELECTIVITY

private static final double DEFAULT_EQUAL_SELECTIVITY
See Also:
Constant Field Values

DEFAULT_EQUAL_SELECTIVITY_SQUARED

private static final double DEFAULT_EQUAL_SELECTIVITY_SQUARED
See Also:
Constant Field Values

DEFAULT_COMP_SELECTIVITY

private static final double DEFAULT_COMP_SELECTIVITY
See Also:
Constant Field Values

program

private HepProgram program

rootRel

private RelNode rootRel
Constructor Detail

FarragoMetadataTest

public FarragoMetadataTest(String testName)
                    throws Exception
Creates a new FarragoMetadataTest 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

transformQueryWithoutImplementation

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

transformQuery

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

initPlanner

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

checkPopulation

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

testPopulationTabPrimary

public void testPopulationTabPrimary()
                              throws Exception
Throws:
Exception

testPopulationTabUniqueNotNull

public void testPopulationTabUniqueNotNull()
                                    throws Exception
Throws:
Exception

testPopulationTabUniqueNull

public void testPopulationTabUniqueNull()
                                 throws Exception
Throws:
Exception

testPopulationFilter

public void testPopulationFilter()
                          throws Exception
Throws:
Exception

testPopulationSort

public void testPopulationSort()
                        throws Exception
Throws:
Exception

testPopulationJoin

public void testPopulationJoin()
                        throws Exception
Throws:
Exception

testPopulationUnion

public void testPopulationUnion()
                         throws Exception
Throws:
Exception

testPopulationAgg

public void testPopulationAgg()
                       throws Exception
Throws:
Exception

checkUniqueKeys

private void checkUniqueKeys(String sql,
                             Set<BitSet> expected,
                             Set<BitSet> nonUniqueKeys,
                             Boolean nonUniqueExpected)
                      throws Exception
Throws:
Exception

checkColumnUniqueness

private void checkColumnUniqueness(Set<BitSet> keySet,
                                   Boolean expected)

testUniqueKeysTab

public void testUniqueKeysTab()
                       throws Exception
Throws:
Exception

testUniqueKeysProj1

public void testUniqueKeysProj1()
                         throws Exception
Throws:
Exception

testUniqueKeysProj2

public void testUniqueKeysProj2()
                         throws Exception
Throws:
Exception

testUniqueKeysProj3

public void testUniqueKeysProj3()
                         throws Exception
Throws:
Exception

testUniqueKeysAgg

public void testUniqueKeysAgg()
                       throws Exception
Throws:
Exception

testUniqueKeysFullTableAgg

public void testUniqueKeysFullTableAgg()
                                throws Exception
Throws:
Exception

testUniqueKeysCorrelateRel

public void testUniqueKeysCorrelateRel()
                                throws Exception
Throws:
Exception

testUniqueKeysWhenNullsFiltered

public void testUniqueKeysWhenNullsFiltered()
                                     throws Exception
Throws:
Exception

testAreColumnsUniqueWithLiteral

public void testAreColumnsUniqueWithLiteral()
                                     throws Exception
Throws:
Exception

testAreColumnsUniqueWithCast

public void testAreColumnsUniqueWithCast()
                                  throws Exception
Throws:
Exception

checkUniqueKeysJoin

private void checkUniqueKeysJoin(String sql,
                                 Set<BitSet> expected,
                                 Set<BitSet> nonUniqueKeySet)
                          throws Exception
Throws:
Exception

addConcatUniqueKeys

private void addConcatUniqueKeys(Set<BitSet> keySet,
                                 Set<BitSet> nonUniqueKeySet)

testUniqueKeysJoinLeft

public void testUniqueKeysJoinLeft()
                            throws Exception
Throws:
Exception

testUniqueKeysJoinRight

public void testUniqueKeysJoinRight()
                             throws Exception
Throws:
Exception

testUniqueKeysJoinNotUnique

public void testUniqueKeysJoinNotUnique()
                                 throws Exception
Throws:
Exception

testUniqueKeysCartesianProduct

public void testUniqueKeysCartesianProduct()
                                    throws Exception
Throws:
Exception

testUniqueKeysLeftOuterJoin

public void testUniqueKeysLeftOuterJoin()
                                 throws Exception
Throws:
Exception

testUniqueKeysRightOuterJoin

public void testUniqueKeysRightOuterJoin()
                                  throws Exception
Throws:
Exception

checkDistinctRowCount

private void checkDistinctRowCount(RelNode rel,
                                   BitSet groupKey,
                                   Double expected)

testDistinctRowCountFilter

public void testDistinctRowCountFilter()
                                throws Exception
Throws:
Exception

testDistinctRowCountSort

public void testDistinctRowCountSort()
                              throws Exception
Throws:
Exception

testDistinctRowCountUnion

public void testDistinctRowCountUnion()
                               throws Exception
Throws:
Exception

testDistinctRowCountAgg

public void testDistinctRowCountAgg()
                             throws Exception
Throws:
Exception

testDistinctRowCountJoin

public void testDistinctRowCountJoin()
                              throws Exception
Throws:
Exception