You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Taras Ledkov <tl...@gridgain.com> on 2021/04/27 09:41:53 UTC

How to extend SQL type system?

Hi all,

I'm looking for the way to extend SQL types for my engine based on Calcite.
Now calcite doesn't support UUID sql type. This could be fixed by 
calcite patch,
but what are the best practices for adding new engine-specific type?

e.g. I have to introduce new SQL type MY_UUID etc.

RelDataType is interface but the method RelDataType#getSqlTypeName 
returns SqlTypeName enum that is defined by calcite framework.
Are there any extension point for custom  types or it contradicts 
calcite architecture an it is not Calcite way?

Just in case, again:
I mean that under custom SQL types, it is not structured types that are 
defined by SQL user, but engine-specific types:
e.g.: blob, image, text, my_blob, my_uuid, json etc...

-- 
Taras Ledkov
Mail-To: tledkov@gridgain.com


Re: How to extend SQL type system?

Posted by JiaTao Tao <ta...@gmail.com>.
Maybe STRING type can be considered. I know there's some type that may
archive the same goal and most RDBMS doesn't support this(SQLLite support,
MySQL/pg not), but it becomes a standard type in many engines like
Spark/Hive/BigQuery, etc.


Regards!

Aron Tao


Julian Hyde <jh...@gmail.com> 于2021年4月28日周三 上午2:42写道:

> If the type is widely used we could consider supporting it. Which
> databases have a UUID type? Is there a standard ODBC/JDBC type code for it?
> Are there any built-in functions that operate on UUIDs?
>
> Another option is to create a user-defined type.
>
> Julian
>
>
> > On Apr 27, 2021, at 7:04 AM, JiaTao Tao <ta...@gmail.com> wrote:
> >
> > I think the only way is to add your type to SqlTypeName and override
> > RelDataTypeSystem/RelDataTypeFactory if needed
> >
> > Regards!
> >
> > Aron Tao
> >
> >
> > Taras Ledkov <tl...@gridgain.com> 于2021年4月27日周二 下午5:42写道:
> >
> >> Hi all,
> >>
> >> I'm looking for the way to extend SQL types for my engine based on
> Calcite.
> >> Now calcite doesn't support UUID sql type. This could be fixed by
> >> calcite patch,
> >> but what are the best practices for adding new engine-specific type?
> >>
> >> e.g. I have to introduce new SQL type MY_UUID etc.
> >>
> >> RelDataType is interface but the method RelDataType#getSqlTypeName
> >> returns SqlTypeName enum that is defined by calcite framework.
> >> Are there any extension point for custom  types or it contradicts
> >> calcite architecture an it is not Calcite way?
> >>
> >> Just in case, again:
> >> I mean that under custom SQL types, it is not structured types that are
> >> defined by SQL user, but engine-specific types:
> >> e.g.: blob, image, text, my_blob, my_uuid, json etc...
> >>
> >> --
> >> Taras Ledkov
> >> Mail-To: tledkov@gridgain.com
> >>
> >>
>
>

Re: How to extend SQL type system?

Posted by Taras Ledkov <tl...@gridgain.com>.
Hi,

What do you mean on "user defined type"?

CREATE TYPE … ?

What do you suggest to support native type like UUID for type that is 
out of JDBC scope?

class VendorName_RelDataType implement RelDataType {...}

Which SqlTypeName value should be used for such types? STRUCT?

On 27.04.2021 21:42, Julian Hyde wrote:
> If the type is widely used we could consider supporting it. Which databases have a UUID type? Is there a standard ODBC/JDBC type code for it? Are there any built-in functions that operate on UUIDs?
>
> Another option is to create a user-defined type.
>
> Julian
>   
>
>> On Apr 27, 2021, at 7:04 AM, JiaTao Tao <ta...@gmail.com> wrote:
>>
>> I think the only way is to add your type to SqlTypeName and override
>> RelDataTypeSystem/RelDataTypeFactory if needed
>>
>> Regards!
>>
>> Aron Tao
>>
>>
>> Taras Ledkov <tl...@gridgain.com> 于2021年4月27日周二 下午5:42写道:
>>
>>> Hi all,
>>>
>>> I'm looking for the way to extend SQL types for my engine based on Calcite.
>>> Now calcite doesn't support UUID sql type. This could be fixed by
>>> calcite patch,
>>> but what are the best practices for adding new engine-specific type?
>>>
>>> e.g. I have to introduce new SQL type MY_UUID etc.
>>>
>>> RelDataType is interface but the method RelDataType#getSqlTypeName
>>> returns SqlTypeName enum that is defined by calcite framework.
>>> Are there any extension point for custom  types or it contradicts
>>> calcite architecture an it is not Calcite way?
>>>
>>> Just in case, again:
>>> I mean that under custom SQL types, it is not structured types that are
>>> defined by SQL user, but engine-specific types:
>>> e.g.: blob, image, text, my_blob, my_uuid, json etc...
>>>
>>> --
>>> Taras Ledkov
>>> Mail-To: tledkov@gridgain.com
>>>
>>>
-- 
Taras Ledkov
Mail-To: tledkov@gridgain.com


Re: How to extend SQL type system?

Posted by Julian Hyde <jh...@gmail.com>.
If the type is widely used we could consider supporting it. Which databases have a UUID type? Is there a standard ODBC/JDBC type code for it? Are there any built-in functions that operate on UUIDs?

Another option is to create a user-defined type.

Julian
 

> On Apr 27, 2021, at 7:04 AM, JiaTao Tao <ta...@gmail.com> wrote:
> 
> I think the only way is to add your type to SqlTypeName and override
> RelDataTypeSystem/RelDataTypeFactory if needed
> 
> Regards!
> 
> Aron Tao
> 
> 
> Taras Ledkov <tl...@gridgain.com> 于2021年4月27日周二 下午5:42写道:
> 
>> Hi all,
>> 
>> I'm looking for the way to extend SQL types for my engine based on Calcite.
>> Now calcite doesn't support UUID sql type. This could be fixed by
>> calcite patch,
>> but what are the best practices for adding new engine-specific type?
>> 
>> e.g. I have to introduce new SQL type MY_UUID etc.
>> 
>> RelDataType is interface but the method RelDataType#getSqlTypeName
>> returns SqlTypeName enum that is defined by calcite framework.
>> Are there any extension point for custom  types or it contradicts
>> calcite architecture an it is not Calcite way?
>> 
>> Just in case, again:
>> I mean that under custom SQL types, it is not structured types that are
>> defined by SQL user, but engine-specific types:
>> e.g.: blob, image, text, my_blob, my_uuid, json etc...
>> 
>> --
>> Taras Ledkov
>> Mail-To: tledkov@gridgain.com
>> 
>> 


Re: How to extend SQL type system?

Posted by JiaTao Tao <ta...@gmail.com>.
I think the only way is to add your type to SqlTypeName and override
RelDataTypeSystem/RelDataTypeFactory if needed

Regards!

Aron Tao


Taras Ledkov <tl...@gridgain.com> 于2021年4月27日周二 下午5:42写道:

> Hi all,
>
> I'm looking for the way to extend SQL types for my engine based on Calcite.
> Now calcite doesn't support UUID sql type. This could be fixed by
> calcite patch,
> but what are the best practices for adding new engine-specific type?
>
> e.g. I have to introduce new SQL type MY_UUID etc.
>
> RelDataType is interface but the method RelDataType#getSqlTypeName
> returns SqlTypeName enum that is defined by calcite framework.
> Are there any extension point for custom  types or it contradicts
> calcite architecture an it is not Calcite way?
>
> Just in case, again:
> I mean that under custom SQL types, it is not structured types that are
> defined by SQL user, but engine-specific types:
> e.g.: blob, image, text, my_blob, my_uuid, json etc...
>
> --
> Taras Ledkov
> Mail-To: tledkov@gridgain.com
>
>