[
https://issues.apache.org/jira/browse/CALCITE-6550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17880405#comment-17880405
]
Norman Jordan commented on CALCITE-6550:
----------------------------------------
I have published a PR.
The main idea here is to allow collisions in the scalar function map. When
there are collisions, look for an implementation based on the SqlOperator
object identity. Much of the change here is managing the scalar function map in
{*}RexImpTable{*}.
* Alternate solutions:
Fix up the hashcode and equals methods for *SqlBasicFunction* options. There
will still be some collisions in {*}RexImpTable{*}, since a function could be
defined multiple times (ie it is in multiple function libraries with different
implementations).
* Reconsider putting all functions in {*}RexImpTable{*}. We should only need
the functions for selected libraries at any given time.
> Improve SQL function overloading
> --------------------------------
>
> Key: CALCITE-6550
> URL: https://issues.apache.org/jira/browse/CALCITE-6550
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Norman Jordan
> Assignee: Norman Jordan
> Priority: Minor
> Labels: pull-request-available
>
> All SQL functions across all SQL libraries as well as the standard functions
> are used as keys in a Map (in the class {*}RexImpTable{*}). The hashcode and
> equals methods currently only look at the name, kind and class.
> [https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/SqlOperator.java#L424]
> [https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/SqlOperator.java#L439]
> This causes a few problems:
> * Some functions may have the same name and kind but different sets of
> parameters
> * Two different SQL libraries may have functions with the same name and kind
> (and even parameters) but have different implementations.
> The current work around is to create new anonymous classes when needed to
> avoid collisions in the Map. Here is an example.
> https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java#L578
> The hashcode and equals methods should consider more information, such as the
> parameters as well as some way to differentiate similar functions in
> different libraries.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)