org.eigenbase.test
Class RelMetadataTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.eigenbase.test.SqlToRelTestBase
              extended by org.eigenbase.test.RelMetadataTest
All Implemented Interfaces:
Test

public class RelMetadataTest
extends SqlToRelTestBase

Unit test for DefaultRelMetadataProvider. See SqlToRelTestBase class comments for details on the schema used. Note that no optimizer rules are fired on the translation of the SQL into relational algebra (e.g. join conditions in the WHERE clause will look like filters), so it's necessary to phrase the SQL carefully.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/test/RelMetadataTest.java#8 $
Author:
John V. Sichi

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eigenbase.test.SqlToRelTestBase
SqlToRelTestBase.MockRelOptSchema, SqlToRelTestBase.Tester, SqlToRelTestBase.TesterImpl
 
Field Summary
private static double DEFAULT_COMP_SELECTIVITY
           
private static double DEFAULT_EQUAL_SELECTIVITY
           
private static double DEFAULT_EQUAL_SELECTIVITY_SQUARED
           
private static double DEFAULT_NOTNULL_SELECTIVITY
           
private static double DEFAULT_SELECTIVITY
           
private static double DEPT_SIZE
           
private static double EMP_SIZE
           
private static double EPSILON
           
 
Fields inherited from class org.eigenbase.test.SqlToRelTestBase
NL, tester
 
Constructor Summary
RelMetadataTest()
           
 
Method Summary
static void checkColumnOrigin(RelColumnOrigin rco, String expectedTableName, String expectedColumnName, boolean expectedDerived)
           
private  Set<RelColumnOrigin> checkColumnOrigin(String sql)
           
private  void checkFilterSelectivity(String sql, double expected)
           
private  void checkNoColumnOrigin(String sql)
           
private  void checkPercentageOriginalRows(String sql, double expected)
           
private  void checkPercentageOriginalRows(String sql, double expected, double epsilon)
           
private  void checkRelSelectivity(RelNode rel, double expected)
           
private  void checkRowCount(String sql, double expected)
           
private  void checkSingleColumnOrigin(String sql, String expectedTableName, String expectedColumnName, boolean expectedDerived)
           
private  void checkTwoColumnOrigin(String sql, String expectedTableName1, String expectedColumnName1, String expectedTableName2, String expectedColumnName2, boolean expectedDerived)
           
private  RelNode convertSql(String sql)
           
 void testColumnOriginsAggCountStar()
           
 void testColumnOriginsAggKey()
           
 void testColumnOriginsAggMeasure()
           
 void testColumnOriginsConstant()
           
 void testColumnOriginsDyadicExpression()
           
 void testColumnOriginsExpression()
           
 void testColumnOriginsFilter()
           
 void testColumnOriginsJoinFullOuter()
           
 void testColumnOriginsJoinLeft()
           
 void testColumnOriginsJoinOuter()
           
 void testColumnOriginsJoinRight()
           
 void testColumnOriginsSelfUnion()
           
 void testColumnOriginsTableOnly()
           
 void testColumnOriginsUnion()
           
 void testColumnOriginsValues()
           
 void testDistinctRowCountTable()
           
 void testPercentageOriginalRowsAgg()
           
 void testPercentageOriginalRowsJoin()
           
 void testPercentageOriginalRowsJoinTwoFilters()
           
 void testPercentageOriginalRowsOneFilter()
           
 void testPercentageOriginalRowsRedundantFilter()
           
 void testPercentageOriginalRowsTableOnly()
           
 void testPercentageOriginalRowsTwoFilters()
           
 void testPercentageOriginalRowsUnionBigFilter()
           
 void testPercentageOriginalRowsUnionLittleFilter()
           
 void testPercentageOriginalRowsUnionNoFilter()
           
 void testRowCountCartesian()
           
 void testRowCountDept()
           
 void testRowCountEmp()
           
 void testRowCountFilter()
           
 void testRowCountJoin()
           
 void testRowCountSort()
           
 void testRowCountUnion()
           
 void testSelectivityAgg()
           
 void testSelectivityAndFilter()
           
 void testSelectivityComparisonFilter()
           
 void testSelectivityIsNotNullFilter()
           
 void testSelectivityOrFilter()
           
 void testSelectivityRedundantFilter()
           
 void testSelectivitySort()
           
 void testSelectivityUnion()
           
 
Methods inherited from class org.eigenbase.test.SqlToRelTestBase
createTester, getDiffRepos
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, 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

EPSILON

private static final double EPSILON
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

DEFAULT_NOTNULL_SELECTIVITY

private static final double DEFAULT_NOTNULL_SELECTIVITY
See Also:
Constant Field Values

DEFAULT_SELECTIVITY

private static final double DEFAULT_SELECTIVITY
See Also:
Constant Field Values

EMP_SIZE

private static final double EMP_SIZE
See Also:
Constant Field Values

DEPT_SIZE

private static final double DEPT_SIZE
See Also:
Constant Field Values
Constructor Detail

RelMetadataTest

public RelMetadataTest()
Method Detail

convertSql

private RelNode convertSql(String sql)

checkPercentageOriginalRows

private void checkPercentageOriginalRows(String sql,
                                         double expected)

checkPercentageOriginalRows

private void checkPercentageOriginalRows(String sql,
                                         double expected,
                                         double epsilon)

testPercentageOriginalRowsTableOnly

public void testPercentageOriginalRowsTableOnly()

testPercentageOriginalRowsAgg

public void testPercentageOriginalRowsAgg()

testPercentageOriginalRowsOneFilter

public void testPercentageOriginalRowsOneFilter()

testPercentageOriginalRowsTwoFilters

public void testPercentageOriginalRowsTwoFilters()

testPercentageOriginalRowsRedundantFilter

public void testPercentageOriginalRowsRedundantFilter()

testPercentageOriginalRowsJoin

public void testPercentageOriginalRowsJoin()

testPercentageOriginalRowsJoinTwoFilters

public void testPercentageOriginalRowsJoinTwoFilters()

testPercentageOriginalRowsUnionNoFilter

public void testPercentageOriginalRowsUnionNoFilter()

testPercentageOriginalRowsUnionLittleFilter

public void testPercentageOriginalRowsUnionLittleFilter()

testPercentageOriginalRowsUnionBigFilter

public void testPercentageOriginalRowsUnionBigFilter()

checkColumnOrigin

private Set<RelColumnOrigin> checkColumnOrigin(String sql)

checkNoColumnOrigin

private void checkNoColumnOrigin(String sql)

checkColumnOrigin

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

checkSingleColumnOrigin

private void checkSingleColumnOrigin(String sql,
                                     String expectedTableName,
                                     String expectedColumnName,
                                     boolean expectedDerived)

checkTwoColumnOrigin

private void checkTwoColumnOrigin(String sql,
                                  String expectedTableName1,
                                  String expectedColumnName1,
                                  String expectedTableName2,
                                  String expectedColumnName2,
                                  boolean expectedDerived)

testColumnOriginsTableOnly

public void testColumnOriginsTableOnly()

testColumnOriginsExpression

public void testColumnOriginsExpression()

testColumnOriginsDyadicExpression

public void testColumnOriginsDyadicExpression()

testColumnOriginsConstant

public void testColumnOriginsConstant()

testColumnOriginsFilter

public void testColumnOriginsFilter()

testColumnOriginsJoinLeft

public void testColumnOriginsJoinLeft()

testColumnOriginsJoinRight

public void testColumnOriginsJoinRight()

testColumnOriginsJoinOuter

public void testColumnOriginsJoinOuter()

testColumnOriginsJoinFullOuter

public void testColumnOriginsJoinFullOuter()

testColumnOriginsAggKey

public void testColumnOriginsAggKey()

testColumnOriginsAggMeasure

public void testColumnOriginsAggMeasure()

testColumnOriginsAggCountStar

public void testColumnOriginsAggCountStar()

testColumnOriginsValues

public void testColumnOriginsValues()

testColumnOriginsUnion

public void testColumnOriginsUnion()

testColumnOriginsSelfUnion

public void testColumnOriginsSelfUnion()

checkRowCount

private void checkRowCount(String sql,
                           double expected)

testRowCountEmp

public void testRowCountEmp()

testRowCountDept

public void testRowCountDept()

testRowCountCartesian

public void testRowCountCartesian()

testRowCountJoin

public void testRowCountJoin()

testRowCountUnion

public void testRowCountUnion()

testRowCountFilter

public void testRowCountFilter()

testRowCountSort

public void testRowCountSort()

checkFilterSelectivity

private void checkFilterSelectivity(String sql,
                                    double expected)

testSelectivityIsNotNullFilter

public void testSelectivityIsNotNullFilter()

testSelectivityComparisonFilter

public void testSelectivityComparisonFilter()

testSelectivityAndFilter

public void testSelectivityAndFilter()

testSelectivityOrFilter

public void testSelectivityOrFilter()

checkRelSelectivity

private void checkRelSelectivity(RelNode rel,
                                 double expected)

testSelectivityRedundantFilter

public void testSelectivityRedundantFilter()

testSelectivitySort

public void testSelectivitySort()

testSelectivityUnion

public void testSelectivityUnion()

testSelectivityAgg

public void testSelectivityAgg()

testDistinctRowCountTable

public void testDistinctRowCountTable()