You could do something that substitutes RexCalls or SqlCalls of unsupported 
function calls with calls to supported functions.

But be sure to remember that the semantics of functions does not depend on the 
target dialect. Function semantics are always in terms of Calcite’s dialect. 
This matters when two DBs have a function with the same name that have 
different semantics. Examples of this are the various SUBSTR_ORACLE, 
SUBSTR_BIG_QUERY, SUBSTR_MYSQL functions in SqlLibraryOperators, which all 
appear as “SUBSTR” in their respective DBs but have different semantics when 
length is negative or zero. 

Julian


> On May 25, 2023, at 10:09 AM, Soumyadeep Mukhopadhyay <[email protected]> 
> wrote:
> 
> Hello Everyone,
> 
> I wanted to know how one can leverage existing dialects to add new
> functions or rename the occurrence of a specific function (or an operator).
> 
> For example, a query in Spark SQL - "SELECT EXPLODE(ARRAY['1', '2'])" will
> only work in Postgres if it is rewritten as  "SELECT UNNEST(ARRAY['1',
> '2'])". If I need to emulate this kind of substitution how should I
> approach it?
> 
> Another example that I was thinking of is, implementing functions that
> don't exist in the current dialect like ARRAY_AGG in Snowflake. How can I
> implement this in Calcite?
> 
> Any suggestions would be much appreciated. Thank you for your time! :)
> 
> With best regards,
> Soumydeep.

Reply via email to