[
https://issues.apache.org/jira/browse/CALCITE-4775?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17416381#comment-17416381
]
Julian Hyde commented on CALCITE-4775:
--------------------------------------
OK, you're right. But the validator really shouldn't be doing rewrites. Except
"unconditional rewrites" - i.e. rewrites that the validator relies on, and if
it didn't do, the world would fall apart.
So, if this rewrite really is optional, move it to the
{{StandardConvertletTable}}, where it will be used by {{SqlToRelConverter}}. We
have ways of configuring that, e.g. {{FrameworkConfig.getConvertletTable()}}.
This is probably more work than you expected. You wanted to "drill a hole", and
I just handed you a load of tech debt to deal with. This is how progress is
made.
> Fine grained tuning of call rewrite behaviour
> ----------------------------------------------
>
> Key: CALCITE-4775
> URL: https://issues.apache.org/jira/browse/CALCITE-4775
> Project: Calcite
> Issue Type: New Feature
> Affects Versions: 1.26.0
> Environment: Calcite 1.26
> Reporter: Francesco Guardiani
> Priority: Trivial
>
> In a Flink SQL PR [https://github.com/apache/flink/pull/17256] I've tried to
> disable the call rewrite feature of Calcite parser to disable the rewrite of
> COALESCE. The problem with this is that it creates a regression in other
> components, since we rely on call rewrite for other sql features.
> Would it be possible to modify the sql call rewrite feature to pick (or
> alternatively disable) which sql operator should be rewritten?
> For example, the SqlValidator.Config could take as parameter a list of
> excludeCallRewrite
> SqlOperator classes, which can be checked later by the SqlValidatorImpl to
> enable or disable a rewrite of a specific class:
> {code:java}
> SqlValidator.Config.DEFAULT
> .withCallRewrite(true)
> .withExcludedCallRewrite(SqlCoalesceFunction.class)
> {code}
> And then in SqlValidatorImpl:
> {code:java}
> if (config.callRewrite() &&
> !config.isCallRewriteExcluded(call.getOperator().getClass())) {
> node = call.getOperator().rewriteCall(this, call);
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)