org.eigenbase.test
Class RelOptRulesTest

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

public class RelOptRulesTest
extends RelOptTestBase

Unit test for rules in org.eigenbase.rel and subpackages.

As input, the test supplies a SQL statement and a single rule; the SQL is translated into relational algebra and then fed into a HepPlanner. The planner fires the rule on every pattern match in a depth-first left-to-right preorder traversal of the tree for as long as the rule continues to succeed in applying its transform. (For rules which call transformTo more than once, only the last result is used.) The plan before and after "optimization" is diffed against a .ref file using DiffRepository.

Procedure for adding a new test case:

  1. Add a new public test method for your rule, following the existing examples. You'll have to come up with an SQL statement to which your rule will apply in a meaningful way. See SqlToRelTestBase class comments for details on the schema.
  2. Run the test. It should fail. Inspect the output in RelOptRulesTest.log.xml; verify that the "planBefore" is the correct translation of your SQL, and that it contains the pattern on which your rule is supposed to fire. If all is well, check out RelOptRulesTest.ref.xml and replace it with the new .log.xml.
  3. Run the test again. It should fail again, but this time it should contain a "planAfter" entry for your rule. Verify that your rule applied its transformation correctly, and then update the .ref.xml file again.
  4. Run the test one last time; this time it should pass.

Version:
$Id: //open/dev/farrago/src/org/eigenbase/test/RelOptRulesTest.java#15 $
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
 
Fields inherited from class org.eigenbase.test.SqlToRelTestBase
NL, tester
 
Constructor Summary
RelOptRulesTest()
           
 
Method Summary
protected  DiffRepository getDiffRepos()
          Returns the default diff repository for this test, or null if there is no repository.
 void testAddRedundantSemiJoinRule()
           
 void testExtractJoinFilterRule()
           
 void testPushFilterThroughOuterJoin()
           
 void testPushProjectPastFilter()
           
 void testPushProjectPastJoin()
           
 void testPushProjectPastSetOp()
           
 void testReduceAverage()
           
 void testUnionToDistinctRule()
           
 
Methods inherited from class org.eigenbase.test.RelOptTestBase
checkPlanning, checkPlanning, checkPlanning, checkPlanning, checkPlanning, createProgram
 
Methods inherited from class org.eigenbase.test.SqlToRelTestBase
createTester
 
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
 

Constructor Detail

RelOptRulesTest

public RelOptRulesTest()
Method Detail

getDiffRepos

protected DiffRepository getDiffRepos()
Description copied from class: SqlToRelTestBase
Returns the default diff repository for this test, or null if there is no repository.

The default implementation returns null.

Sub-classes that want to use a diff repository can override. Sub-sub-classes can override again, inheriting test cases and overriding selected test results.

And individual test cases can override by providing a different tester object.

Overrides:
getDiffRepos in class SqlToRelTestBase
Returns:
Diff repository

testUnionToDistinctRule

public void testUnionToDistinctRule()

testExtractJoinFilterRule

public void testExtractJoinFilterRule()

testAddRedundantSemiJoinRule

public void testAddRedundantSemiJoinRule()

testPushFilterThroughOuterJoin

public void testPushFilterThroughOuterJoin()

testReduceAverage

public void testReduceAverage()

testPushProjectPastFilter

public void testPushProjectPastFilter()

testPushProjectPastJoin

public void testPushProjectPastJoin()

testPushProjectPastSetOp

public void testPushProjectPastSetOp()