Literals have to be simple values (although maybe we make an exception and 
allow "CAST(NULL …)”) but it is easy to create constant complex-valued 
expressions. ARRAY, MAP, MULTISET, STRUCT are the constructors for complex 
values, and each has a corresponding operator in SqlStdOperatorTable. What you 
get back is a RexCall but it will be regarded as a constant value.

It sounds as if you have a user-defined type. Calcite has some support for 
those. (In the LucidDB ancestor project support was more extensive; see [1].) 
See SqlFunctionCategory.USER_DEFINED_CONSTRUCTOR. 

Your extended SQL will be more compatible with standard SQL if you use ‘=>’ 
rather than ‘=‘.

Julian

[1] http://farrago.sourceforge.net/design/UserDefinedTypesAndRoutines.html

> On Dec 15, 2015, at 5:30 PM, Andy Grove <[email protected]> wrote:
> 
> I'm working with a proprietary SQL dialect that supports user-defined types
> and allows queries that create values using literal expressions. I am
> trying to figure out if Calcite can support this functionality.
> 
> For example, let's assume the user has defined a type named 'Person' which
> has attributes 'firstName', 'lastName' and 'age'.
> 
> The SQL dialect would allow the following queries:
> 
> SELECT Person(firstName='Joe', lastName='Bloggs', age=21);
> 
> In this case I think I could use RelBuilder.literal() to create an instance.
> 
> However, the values could be relational expressions too:
> 
> SELECT Person(firstName=f.firstName., lastName=f.lastName, age=f.age)
> FROM flat_table f;
> 
> Is there a concept in Calcite that would support this type of use case?
> 
> Thanks,
> 
> Andy.
> 
> --
> 
> Andy Grove
> Chief Architect
> AgilData - Simple Streaming SQL that Scales
> www.agildata.com

Reply via email to