You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by 许伟栋 <xw...@gmail.com> on 2021/12/08 03:50:49 UTC

sqlnode design question

Hi, All:

I'm new to calcite, have some doubts about the SqlNode design:

I'm working on a mysql middleware which needs parsing and query
optimization.
Unfortunately, I'm using C++, so it's not trivial to use Calcite directly.

Instead, I'm trying to mimic what Calcite does to see if I can come up with
an MVP.

Right now, I got the CST from Antlr4, and I'm about to visit the CST to
generate AST.
When I look at SqlNode in Calcite, I found that a common segment like table
from select statement is also the type of SqlNode.
In other implementations, it's normally the concrete type like
`TableSegment`.
I was wondering what's the purpose behind the structure design?

Thanks in advance.

Re: sqlnode design question

Posted by Stamatis Zampetakis <za...@gmail.com>.
Hi,

Many people integrating Calcite with C++ or other languages opt to do so by
serializing/deserializing plans to JSON (see discussion [1] for example).

Before reimplementing part of Calcite in another language it may make sense
to look if you can achieve the desired result in a different way.

Best,
Stamatis

[1] https://lists.apache.org/thread/yd5lqls6pxfn7q1m0r2onbj3x4wvohln

On Wed, Dec 8, 2021 at 7:37 PM 许伟栋 <xw...@gmail.com> wrote:

> Hi, All:
>
> I'm new to calcite, have some doubts about the SqlNode design:
>
> I'm working on a mysql middleware which needs parsing and query
> optimization.
> Unfortunately, I'm using C++, so it's not trivial to use Calcite directly.
>
> Instead, I'm trying to mimic what Calcite does to see if I can come up with
> an MVP.
>
> Right now, I got the CST from Antlr4, and I'm about to visit the CST to
> generate AST.
> When I look at SqlNode in Calcite, I found that a common segment like table
> from select statement is also the type of SqlNode.
> In other implementations, it's normally the concrete type like
> `TableSegment`.
> I was wondering what's the purpose behind the structure design?
>
> Thanks in advance.
>