[jira] [Commented] (CALCITE-2310) SqlParser parse multiple sql statements split by semicolon

2018-05-22 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16484320#comment-16484320
 ] 

Julian Hyde commented on CALCITE-2310:
--

The reason I suggest BEGIN ... END is so that the parser knows which syntactic 
construct is coming up. A block (sequence of statements) could even be a kind 
of statement; without BEGIN, a sequence of statements could never be a kind of 
statement.

> SqlParser parse multiple sql statements split by semicolon
> --
>
> Key: CALCITE-2310
> URL: https://issues.apache.org/jira/browse/CALCITE-2310
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Minor
>
> Current, SqlParser only supports parse single sql statement to single 
> SqlNode. But since we have server module, and support DDL syntax, It is 
> common to write DDL statement and DML statement together to build a complete 
> logic. 
> For example:
>  * Table orders is a source table;
>  * Table output_console is a sink table;
>  * Read data from source table, do some project and filter, then write to 
> sink table. 
> {code:java}
> CREATE TABLE orders (
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> ); 
> CREATE TABLE output_console(
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> );
> INSERT INTO output_console
> SELECT
>  createTime,
>  productId,
>  orderId,
>  units,
>  user_name
> FROM orders
> WHERE (productId>3) AND (productId<8);
> {code}
> So, I think it really helps if SqlParser support parse multiple sql 
> statements.
>  
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2310) SqlParser parse multiple sql statements split by semicolon

2018-05-15 Thread Fei Xu (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16476787#comment-16476787
 ] 

Fei Xu commented on CALCITE-2310:
-

Put this extension to 'server' module is OK. But do you think we really need 
add BEGIN and ENG for parse a block ? cause single statement can be a special 
case of sequences statements, e.g. 
{code:java}
/**
 * Parses Sequences SQL statement followed by the end-of-file symbol.
 */
List seqSqlStmtEof() :
{
List list = new ArrayList();
SqlNode stmt;
}
{
stmt = SqlStmt() { list.add(stmt); }
(  stmt = SqlStmt() {list.add(stmt);} ) *
[  ]

{
return list;
}
}
{code}

> SqlParser parse multiple sql statements split by semicolon
> --
>
> Key: CALCITE-2310
> URL: https://issues.apache.org/jira/browse/CALCITE-2310
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Minor
>
> Current, SqlParser only supports parse single sql statement to single 
> SqlNode. But since we have server module, and support DDL syntax, It is 
> common to write DDL statement and DML statement together to build a complete 
> logic. 
> For example:
>  * Table orders is a source table;
>  * Table output_console is a sink table;
>  * Read data from source table, do some project and filter, then write to 
> sink table. 
> {code:java}
> CREATE TABLE orders (
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> ); 
> CREATE TABLE output_console(
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> );
> INSERT INTO output_console
> SELECT
>  createTime,
>  productId,
>  orderId,
>  units,
>  user_name
> FROM orders
> WHERE (productId>3) AND (productId<8);
> {code}
> So, I think it really helps if SqlParser support parse multiple sql 
> statements.
>  
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2310) SqlParser parse multiple sql statements split by semicolon

2018-05-15 Thread Julian Hyde (JIRA)

[ 
https://issues.apache.org/jira/browse/CALCITE-2310?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16476459#comment-16476459
 ] 

Julian Hyde commented on CALCITE-2310:
--

Makes sense. It would need to be in the "server" or "babel" parser, because the 
regular parser does not support DDL.

Sequences of statements begin to look like PL/SQL. So, should we instead parse 
a block:

{code}
BEGIN
  statement;
  ...
  statement;
END
{code}

You can add BEGIN and END before parsing.

> SqlParser parse multiple sql statements split by semicolon
> --
>
> Key: CALCITE-2310
> URL: https://issues.apache.org/jira/browse/CALCITE-2310
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Minor
>
> Current, SqlParser only supports parse single sql statement to single 
> SqlNode. But since we have server module, and support DDL syntax, It is 
> common to write DDL statement and DML statement together to build a complete 
> logic. 
> For example:
>  * Table orders is a source table;
>  * Table output_console is a sink table;
>  * Read data from source table, do some project and filter, then write to 
> sink table. 
> {code:java}
> CREATE TABLE orders (
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> ); 
> CREATE TABLE output_console(
>  createTime TIMESTAMP,
>  productId bigint,
>  orderId bigint,
>  units bigint,
>  user_name VARCHAR
> );
> INSERT INTO output_console
> SELECT
>  createTime,
>  productId,
>  orderId,
>  units,
>  user_name
> FROM orders
> WHERE (productId>3) AND (productId<8);
> {code}
> So, I think it really helps if SqlParser support parse multiple sql 
> statements.
>  
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)