Skip to content

Commit

Permalink
Add more sql bind test case for delete and update statement (#34150)
Browse files Browse the repository at this point in the history
  • Loading branch information
strongduanmu authored Dec 25, 2024
1 parent 3ca4a31 commit f4afcc3
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
61 changes: 61 additions & 0 deletions test/it/binder/src/test/resources/cases/dml/delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<sql-parser-test-cases>
<delete sql-case-id="delete_order_by">
<table name="t_order" start-index="12" stop-index="18">
<table-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
</table-bound>
</table>
<where start-index="20" stop-index="37">
<expr>
<binary-operation-expression start-index="26" stop-index="37">
<left>
<column name="order_id" start-index="26" stop-index="33">
<column-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
<original-table name="t_order" />
<original-column name="order_id" start-delimiter="`" end-delimiter="`" />
</column-bound>
</column>
</left>
<operator>=</operator>
<right>
<literal-expression value="1" start-index="37" stop-index="37" />
</right>
</binary-operation-expression>
</expr>
</where>
<order-by>
<column-item name="user_id" start-index="48" stop-index="54">
<column-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
<original-table name="t_order" />
<original-column name="user_id" start-delimiter="`" end-delimiter="`" />
</column-bound>
</column-item>
</order-by>
<limit start-index="56" stop-index="62">
<row-count value="1" start-index="62" stop-index="62" />
</limit>
</delete>
</sql-parser-test-cases>
78 changes: 78 additions & 0 deletions test/it/binder/src/test/resources/cases/dml/update.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<sql-parser-test-cases>
<update sql-case-id="update_order_by">
<table start-index="7" stop-index="13">
<simple-table name="t_order" start-index="7" stop-index="13">
<table-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
</table-bound>
</simple-table>
</table>
<set start-index="15" stop-index="29">
<assignment start-index="19" stop-index="29">
<column name="user_id" start-index="19" stop-index="25">
<column-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
<original-table name="t_order" />
<original-column name="user_id" start-delimiter="`" end-delimiter="`" />
</column-bound>
</column>
<assignment-value>
<literal-expression value="1" start-index="29" stop-index="29" />
</assignment-value>
</assignment>
</set>
<where start-index="31" stop-index="48">
<expr>
<binary-operation-expression start-index="37" stop-index="48">
<left>
<column name="order_id" start-index="37" stop-index="44">
<column-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
<original-table name="t_order" />
<original-column name="order_id" start-delimiter="`" end-delimiter="`" />
</column-bound>
</column>
</left>
<operator>=</operator>
<right>
<literal-expression value="1" start-index="48" stop-index="48" />
</right>
</binary-operation-expression>
</expr>
</where>
<order-by>
<column-item name="user_id" start-index="59" stop-index="65">
<column-bound>
<original-database name="foo_db_1" />
<original-schema name="foo_db_1" />
<original-table name="t_order" />
<original-column name="user_id" start-delimiter="`" end-delimiter="`" />
</column-bound>
</column-item>
</order-by>
<limit start-index="67" stop-index="73">
<row-count value="1" start-index="73" stop-index="73" />
</limit>
</update>
</sql-parser-test-cases>
21 changes: 21 additions & 0 deletions test/it/binder/src/test/resources/sqls/dml/delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<sql-cases>
<sql-case id="delete_order_by" value="DELETE FROM t_order WHERE order_id = 1 ORDER BY user_id LIMIT 1" db-types="MySQL"/>
</sql-cases>
21 changes: 21 additions & 0 deletions test/it/binder/src/test/resources/sqls/dml/update.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<sql-cases>
<sql-case id="update_order_by" value="UPDATE t_order SET user_id = 1 WHERE order_id = 1 ORDER BY user_id LIMIT 1" db-types="MySQL"/>
</sql-cases>

0 comments on commit f4afcc3

Please sign in to comment.