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

Lai Zhou edited comment on CALCITE-2282 at 4/30/19 6:52 AM:
------------------------------------------------------------

[~zhztheplayer] ,thanks, you're right. " That said, you can put a operator with 
same NAME, KIND to your own table, then validator will use it to replace the 
original one"

It really works. I don't need to rewrite the Parser.jj to replace DIVIDE. I 
forgot my new solutions for DIVIDE in last comment.

Here is my code:

 
{code:java}
newOp = new SqlBinaryOperator(upName,
    operatorInSqlStdOperatorTable.getKind(),
    operatorInSqlStdOperatorTable.getLeftPrec(),
    operatorInSqlStdOperatorTable.getRightPrec(),
    HiveSqlUDFReturnTypeInference.INSTANCE, null,
    HiveSqlFunction.ArgChecker.INSTANCE);
newOp = new SqlPrefixOperator(upName,
    operatorInSqlStdOperatorTable.getKind(),
    operatorInSqlStdOperatorTable.getLeftPrec(),
    operatorInSqlStdOperatorTable.getRightPrec(),
    HiveSqlUDFReturnTypeInference.INSTANCE, null,
    HiveSqlFunction.ArgChecker.INSTANCE);
register(newOp);

{code}
If we  put an operator with same NAME, KIND to replace the original one, we'd 
better keep the same class `SqlBinaryOperator` or `SqlPrefixOperator`. So I 
introduced a new constructor

for them to construct the Operator.

as [~julianhyde] said, "Another technique could be a visitor that walks over 
expressions and replaces Calcite's DIVIDE with Hive's DIVIDE."  It also works .

Thanks.

 

 


was (Author: hhlai1990):
[~zhztheplayer] ,thanks, you're right. " That said, you can put a operator with 
same NAME, KIND to your own table, then validator will use it to replace the 
original one"

It really works. I don't need to rewrite the Parser.jj to replace DIVIDE. I 
forgot my new solutions for DIVIDE in last comment.

Here is my code:

 
{code:java}
newOp = new SqlBinaryOperator(upName,
    operatorInSqlStdOperatorTable.getKind(),
    operatorInSqlStdOperatorTable.getLeftPrec(),
    operatorInSqlStdOperatorTable.getRightPrec(),
    HiveSqlUDFReturnTypeInference.INSTANCE, null,
    HiveSqlFunction.ArgChecker.INSTANCE);
newOp = new SqlPrefixOperator(upName,
    operatorInSqlStdOperatorTable.getKind(),
    operatorInSqlStdOperatorTable.getLeftPrec(),
    operatorInSqlStdOperatorTable.getRightPrec(),
    HiveSqlUDFReturnTypeInference.INSTANCE, null,
    HiveSqlFunction.ArgChecker.INSTANCE);
register(newOp);

{code}
If we  put an operator with same NAME, KIND to replace the original one, we'd 
better keep the same class `SqlBinaryOperator` or `SqlPrefixOperator`. So I 
introduced a new constructor

for them to construct the Operator.

as [~julianhyde] said, "Another technique could be a visitor that walks over 
expressions and replaces Calcite's DIVIDE with Hive's DIVIDE." can also work .

Thanks.

 

 

> Allow OperatorTable to be pluggable in the parser
> -------------------------------------------------
>
>                 Key: CALCITE-2282
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2282
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Sudheesh Katkam
>            Priority: Major
>         Attachments: CALCITE-2282.patch.txt
>
>
> SqlAbstractParserImpl [hardcodes OperatorTable to 
> SqlStdOperatorTable|https://github.com/apache/calcite/blob/8327e674e7f0a768d124fa37fd75cda4b8a35bb6/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java#L334|https://github.com/apache/calcite/blob/8327e674e7f0a768d124fa37fd75cda4b8a35bb6/core/src/main/java/org/apache/calcite/sql/parser/SqlAbstractParserImpl.java#L334].
>  Make this pluggable via a protected method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to