org.eigenbase.test
Class RelOptRulesTest
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.eigenbase.test.SqlToRelTestBase
org.eigenbase.test.RelOptTestBase
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:
- 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.
- 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.
- 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.
- 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
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 |
RelOptRulesTest
public RelOptRulesTest()
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()