DRILL-4372: Expose the functions return type to Drill - Drill-Calite version update: This commit needs to have Calcite's patch (CALCITE-1062) to plugin customized SqlOperator.
- FunctionTemplate Add FunctionArgumentNumber annotation. This annotation element tells if the number of argument(s) is fixed or arbitrary (e.g., String concatenation function).
Due to this modification, there are some minor changes in DrillFuncHolder, DrillFunctionRegistry and FunctionAttributes.
- Checker Add a new Checker (which Calcite uses to validate the legitimacy of the number of argument(s) for a function) to allow functions with arbitrary arguments to pass Caclite's validation
- Type conversion between Drill and Calcite DrillConstExector is given a static method getDrillTypeFromCalcite() to convert Calcite types to Drill's.
- Extract function's return type inference Unlike other functions, Extract function's return type can be determined solely based on the first argument. A logic is added in to allow this inference to happen
- DrillCalcite wrapper: From the aspects of return type inference and argument type checks, Calcite's mechanism is very different from Drill's. In addition, currently, there is no straightforward way for Drill to plug-in customized mechanisms to Calcite. Thus, wrappers are provided to serve the objective.
Except for the mechanisms of type inference and argument type checks, these wrappers just forward any method calls to the wrapped SqlOpertor, SqlFuncion or SqlAggFunction to respond.
A interface DrillCalciteSqlWrapper is also added for the callers of the three wrappers to get the wrapped objects easier.
Due to these wrappers, UnsupportedOperatorsVisitor is modified in a minor manner.
- Calcite's SqlOpertor, SqlFuncion or SqlAggFunction are wrapped in DrillOperatorTable Instead of returning Caclite's native SqlOpertor, SqlFuncion or SqlAggFunction, return the wrapped ones to ensure customized behaviors can be adopted.
- Type inference mechanism This mechanism is used across all SqlOpertor, SqlFuncion or SqlAggFunction. Thus, it is factored out as its own method in TypeInferenceUtils
- Upgrade Drill-Calcite
Bump version number to 1.4.0-drill-test-r16
- Implement two argument version of lpad, rpad
- Implement one argument version of ltrim, rtrim, btrim