Skip to content

Commit

Permalink
For apache#3032, add missing dcl test cases for select with functions…
Browse files Browse the repository at this point in the history
… grammars.
  • Loading branch information
haocao committed Sep 20, 2019
1 parent 075ce38 commit 36c933f
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -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 expected-data-file="select_special_function_nested.xml" />
</dql-test-case>

<dql-test-case sql-case-id="select_with_interval_function">
<assertion 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 = 12 AND order_id = 1000" 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 = 12 AND order_id = 1000" db-types="MySQL" />
</sql-cases>

0 comments on commit 36c933f

Please sign in to comment.