Skip to content

Commit

Permalink
For #3032, add missing dcl test cases for select with functions gramm…
Browse files Browse the repository at this point in the history
…ars. (#3076)

* For #3032, add missing dcl test cases for select with functions grammars.

* For #3032, add missing dcl test cases for select with functions grammars 2nd.
  • Loading branch information
haocao authored and terrymanu committed Sep 21, 2019
1 parent b7a2f37 commit f4312c6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
</tokens>
</parser-result>

<parser-result sql-case-id="select_distinct_function" >
<parser-result sql-case-id="select_distinct_function">
<tables>
<table name="t_order_item" />
</tables>
Expand Down Expand Up @@ -1004,7 +1004,7 @@
</column-select-items>
</select-items>
</parser-result>
<parser-result sql-case-id="select_special_function_nested">
<parser-result sql-case-id="select_special_function_nested" parameters="12, 1000">
<tables>
<table name="t_order"/>
</tables>
Expand All @@ -1013,9 +1013,19 @@
</tokens>
<select-items start-index="7" stop-index="29">
<aggregation-select-items>
<aggregation-select-item start-index="7" stop-index="29" type="SUM" text="sum(if(status=0,1,0))" innerExpressionStartIndex="10" />
<aggregation-select-item start-index="7" stop-index="29" type="SUM" text="sum(if(status=0,1,0))" innerExpressionStartIndex="10" alias="func_status" />
</aggregation-select-items>
</select-items>
<sharding-conditions>
<and-condition>
<condition column-name="user_id" table-name="t_order" operator="EQUAL">
<value index="0" literal="12" type="int" />
</condition>
<condition column-name="order_id" table-name="t_order" operator="EQUAL">
<value index="1" literal="1000" type="int" />
</condition>
</and-condition>
</sharding-conditions>
</parser-result>
<parser-result sql-case-id="select_with_row_subquery_without_row_keyword">
<tables>
Expand Down Expand Up @@ -1043,7 +1053,7 @@
</shorthand-select-items>
</select-items>
</parser-result>
<parser-result sql-case-id="select_with_interval_function">
<parser-result sql-case-id="select_with_interval_function" parameters="12, 1000">
<tables>
<table name="t_order"/>
</tables>
Expand All @@ -1052,8 +1062,18 @@
</tokens>
<select-items start-index="7" stop-index="26">
<expression-items>
<expression-item start-index="7" stop-index="26" text="INTERVAL(status,1,5)" alias="inSales" />
<expression-item start-index="7" stop-index="26" text="INTERVAL(status,1,5)" alias="func_status" />
</expression-items>
</select-items>
<sharding-conditions>
<and-condition>
<condition column-name="user_id" table-name="t_order" operator="EQUAL">
<value index="0" literal="12" type="int" />
</condition>
<condition column-name="order_id" table-name="t_order" operator="EQUAL">
<value index="1" literal="1000" type="int" />
</condition>
</and-condition>
</sharding-conditions>
</parser-result>
</parser-result-sets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
~ 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.
-->

<dataset>
<metadata>
<column name="func_status" />
</metadata>
<row values="null" />
</dataset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
~ 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.
-->

<dataset>
<metadata>
<column name="func_status" />
</metadata>
</dataset>
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,12 @@
<dql-test-case sql-case-id="select_distinct_with_count_group_by">
<assertion expected-data-file="select_distinct_with_count_group_by.xml" />
</dql-test-case>

<dql-test-case sql-case-id="select_special_function_nested">
<assertion parameters="12:int, 1000:int" expected-data-file="select_special_function_nested.xml" />
</dql-test-case>

<dql-test-case sql-case-id="select_with_interval_function">
<assertion parameters="12:int, 1000:int" expected-data-file="select_with_interval_function.xml" />
</dql-test-case>
</integrate-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
<sql-case id="select_in_with_geography" value="SELECT * FROM t_order WHERE rule IN (?::jsonb, ?::jsonb) AND start_point=ST_GeographyFromText('SRID=4326;POINT('||?||' '||?||')') AND user_id = ? AND order_id = ?" db-types="PostgreSQL" />
<sql-case id="select_between_with_geography" value="SELECT * FROM t_order WHERE rule BETWEEN ?::jsonb AND ?::jsonb AND start_point=ST_GeographyFromText('SRID=4326;POINT('||?||' '||?||')') AND order_id = ?" db-types="PostgreSQL" />
<sql-case id="select_with_schema" value="SELECT * FROM db1.t_order" />
<sql-case id="select_special_function_nested" value="SELECT sum(if(status=0, 1, 0)) FROM t_order" />
<sql-case id="select_special_function_nested" value="SELECT sum(if(status=0, 1, 0)) func_status FROM t_order WHERE user_id = ? AND order_id = ?" db-types="MySQL" />
<sql-case id="select_with_row_subquery_without_row_keyword" value="SELECT * FROM t_order WHERE (user_id,order_id) = (SELECT user_id,order_id FROM t_order_item WHERE id = 10)" db-types="MySQL" />
<sql-case id="select_with_row_subquery" value="SELECT * FROM t_order WHERE ROW(user_id,order_id) = (SELECT user_id,order_id FROM t_order_item WHERE id = 10)" db-types="MySQL" />
<sql-case id="select_with_interval_function" value="SELECT INTERVAL(status,1,5) inSales FROM t_order" db-types="MySQL" />
<sql-case id="select_with_interval_function" value="SELECT INTERVAL(status,1,5) func_status FROM t_order WHERE user_id = ? AND order_id = ?" db-types="MySQL" />
</sql-cases>

0 comments on commit f4312c6

Please sign in to comment.