[ 
https://issues.apache.org/jira/browse/CALCITE-5835?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ankit Siva updated CALCITE-5835:
--------------------------------
    Description: 
I've set up a parser as follows:

{{val config= SqlParser.config()
    .withConformance(SqlConformanceEnum.BABEL)
    .withQuoting(Quoting.DOUBLE_QUOTE)
    .withQuotedCasing(Casing.TO_LOWER)
    .withUnquotedCasing(Casing.TO_LOWER)
    .withCaseSensitive(false)

val parser = SqlParser.create(sql, config)
parser.parseQuery()}}

 I am parsing the following statements:

1.
{{INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, 
Country) 
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 
'Norway')}}

2. 
{{INSERT INTO emps (emp_id , emp_name , emp_salary)
SELECT employee_id , last_name , salary
FROM   employees
WHERE  department_id = 50}}

3.
{{UPDATE employees
SET salary = 5000
WHERE employee_id = 100}}

4.
{{DELETE FROM employees
WHERE department_id = (
    SELECT department_id FROM departments
    WHERE department_name = 'Sales'
)}}

5.
{{MERGE INTO  customers_backup bkup
USING       customers cust
ON         (bkup.cust_id = cust.cust_id)
WHEN MATCHED THEN
UPDATE SET
bkup.cust_name = cust.cust_name ,
bkup.cust_surfing_package = cust.cust_surfing_package
WHEN NOT MATCHED THEN
INSERT VALUES(cust.cust_id , cust.cust_name , cust.cust_surfing_package)}}

Parsing any of these queries does not raise a `SqlParseException`. 
Additionally, these return nodes that are not of type {{SqlSelect}} or 
{{SqlBinaryOperator}}. This conflicts with the expectation of the method and 
the contract declared in the 
[javadoc](https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/parser/SqlParser.html#parseQuery())


  was:
I've set up a parser as follows:
```
val config= SqlParser.config()
    .withConformance(SqlConformanceEnum.BABEL)
    .withQuoting(Quoting.DOUBLE_QUOTE)
    .withQuotedCasing(Casing.TO_LOWER)
    .withUnquotedCasing(Casing.TO_LOWER)
    .withCaseSensitive(false)

val parser = SqlParser.create(sql, config)
parser.parseQuery()
```
 I am parsing the following statements:
```
1.
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, 
Country) 
VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 
'Norway')

2. 
INSERT INTO emps (emp_id , emp_name , emp_salary)
SELECT employee_id , last_name , salary
FROM   employees
WHERE  department_id = 50

3.
UPDATE employees
SET salary = 5000
WHERE employee_id = 100

4.
DELETE FROM employees
WHERE department_id = (
    SELECT department_id FROM departments
    WHERE department_name = 'Sales'
)

5.
MERGE INTO  customers_backup bkup
USING       customers cust
ON         (bkup.cust_id = cust.cust_id)
WHEN MATCHED THEN
UPDATE SET
bkup.cust_name = cust.cust_name ,
bkup.cust_surfing_package = cust.cust_surfing_package
WHEN NOT MATCHED THEN
INSERT VALUES(cust.cust_id , cust.cust_name , cust.cust_surfing_package)
```

Parsing any of these queries does not raise a `SqlParseException`. 
Additionally, these return nodes that are not of type `SqlSelect` or 
`SqlBinaryOperator`. This conflicts with the expectation of the method and the 
contract declared in the 
[javadoc](https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/parser/SqlParser.html#parseQuery())



> SqlParser.parseQuery() successfully parses DML and DDL statements without 
> throwing a SqlParseException
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-5835
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5835
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.34.0
>            Reporter: Ankit Siva
>            Priority: Major
>
> I've set up a parser as follows:
> {{val config= SqlParser.config()
>     .withConformance(SqlConformanceEnum.BABEL)
>     .withQuoting(Quoting.DOUBLE_QUOTE)
>     .withQuotedCasing(Casing.TO_LOWER)
>     .withUnquotedCasing(Casing.TO_LOWER)
>     .withCaseSensitive(false)
> val parser = SqlParser.create(sql, config)
> parser.parseQuery()}}
>  I am parsing the following statements:
> 1.
> {{INSERT INTO Customers (CustomerName, ContactName, Address, City, 
> PostalCode, Country) 
> VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 
> 'Norway')}}
> 2. 
> {{INSERT INTO emps (emp_id , emp_name , emp_salary)
> SELECT employee_id , last_name , salary
> FROM   employees
> WHERE  department_id = 50}}
> 3.
> {{UPDATE employees
> SET salary = 5000
> WHERE employee_id = 100}}
> 4.
> {{DELETE FROM employees
> WHERE department_id = (
>     SELECT department_id FROM departments
>     WHERE department_name = 'Sales'
> )}}
> 5.
> {{MERGE INTO  customers_backup bkup
> USING       customers cust
> ON         (bkup.cust_id = cust.cust_id)
> WHEN MATCHED THEN
> UPDATE SET
> bkup.cust_name = cust.cust_name ,
> bkup.cust_surfing_package = cust.cust_surfing_package
> WHEN NOT MATCHED THEN
> INSERT VALUES(cust.cust_id , cust.cust_name , cust.cust_surfing_package)}}
> Parsing any of these queries does not raise a `SqlParseException`. 
> Additionally, these return nodes that are not of type {{SqlSelect}} or 
> {{SqlBinaryOperator}}. This conflicts with the expectation of the method and 
> the contract declared in the 
> [javadoc](https://calcite.apache.org/javadocAggregate/org/apache/calcite/sql/parser/SqlParser.html#parseQuery())



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to