[
https://issues.apache.org/jira/browse/CALCITE-7016?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17953073#comment-17953073
]
Alessandro Solimando commented on CALCITE-7016:
-----------------------------------------------
[~jensen] if there is consensus on the change, it can definitely be part of
1.40.0, but as you say, it's not a urgent change and it can be postponed if we
don't make it in time.
In my understanding, you are afraid that, when using the _relFn_ method to
build the relation expression to be used in the test, there is no check that
the corresponding SQL resource in the XML file matches it.
Your main concern is not about redundancy per se, but inconsistency. The _sql_
method is redundant but its consistency is checked (the SQL string is used
as-is in the XML file), you don't have a problem with that.
For the _relFn_ variant, however, one probably ends up writing manually the SQL
string in the XML file, and there is no check nor guarantee that they actually
match.
What you propose is to forbid the _sql_ resource in the XML file for tests
written using the _relFn_ variant.
This would prevent inconsistency between the XML file and the Java file, but it
also makes the tests entries in the XML file non-uniform (some have SQL, some
others not, and by looking at the XML file, you can't tell why, as you don't
see how the test was written in Java).
An alternative, which would preserve the original spirit of Julian to have SQL
in the XML files as well to make it self-contained (with which I agree, it's
often of great help!), would be to generate the SQL string from the _RelNode_
and check if it matches that in the XML file.
I am not sure how easy it is to achieve that, but I see two benefits:
1) all tests in the XML file follows the same format
2) we keep explicit SQL close to their plans in XML (no need to check the Java
file)
3) upon adding a new test using the _relFn_ variant, one doesn't need to write
the SQL manually, it can check the expected one upon test failure, validate it
and add it to the XML file
4) consistency of the SQL resource for _relFn_ tests in the XML file would be
automatically guaranteed
> Sql resources should not be included in XML when using relFn in
> RelOptRulesTest testing
> ---------------------------------------------------------------------------------------
>
> Key: CALCITE-7016
> URL: https://issues.apache.org/jira/browse/CALCITE-7016
> Project: Calcite
> Issue Type: Improvement
> Reporter: Zhen Chen
> Assignee: Zhen Chen
> Priority: Minor
> Labels: pull-request-available
>
> Use relFn to construct a plan for rule validation, and SQL resources should
> not be included in the result file(RelOptRulesTest.xml). If SQL can be used
> to generate plans, it is not recommended to use relFn for construction.
> Otherwise, it may lead to incorrect mapping between sql and planBefore.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)