You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by David Valenzuela Rodriguez <da...@groupon.com.INVALID> on 2020/03/26 21:01:02 UTC

Parsing Teradata SQL with Apache Calcite

Hi!

I'm currently evaluating the Apache Calcite framework for the purposes of
parsing Teradata SQL. As far as I can tell, this is accomplished by
defining a SqlOperatorTable with TD-specific operators. Other than that,
I'm not really sure how to integrate that SqlOperatorTable into the
Parser/Planner. Are there any guidelines or examples of this? I haven't
really seen this, but I assume this is not something new.

Thanks in advance!

-- 
David Valenzuela
Software Engineer | Data & Discovery | GROUPON
mobile 425.614.5243
davidvr@groupon.com

Re: Parsing Teradata SQL with Apache Calcite

Posted by Danny Chan <yu...@gmail.com>.
If you only want to add some extension operators for TD, modify SqlLibraryOperators.java is okey.

If you also want to interact with TD through JDBC connection, a TD SqlDialect may also need to be introduced.

Best,
Danny Chan
在 2020年3月28日 +0800 PM5:32,David Valenzuela Rodriguez <da...@groupon.com.invalid>,写道:
> Hi,
>
> In order to define the TD library, it looks like I'd basically need to
> modify the following:
>
> -
> https://github.com/apache/calcite/blob/888dd3a7d20ad04b22434f16d96177b7ca2c28aa/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
> -
> https://github.com/apache/calcite/blob/52a57078ba081b24b9d086ed363c715485d1a519/core/src/main/java/org/apache/calcite/sql/fun/SqlLibrary.java
>
>
> Is that accurate?
>
> Thanks!
> David
>
> On Thu, Mar 26, 2020 at 5:13 PM David Valenzuela Rodriguez <
> davidvr@groupon.com> wrote:
>
> > Awesome, thanks!
> >
> > David
> >
> > On Thu, Mar 26, 2020 at 4:02 PM Julian Hyde <jh...@apache.org> wrote:
> >
> > > There are a few related concepts that make up the general idea of
> > > "dialect":
> > > * *dialect* determines how the JDBC adapter convert SqlNodes to SQL
> > > (e.g. generate "LIMIT 5" or "FETCH 5 ROWS")
> > > * *conformance* determines what features the validator will allow
> > > (e.g. does "GROUP BY 1" mean group by the first field or the literal
> > > 1)
> > > * *parserConfig* parameters control the parser, for example
> > > identifiers (quoted using brackets, or back-ticks or double-quotes),
> > > and how it treats the case of quoted and unquoted identifiers
> > > * *library* is a set of built-in functions. For example, you might
> > > want to use standard SQL functions plus Oracle's function set (e.g.
> > > DECODE)
> > > * *type system* determines things such as what is the maximum length
> > > of a VARCHAR value
> > >
> > > These are intentionally kept separate in the code. We built a bridge
> > > between dialect parserConfig in
> > > https://issues.apache.org/jira/browse/CALCITE-3050. It's worth reading
> > > that issue for the back-story.
> > >
> > > To parse Teradata SQL, you probably need to create a library (for
> > > functions) and a conformance. Maybe a new constant Lex.TERADATA.
> > >
> > > Julian
> > >
> > >
> > > If you want to parse Tera
> > >
> > > On Thu, Mar 26, 2020 at 3:44 PM David Valenzuela Rodriguez
> > > <da...@groupon.com.invalid> wrote:
> > > >
> > > > Hi!
> > > >
> > > > I'm currently evaluating the Apache Calcite framework for the purposes
> > > of
> > > > parsing Teradata SQL. As far as I can tell, this is accomplished by
> > > > defining a SqlOperatorTable with TD-specific operators. Other than that,
> > > > I'm not really sure how to integrate that SqlOperatorTable into the
> > > > Parser/Planner. Are there any guidelines or examples of this? I haven't
> > > > really seen this, but I assume this is not something new.
> > > >
> > > > Thanks in advance!
> > > >
> > > > --
> > > > David Valenzuela
> > > > Software Engineer | Data & Discovery | GROUPON
> > > > mobile 425.614.5243
> > > > davidvr@groupon.com
> > >
> >
> >
> > --
> > David Valenzuela
> > Software Engineer | Data & Discovery | GROUPON
> > mobile 425.614.5243
> > davidvr@groupon.com
> >
>
>
> --
> David Valenzuela
> Software Engineer | Data & Discovery | GROUPON
> mobile 425.614.5243
> davidvr@groupon.com

Re: Parsing Teradata SQL with Apache Calcite

Posted by David Valenzuela Rodriguez <da...@groupon.com.INVALID>.
Hi,

In order to define the TD library, it looks like I'd basically need to
modify the following:

   -
   https://github.com/apache/calcite/blob/888dd3a7d20ad04b22434f16d96177b7ca2c28aa/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java
   -
   https://github.com/apache/calcite/blob/52a57078ba081b24b9d086ed363c715485d1a519/core/src/main/java/org/apache/calcite/sql/fun/SqlLibrary.java


Is that accurate?

Thanks!
David

On Thu, Mar 26, 2020 at 5:13 PM David Valenzuela Rodriguez <
davidvr@groupon.com> wrote:

> Awesome, thanks!
>
> David
>
> On Thu, Mar 26, 2020 at 4:02 PM Julian Hyde <jh...@apache.org> wrote:
>
>> There are a few related concepts that make up the general idea of
>> "dialect":
>> * *dialect* determines how the JDBC adapter convert SqlNodes to SQL
>> (e.g. generate "LIMIT 5" or "FETCH 5 ROWS")
>> * *conformance* determines what features the validator will allow
>> (e.g. does "GROUP BY 1" mean group by the first field or the literal
>> 1)
>> * *parserConfig* parameters control the parser, for example
>> identifiers (quoted using brackets, or back-ticks or double-quotes),
>> and how it treats the case of quoted and unquoted identifiers
>> * *library* is a set of built-in functions. For example, you might
>> want to use standard SQL functions plus Oracle's function set (e.g.
>> DECODE)
>> * *type system* determines things such as what is the maximum length
>> of a VARCHAR value
>>
>> These are intentionally kept separate in the code. We built a bridge
>> between dialect parserConfig in
>> https://issues.apache.org/jira/browse/CALCITE-3050. It's worth reading
>> that issue for the back-story.
>>
>> To parse Teradata SQL, you probably need to create a library (for
>> functions) and a conformance. Maybe a new constant Lex.TERADATA.
>>
>> Julian
>>
>>
>> If you want to parse Tera
>>
>> On Thu, Mar 26, 2020 at 3:44 PM David Valenzuela Rodriguez
>> <da...@groupon.com.invalid> wrote:
>> >
>> > Hi!
>> >
>> > I'm currently evaluating the Apache Calcite framework for the purposes
>> of
>> > parsing Teradata SQL. As far as I can tell, this is accomplished by
>> > defining a SqlOperatorTable with TD-specific operators. Other than that,
>> > I'm not really sure how to integrate that SqlOperatorTable into the
>> > Parser/Planner. Are there any guidelines or examples of this? I haven't
>> > really seen this, but I assume this is not something new.
>> >
>> > Thanks in advance!
>> >
>> > --
>> > David Valenzuela
>> > Software Engineer | Data & Discovery | GROUPON
>> > mobile 425.614.5243
>> > davidvr@groupon.com
>>
>
>
> --
> David Valenzuela
> Software Engineer | Data & Discovery | GROUPON
> mobile 425.614.5243
> davidvr@groupon.com
>


-- 
David Valenzuela
Software Engineer | Data & Discovery | GROUPON
mobile 425.614.5243
davidvr@groupon.com

Re: Parsing Teradata SQL with Apache Calcite

Posted by David Valenzuela Rodriguez <da...@groupon.com.INVALID>.
Awesome, thanks!

David

On Thu, Mar 26, 2020 at 4:02 PM Julian Hyde <jh...@apache.org> wrote:

> There are a few related concepts that make up the general idea of
> "dialect":
> * *dialect* determines how the JDBC adapter convert SqlNodes to SQL
> (e.g. generate "LIMIT 5" or "FETCH 5 ROWS")
> * *conformance* determines what features the validator will allow
> (e.g. does "GROUP BY 1" mean group by the first field or the literal
> 1)
> * *parserConfig* parameters control the parser, for example
> identifiers (quoted using brackets, or back-ticks or double-quotes),
> and how it treats the case of quoted and unquoted identifiers
> * *library* is a set of built-in functions. For example, you might
> want to use standard SQL functions plus Oracle's function set (e.g.
> DECODE)
> * *type system* determines things such as what is the maximum length
> of a VARCHAR value
>
> These are intentionally kept separate in the code. We built a bridge
> between dialect parserConfig in
> https://issues.apache.org/jira/browse/CALCITE-3050. It's worth reading
> that issue for the back-story.
>
> To parse Teradata SQL, you probably need to create a library (for
> functions) and a conformance. Maybe a new constant Lex.TERADATA.
>
> Julian
>
>
> If you want to parse Tera
>
> On Thu, Mar 26, 2020 at 3:44 PM David Valenzuela Rodriguez
> <da...@groupon.com.invalid> wrote:
> >
> > Hi!
> >
> > I'm currently evaluating the Apache Calcite framework for the purposes of
> > parsing Teradata SQL. As far as I can tell, this is accomplished by
> > defining a SqlOperatorTable with TD-specific operators. Other than that,
> > I'm not really sure how to integrate that SqlOperatorTable into the
> > Parser/Planner. Are there any guidelines or examples of this? I haven't
> > really seen this, but I assume this is not something new.
> >
> > Thanks in advance!
> >
> > --
> > David Valenzuela
> > Software Engineer | Data & Discovery | GROUPON
> > mobile 425.614.5243
> > davidvr@groupon.com
>


-- 
David Valenzuela
Software Engineer | Data & Discovery | GROUPON
mobile 425.614.5243
davidvr@groupon.com

Re: Parsing Teradata SQL with Apache Calcite

Posted by Julian Hyde <jh...@apache.org>.
There are a few related concepts that make up the general idea of "dialect":
* *dialect* determines how the JDBC adapter convert SqlNodes to SQL
(e.g. generate "LIMIT 5" or "FETCH 5 ROWS")
* *conformance* determines what features the validator will allow
(e.g. does "GROUP BY 1" mean group by the first field or the literal
1)
* *parserConfig* parameters control the parser, for example
identifiers (quoted using brackets, or back-ticks or double-quotes),
and how it treats the case of quoted and unquoted identifiers
* *library* is a set of built-in functions. For example, you might
want to use standard SQL functions plus Oracle's function set (e.g.
DECODE)
* *type system* determines things such as what is the maximum length
of a VARCHAR value

These are intentionally kept separate in the code. We built a bridge
between dialect parserConfig in
https://issues.apache.org/jira/browse/CALCITE-3050. It's worth reading
that issue for the back-story.

To parse Teradata SQL, you probably need to create a library (for
functions) and a conformance. Maybe a new constant Lex.TERADATA.

Julian


If you want to parse Tera

On Thu, Mar 26, 2020 at 3:44 PM David Valenzuela Rodriguez
<da...@groupon.com.invalid> wrote:
>
> Hi!
>
> I'm currently evaluating the Apache Calcite framework for the purposes of
> parsing Teradata SQL. As far as I can tell, this is accomplished by
> defining a SqlOperatorTable with TD-specific operators. Other than that,
> I'm not really sure how to integrate that SqlOperatorTable into the
> Parser/Planner. Are there any guidelines or examples of this? I haven't
> really seen this, but I assume this is not something new.
>
> Thanks in advance!
>
> --
> David Valenzuela
> Software Engineer | Data & Discovery | GROUPON
> mobile 425.614.5243
> davidvr@groupon.com