What Danny says is correct. Type inference is built into each operator/function, so if you want to customize type inference, you basically need to create a new set of operators/functions.
I’ll add that there is interface RelDataTypeSystem, which allows you to customize properties of built-in types and key built-in operators, such as the result type of division or addition of decimals. But we do not extend that interface without good cause. Julian > On Oct 24, 2019, at 8:19 PM, Dustin Freeman <jungle.free...@gmail.com> wrote: > > Hi Danny, > > Thanks very much for quick response. Basically, you are saying that there > are not ways to change type inference rules. The only way to do that is to > write your own type inference functions for some specific calls, then use > RexShuttle to re-do type inference. > > Dustin > > > On Thu, Oct 24, 2019 at 8:09 PM Danny Chan <yuzhao....@gmail.com> wrote: > >> Dustin ~ >> >> The type inference for all kinds of operator/functions are defined by 2 >> kinds of components in Calcite: >> >> >> • The SqlOperandTypeChecker infers the operands data types >> • The SqlReturnTypeInference infers the return data type of the call >> >> That means the type inference strategy is fixed and AFAIK, there is no way >> to change it dynamically, the strategy is registered statically with the >> function/operator. >> >> If you want to explicit specify the all the integer literals should be >> INT64(BIGINT) type, you can use a RexShuttle to visit all the rexCalls and >> rewrite your relational expression. >> >> Best, >> Danny Chan >> 在 2019年10月25日 +0800 AM10:46,Dustin Freeman <jungle.free...@gmail.com>,写道: >>> Hi All, >>> >>> After I translate a query (SQL text) into a RelNode Tree like this, >>> >>> RelNode res = planner.getLogicalPlan(getSqlText()); >>> >>> What's the simplest way to do/change type inference and set nullability >> for >>> all expressions in node res? >>> >>> It seems that RelNode has some type info already like below. It seems >> both >>> constants should have a data type int64, rather than int32. A conversion >>> there is needed. That conversion could be simplified to (const int64)1). >>> Anyways to let Calcite to do such changes? >>> >>> bool greater_than(int64 minus((int64) PID, *(const int32) 1)*, (const >>> int32) 100) >>> >>> >>> Thanks, >>> >>> Dustin >>