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

Danny Chan edited comment on CALCITE-2302 at 8/23/19 3:46 AM:
--------------------------------------------------------------

Thanks, [~julianhyde] I kind of agree with your point that the "DIVIDE" 
operator is the role to decide what kind of data it should return, not the 
implicit type casts. Even though the implicit casts can implement as the same 
behavior with configurable sql dialects.

Personally I have no strong objections on leverage the return type inferring of 
RelDataTypeSystem.deriveDecimalDivideType method.

Let's give up the thoughts that we should keep the "DIVIDE" synced and 
configurable with different sql dialects.


was (Author: danny0405):
Thanks, [~julianhyde] I kind of agree with your point that the "DIVIDE" 
operator is the role to decide what kind of data it should return, not the 
implicit type casts. Even though the implicit casts can implement as the same 
behavior with configurable sql dialects.

Personally I have no strong objections on leverage the return type inferring of 
RelDataTypeSystem.deriveDecimalDivideType method, just one question:
 # How to support different sql dialects ? Because PostgreSQL and SQL-SERVER 
return integer and the others return double ? Especially for our JDBC 
connectors, do we need add a control flag or something ?

> Implicit type cast support
> --------------------------
>
>                 Key: CALCITE-2302
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2302
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Danny Chan
>            Assignee: Danny Chan
>            Priority: Critical
>              Labels: pull-request-available
>             Fix For: 1.21.0
>
>          Time Spent: 7h 10m
>  Remaining Estimate: 0h
>
> Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.
> Implicit type cast is an useful function for many cases, So we should support 
> this.
> I checkout Calcite code and found that:
>  # Now we use a validator to validate our operands types[ through kinds of 
> namespaces and scopes ]
>  # Most of the validations will finally goes to
> {code:java}
> SqlOperator.validateOperands
> {code}
>  # which will use validation logic defined in corresponding 
> SqlOperandTypeChecker
> What i'm confused about is where should i put the implicit type cast logic 
> in? I figured out 2 ways:
>  # Supply a tool class/rules to add casts into a parsed SqlNode tree which 
> will then go through the validation logic later on.
>  # Unleash the validation logic in kinds of SqlOperandTypeChecker, then 
> modify the RelNode/RexNodes tree converted from a validated SqlNode tree to 
> add in casts through custom RelOptRules.
> So guys, which of the 2 ways should i go, or if there are better way to do 
> this?
> I need your help.
>  
> Updated 18-05-30:
> Hi guys, i have made a PR in 
> [CALCITE-2302|https://github.com/apache/calcite/pull/706]
> This is design doc: [Calcite Implicit Type Cast 
> Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].
> This is the conversion types mapping: [Conversion Types 
> Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].
> I really appreciate your suggestions, thx.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to