select-sub-query.xml 8.5 KB
Newer Older
1
<?xml version="1.0" encoding="UTF-8"?>
T
tuohai666 已提交
2
<!--
3 4 5 6 7 8 9 10 11 12 13 14 15 16
  ~ 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.
T
tuohai666 已提交
17 18
  -->

19
<sql-parser-test-cases>
20
    <!-- TODO cannot pass,add later 
21
    <select sql-case-id="select_sub_query_with_multiple_tables" parameters="1, 2">
22 23
        <table name="t_order" alias="o" start-index="33" stop-index="39" />
        <table name="t_order_item" alias="i" start-index="44" stop-index="55" />
24 25 26 27 28 29
        <conditions>
            <condition column-name="order_id" table-name="t_order" operator="IN">
                <value index="0" literal="1" type="int" />
                <value index="1" literal="2" type="int" />
            </condition>
        </conditions>
30
    </select>
31
    -->
32
    
33
    <!-- TODO Can not support subquery at current
34
    <select sql-case-id="select_sub_query_with_order_by">
35
        <table name="t_order" start-index="52" stop-index="58" />
36 37 38 39
        <projections start-index="45" stop-index="45">
            <aggregation-projection type="COUNT" alias="orders_count" />
            <shorthand-projection start-index="45" stop-index="45" />
        </projections>
40
    </select>
T
terrymanu 已提交
41
    
42
    <select sql-case-id="select_sub_query_with_group_by">
43
        <table name="t_order_item" start-index="64" stop-index="75" />
44
        <projections start-index="50" stop-index="57">
45
            <column-projection name="order_id" start-index="50" stop-index="57" />
46
        </projections>
47
    </select>
48
    -->
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166

<!--    <select sql-case-id="select_sub_query_with_table" parameters="1, 2">-->
<!--        <table name="t_order" alias="o" start-index="33" stop-index="39" />-->
<!--        <conditions>-->
<!--            <condition column-name="order_id" table-name="t_order" operator="IN">-->
<!--                <value index="0" literal="1" type="int" />-->
<!--                <value index="1" literal="2" type="int" />-->
<!--            </condition>-->
<!--        </conditions>-->
<!--    </select>-->
    
    <select sql-case-id="select_with_equal_subquery">
        <table name="t_order" start-index="14" stop-index="20" />
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
        <where start-index="22" stop-index="85">
            <and-predicate>
                <predicate start-index="28" literal-stop-index="85">
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
                    <operator type="=" />
                    <compare-right-value>
                        <subquery>
                            <select>
                                <table name="t_order_item" start-index="59" stop-index="70" />
                                <projections start-index="46" stop-index="52">
                                    <column-projection name="user_id" start-index="46" stop-index="52" />
                                </projections>
                                <where start-index="72" stop-index="85">
                                    <and-predicate>
                                        <predicate start-index="78" literal-stop-index="84">
                                            <column-left-value name="id" start-index="78" stop-index="79"  />
                                            <operator type="=" />
                                            <compare-right-value>
                                                <literal-expression value="10" />
                                            </compare-right-value>
                                        </predicate>
                                    </and-predicate>
                                </where>
                            </select>
                        </subquery>
                    </compare-right-value>
                </predicate>
            </and-predicate>
        </where>
    </select>
    
    <select sql-case-id="select_with_in_subquery">
        <table name="t_order" start-index="14" stop-index="20" />
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
        <where start-index="22" stop-index="93">
            <and-predicate>
                <predicate start-index="28" literal-stop-index="93">
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
                    <in-right-value>
                        <subquery>
                            <select>
                                <table name="t_order_item" start-index="60" stop-index="71" />
                                <projections start-index="47" stop-index="53">
                                    <column-projection name="user_id" start-index="47" stop-index="53" />
                                </projections>
                                <where start-index="73" stop-index="92">
                                    <and-predicate>
                                        <predicate start-index="79" literal-stop-index="92">
                                            <column-left-value name="id" start-index="79" stop-index="80"  />
                                            <in-right-value>
                                                <literal-expression value="10" />
                                                <literal-expression value="11" />
                                            </in-right-value>
                                        </predicate>
                                    </and-predicate>
                                </where>
                            </select>
                        </subquery>
                    </in-right-value>
                </predicate>
            </and-predicate>
        </where>
    </select>

        <select sql-case-id="select_with_between_subquery" parameters="12">
            <table name="t_order" start-index="14" stop-index="20" />
            <projections start-index="7" stop-index="7">
                <shorthand-projection start-index="7" stop-index="7" />
            </projections>
            <where start-index="22" stop-index="106">
            <and-predicate>
                <predicate start-index="28" stop-index="103" literal-stop-index="104">
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
                    <between-right-value>
                        <between-subquery>
                            <select>
                                <table name="t_order_item" start-index="65" stop-index="76" />
                                <projections start-index="52" stop-index="58">
                                    <column-projection name="user_id" start-index="52" stop-index="58" />
                                </projections>
                                <where start-index="78" stop-index="96">
                                    <and-predicate>
                                        <predicate start-index="84" stop-index="96" literal-stop-index="96">
                                            <column-left-value name="order_id" start-index="84" stop-index="91"  />
                                            <operator type="=" />
                                            <compare-right-value>
                                                <literal-expression value="10" />
                                            </compare-right-value>
                                        </predicate>
                                    </and-predicate>
                                </where>
                            </select>
                        </between-subquery>
                        <and-parameter-marker-expression value="0" />
                        <and-literal-expression value="12" />
                    </between-right-value>
                </predicate>
            </and-predicate>
        </where>
        </select>
167
</sql-parser-test-cases>