[ 
https://issues.apache.org/jira/browse/CALCITE-5891?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17763299#comment-17763299
 ] 

Mihai Budiu commented on CALCITE-5891:
--------------------------------------

I have made some progress on this front.

The dataflow is as follows:
 * I have a test fixture that extends CalciteSqlOperatorTest
 * The fixture overloads the check function
 * The check function optimizes the query supplied in 4 steps
 ** convert to RelNode (reusing a RelOptFixture)
 ** Use a HepPlanner with a fixed plan; the most important is 
PROJECT_REDUCE_EXPRESSIONS
 ** Convert RelNode to SqlNode using RelToSqlConverter
 ** Convert SqlNode to a String using toSqlString().
 * After optimizing the query, call the super.check(optimizedQuery) function

Ideally this should work, but at this point 70 out of 463 tests fail. There are 
various reasons for the failures. Incorrect optimization is only one of them:
 * result is not equivalent to expected result (optimizer error)
 * type of result is not the same as the type of the expected result 
CALCITE-5987
 * compilation of query into RelNode throws
 * optimizer throws
 * conversion of RelNode to SqlNode fails (e.g., CALCITE-5988)

One solution would be for me to submit a PR with this implementation by 
overloading all the failing tests and using a JUnit annotation to ignore them. 
Then we can assign the bugs to various people responsible for various pieces 
and delete the ignored tests as they are fixed.

Happy to hear other proposals.

> Create a test fixture that would apply PROJECT_REDUCE_EXPRESSIONS to all 
> tests in SqlOperatorTest 
> --------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5891
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5891
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Mihai Budiu
>            Priority: Major
>
> SqlOperatorTest has many tests, including end-to-end tests.
> However, none of these tests exercise the PROJECT_REDUCE_EXPRESSION rules, 
> which often produce different results than these tests for constant 
> expressions.
> Ideally we should be able to subclass SqlOperatorTest and use a fixture that 
> also applies this optimization prior to evaluation.
> I have marked this as a {*}major priority{*}, because I suspect it would 
> catch many bugs with minimal effort. (I have found at least 10 so far.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to