Re: Mapping arithmetic '+' operator with Date and Timestamp operands to target dialect functions
I like the idea of transforming the Rex/Rel tree for the target dialect. Via a RelOptRule or other means. Or perhaps transform the SqlNode tree (which is how we deal with ORDER BY ... NULLS LAST). That’s better, in general, than making the SqlNode-to-string logic more and more complex, because that doesn’t scale, and is not easily shared among dialects. Julian > On Aug 25, 2019, at 23:12, XING JIN wrote: > > I guess in your approach, you need to maintain a customized > `SqlImplementor` ? > How about add a RelOptRule and detect pattern of "date + interval '1' DAY" > and use a RexShuttle to convert to "target_func(date, interval '1' DAY)" > Thus only a RelOptRule needs to be maintained. > > Sachin Rohaj 于2019年8月23日周五 下午11:32写道: > >> Hello, >> >> In one of my use case i am working on DATE and TIMESTAMP based operands. We >> have >> select date + interval '1' DAY from table; >> >> I need to map this to target dialect. >> select target_func(date, interval '1' DAY) from table; >> >> *Approach*: I am planning to intercept the '+' operator in the >> 'SqlImplementor' class using 'call.type.getSqlTypeName()' and delegate that >> responsibility to get the 'target_func' from the specific dialect. >> For exampe: 'dialect.getTargetFunction(SqlTypeName)'. >> >> Thanks, >> Sachin >>
Mapping arithmetic '+' operator with Date and Timestamp operands to target dialect functions
Hello Xing, No I will not be maintaining a customized `SqlImplementor`, rather I'll be making changes in the existing `SqlImplementor`. Regards, Sachin
Re: Mapping arithmetic '+' operator with Date and Timestamp operands to target dialect functions
I guess in your approach, you need to maintain a customized `SqlImplementor` ? How about add a RelOptRule and detect pattern of "date + interval '1' DAY" and use a RexShuttle to convert to "target_func(date, interval '1' DAY)" Thus only a RelOptRule needs to be maintained. Sachin Rohaj 于2019年8月23日周五 下午11:32写道: > Hello, > > In one of my use case i am working on DATE and TIMESTAMP based operands. We > have > select date + interval '1' DAY from table; > > I need to map this to target dialect. > select target_func(date, interval '1' DAY) from table; > > *Approach*: I am planning to intercept the '+' operator in the > 'SqlImplementor' class using 'call.type.getSqlTypeName()' and delegate that > responsibility to get the 'target_func' from the specific dialect. > For exampe: 'dialect.getTargetFunction(SqlTypeName)'. > > Thanks, > Sachin >
Mapping arithmetic '+' operator with Date and Timestamp operands to target dialect functions
Hello, In one of my use case i am working on DATE and TIMESTAMP based operands. We have select date + interval '1' DAY from table; I need to map this to target dialect. select target_func(date, interval '1' DAY) from table; *Approach*: I am planning to intercept the '+' operator in the 'SqlImplementor' class using 'call.type.getSqlTypeName()' and delegate that responsibility to get the 'target_func' from the specific dialect. For exampe: 'dialect.getTargetFunction(SqlTypeName)'. Thanks, Sachin