select.xml 71.0 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 20
<sql-parser-test-cases>
    <select sql-case-id="select_constant_without_table" >
21
        <projections start-index="7" stop-index="12">
22
            <expression-projection alias="a" start-index="7" stop-index="12" />
23
        </projections>
24
    </select>
T
terrymanu 已提交
25
    
26
    <select sql-case-id="select_with_same_table_name_and_alias" parameters="1, 1">
27
        <table name="t_order" alias="t_order" start-index="22" stop-index="28" />
28 29 30 31 32
        <projections start-index="7" stop-index="15">
            <shorthand-projection start-index="7" stop-index="15">
                <owner name="t_order" start-index="7" stop-index="13" />
            </shorthand-projection>
        </projections>
33
        <where start-index="38" stop-index="71">
34 35
            <and-predicate>
                <predicate start-index="44" stop-index="54">
36
                    <column-left-value name="user_id" start-index="44" stop-index="50" />
37 38 39 40 41
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
42 43
                </predicate>
                <predicate start-index="60" stop-index="71">
44
                    <column-left-value name="order_id" start-index="60" stop-index="67" />
45 46 47 48 49
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                    </compare-right-value>
50 51 52
                </predicate>
            </and-predicate>
        </where>
53
    </select>
C
codefairy08 已提交
54
    
55
    <select sql-case-id="select_with_same_table_name_and_alias_column_with_owner" parameters="1, 1">
56
        <table name="t_order" alias="t_order" start-index="52" stop-index="58" />
57 58 59 60 61 62 63 64 65
        <projections start-index="7" stop-index="45">
            <column-projection name="order_id" start-index="7" stop-index="22">
                <owner name="t_order" start-index="7" stop-index="13" />
            </column-projection>
            <column-projection name="user_id" start-index="24" stop-index="38">
                <owner name="t_order" start-index="24" stop-index="30" />
            </column-projection>
            <column-projection name="status" start-index="40" stop-index="45" />
        </projections>
66
        <where start-index="68" stop-index="109">
67 68
            <and-predicate>
                <predicate start-index="74" stop-index="92">
69
                    <column-left-value name="user_id" start-index="74" stop-index="88">
70
                        <owner name="t_order" start-index="74" stop-index="80" />
71
                    </column-left-value>
72 73 74 75 76
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
77 78
                </predicate>
                <predicate start-index="98" stop-index="109">
79
                    <column-left-value name="order_id" start-index="98" stop-index="105" />
80 81 82 83 84
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                    </compare-right-value>
85 86 87
                </predicate>
            </and-predicate>
        </where>
88
    </select>
T
terrymanu 已提交
89
    
90
    <select sql-case-id="select_not_equal_with_single_table" parameters="1">
91
        <table name="t_order_item" start-index="14" stop-index="25" />
92 93 94
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
95
        <where start-index="27" stop-index="44">
96 97
            <and-predicate>
                <predicate start-index="33" stop-index="44">
98
                    <column-left-value name="item_id" start-index="33" stop-index="39" />
99 100 101 102 103
                    <operator type="&lt;&gt;" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
104 105 106
                </predicate>
            </and-predicate>
        </where>
107 108 109
        <order-by>
            <column-item name="item_id" />
        </order-by>
110
    </select>
T
terrymanu 已提交
111
    
112
    <select sql-case-id="select_exclamation_equal_with_single_table" parameters="1">
113
        <table name="t_order_item" start-index="14" stop-index="25" />
114 115 116
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
117
        <where start-index="27" stop-index="44">
118 119
            <and-predicate>
                <predicate start-index="33" stop-index="44">
120
                    <column-left-value name="item_id" start-index="33" stop-index="39" />
121 122 123 124 125
                    <operator type="!=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
126 127 128
                </predicate>
            </and-predicate>
        </where>
129 130 131
        <order-by>
            <column-item name="item_id" />
        </order-by>
132
    </select>
T
terrymanu 已提交
133
    
134
    <select sql-case-id="select_not_in_with_single_table" parameters="100000, 100001">
135
        <table name="t_order_item" start-index="14" stop-index="25" />
136 137 138
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
139
        <where start-index="27" stop-index="77" literal-stop-index="87">
140 141 142
            <!-- FIXME cannot parse IS NOT NULL -->
            <!--<and-predicate>-->
                <!--<predicate start-index="33" stop-index="51">-->
143
                    <!--<column-left-value name="item_id" start-index="33" stop-index="39" />-->
144 145
                <!--</predicate>-->
                <!--<predicate start-index="57" stop-index="77" literal-stop-index="87">-->
146
                    <!--<column-left-value name="item_id" start-index="57" stop-index="63" />-->
147 148 149
                <!--</predicate>-->
            <!--</and-predicate>-->
        </where>
150 151 152
        <order-by>
            <column-item name="item_id" />
        </order-by>
153
    </select>
T
terrymanu 已提交
154
    
155
    <select sql-case-id="select_not_between_with_single_table" parameters="100000, 100001">
156
        <table name="t_order_item" start-index="14" stop-index="25" />
157 158 159
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
160
        <where start-index="27" stop-index="83" literal-stop-index="93">
161 162 163
            <!-- FIXME can not parse IS NOT NULL -->
            <!--<and-predicate>-->
                <!--<predicate start-index="33" stop-index="51">-->
164
                    <!--<column-left-value name="item_id" start-index="33" stop-index="39" />-->
165 166
                <!--</predicate>-->
                <!--<predicate start-index="57" stop-index="83">-->
167
                    <!--<column-left-value name="item_id" start-index="57" stop-index="63" />-->
168 169 170
                <!--</predicate>-->
            <!--</and-predicate>-->
        </where>
171 172 173
        <order-by>
            <column-item name="item_id" />
        </order-by>
174
    </select>
T
terrymanu 已提交
175
    
176
    <select sql-case-id="select_equal_with_single_table" parameters="1, 1">
177
        <table name="t_order" start-index="14" stop-index="20" />
178 179 180
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
181
        <where start-index="22" stop-index="33">
182 183
            <and-predicate>
                <predicate start-index="28" stop-index="38">
184
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
185 186 187 188 189
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
190 191
                </predicate>
                <predicate start-index="44" stop-index="55">
192
                    <column-left-value name="order_id" start-index="44" stop-index="51" />
193 194 195 196 197
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                    </compare-right-value>
198 199 200
                </predicate>
            </and-predicate>
        </where>
201
    </select>
202
    
203
    <select sql-case-id="select_equal_with_same_sharding_column" parameters="1, 2">
204
        <table name="t_order" start-index="14" stop-index="20" />
205 206 207
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
208
        <where start-index="22" stop-index="56">
209 210
            <and-predicate>
                <predicate start-index="28" stop-index="39">
211
                    <column-left-value name="order_id" start-index="28" stop-index="35" />
212 213 214 215 216
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
217 218
                </predicate>
                <predicate start-index="45" stop-index="56">
219
                    <column-left-value name="order_id" start-index="45" stop-index="52" />
220 221 222 223 224
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="2" />
                    </compare-right-value>
225 226 227
                </predicate>
            </and-predicate>
        </where>
228
    </select>
T
terrymanu 已提交
229
    
230
    <select sql-case-id="select_between_with_single_table" parameters="1, 10, 2, 5">
231
        <table name="t_order" start-index="14" stop-index="20" />
232
        <projections start-index="7" stop-index="7">
233
            <shorthand-projection start-index="7" stop-index="7" />
234
        </projections>
235
        <where start-index="22" stop-index="107">
236 237
            <and-predicate>
                <predicate start-index="28" stop-index="50" literal-stop-index="51">
238
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
L
Liang Zhang 已提交
239 240 241 242 243 244
                    <between-right-value>
                        <between-parameter-marker-expression value="0" />
                        <between-literal-expression value="1" />
                        <and-parameter-marker-expression value="1" />
                        <and-literal-expression value="10" />
                    </between-right-value>
245 246
                </predicate>
                <predicate start-index="56" stop-index="79" literal-start-index="57" literal-stop-index="80">
247
                    <column-left-value name="order_id" start-index="56" stop-index="63" literal-start-index="57" literal-stop-index="64" />
L
Liang Zhang 已提交
248 249 250 251 252 253
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="2" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="5" />
                    </between-right-value>
254 255 256
                </predicate>
            </and-predicate>
        </where>
257 258 259 260
        <order-by>
            <column-item name="user_id" />
            <column-item name="order_id" />
        </order-by>
261
    </select>
262
    
263
    <select sql-case-id="select_comparison_symbol_with_single_table" parameters="1, 10, 2, 5">
264
        <table name="t_order" start-index="14" stop-index="20" />
265
        <projections start-index="7" stop-index="7">
266
            <shorthand-projection start-index="7" stop-index="7" />
267
        </projections>
268
        <where start-index="22" stop-index="119" literal-stop-index="120">
269 270
            <and-predicate>
                <predicate start-index="28" stop-index="39">
271
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
272 273 274 275 276
                    <operator type="&gt;=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
277 278
                </predicate>
                <predicate start-index="45" stop-index="56" literal-stop-index="57">
279
                    <column-left-value name="user_id" start-index="45" stop-index="51" />
280 281 282 283 284
                    <operator type="&lt;=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="10" />
                    </compare-right-value>
285 286
                </predicate>
                <predicate start-index="62" stop-index="74" literal-start-index="63" literal-stop-index="75">
287
                    <column-left-value name="order_id" start-index="62" stop-index="69" literal-start-index="63" literal-stop-index="70" />
288 289 290 291 292
                    <operator type="&gt;=" />
                    <compare-right-value>
                        <parameter-marker-expression value="2" />
                        <literal-expression value="2" />
                    </compare-right-value>
293 294
                </predicate>
                <predicate start-index="80" stop-index="92" literal-start-index="81" literal-stop-index="93">
295
                    <column-left-value name="order_id" start-index="80" stop-index="87" literal-start-index="81" literal-stop-index="88" />
296 297 298 299 300
                    <operator type="&lt;=" />
                    <compare-right-value>
                        <parameter-marker-expression value="3" />
                        <literal-expression value="5" />
                    </compare-right-value>
301 302 303
                </predicate>
            </and-predicate>
        </where>
304 305 306 307
        <order-by>
            <column-item name="user_id" />
            <column-item name="order_id" />
        </order-by>
308
    </select>
T
terrymanu 已提交
309
    
310
    <select sql-case-id="select_in_with_single_table" parameters="1, 2, 3, 9, 10">
311
        <table name="t_order" start-index="14" stop-index="20" />
312
        <projections start-index="7" stop-index="7">
313
            <shorthand-projection start-index="7" stop-index="7" />
314
        </projections>
315
        <where start-index="22" stop-index="70" literal-stop-index="71">
316 317
            <and-predicate>
                <predicate start-index="28" stop-index="47">
318
                    <column-left-value name="user_id" start-index="28" stop-index="34" />
319 320 321 322 323 324 325 326
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <parameter-marker-expression value="2" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                        <literal-expression value="3" />
                    </in-right-value>
327 328
                </predicate>
                <predicate start-index="53" stop-index="70" literal-stop-index="71">
329
                    <column-left-value name="order_id" start-index="53" stop-index="60" />
330 331 332 333 334 335
                    <in-right-value>
                        <parameter-marker-expression value="3" />
                        <parameter-marker-expression value="4" />
                        <literal-expression value="9" />
                        <literal-expression value="10" />
                    </in-right-value>
336 337 338
                </predicate>
            </and-predicate>
        </where>
339 340 341 342
        <order-by>
            <column-item name="user_id" />
            <column-item name="order_id" />
        </order-by>
343
    </select>
T
terrymanu 已提交
344
    
345
    <select sql-case-id="select_in_with_same_sharding_column" parameters="1000, 1001, 1001, 1002">
346
        <table name="t_order" start-index="14" stop-index="20" />
347
        <projections start-index="7" stop-index="7">
348
            <shorthand-projection start-index="7" stop-index="7" />
349
        </projections>
350
        <where start-index="22" stop-index="68" literal-stop-index="80">
351 352
            <and-predicate>
                <predicate start-index="28" stop-index="45" literal-stop-index="51">
353
                    <column-left-value name="order_id" start-index="28" stop-index="35" />
354 355 356 357 358 359
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1000" />
                        <literal-expression value="1001" />
                    </in-right-value>
360 361
                </predicate>
                <predicate start-index="51" stop-index="68" literal-start-index="57" literal-stop-index="80">
362
                    <column-left-value name="order_id" start-index="51" stop-index="58" literal-start-index="57" literal-stop-index="64" />
363 364 365 366 367 368
                    <in-right-value>
                        <parameter-marker-expression value="2" />
                        <parameter-marker-expression value="3" />
                        <literal-expression value="1001" />
                        <literal-expression value="1002" />
                    </in-right-value>
369 370 371
                </predicate>
            </and-predicate>
        </where>
372 373 374
        <order-by>
            <column-item name="order_id" />
        </order-by>
375
    </select>
T
terrymanu 已提交
376
    
377
    <select sql-case-id="select_count_like_concat" parameters="'init', 1, 2, 9, 10">
378
        <table name="t_order" alias="o" start-index="37" stop-index="43" />
379 380 381
        <projections start-index="7" stop-index="30">
            <aggregation-projection type="COUNT" inner-expression-start-index="12" alias="orders_count" start-index="7" stop-index="14" />
        </projections>
382
        <where start-index="47" stop-index="142" literal-stop-index="148">
383 384 385
            <and-predicate>
                <!-- TODO assert predicate with like  -->
                <!--<predicate start-index="62" stop-index="79">-->
386
                    <!--<column-left-value name="status" start-index="53" stop-index="60">-->
387 388 389 390
                        <!--<owner name="o" start-index="53" stop-index="53" />-->
                    <!--</column>-->
                <!--</predicate>-->
                <predicate start-index="93" stop-index="111" literal-start-index="98" literal-stop-index="116">
391
                    <column-left-value name="user_id" start-index="93" stop-index="101" literal-start-index="98" literal-stop-index="106">
392
                        <owner name="o" start-index="93" stop-index="93" literal-start-index="98" literal-stop-index="98" />
393
                    </column-left-value>
394 395 396 397 398 399
                    <in-right-value>
                        <parameter-marker-expression value="1" />
                        <parameter-marker-expression value="2" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
400 401
                </predicate>
                <predicate start-index="117" stop-index="142" literal-start-index="122" literal-stop-index="148">
402
                    <column-left-value name="order_id" start-index="117" stop-index="126" literal-start-index="122" literal-stop-index="131">
403
                        <owner name="o" start-index="117" stop-index="117" literal-start-index="122" literal-stop-index="122" />
404
                    </column-left-value>
L
Liang Zhang 已提交
405 406 407 408 409 410
                    <between-right-value>
                        <between-parameter-marker-expression value="3" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="4" />
                        <and-literal-expression value="10" />
                    </between-right-value>
411 412 413
                </predicate>
            </and-predicate>
        </where>
414
    </select>
415
    
416
    <select sql-case-id="select_count_tilde_concat" parameters="'init', 1, 2, 9, 10">
417
        <table name="t_order" alias="o" start-index="37" stop-index="43" />
418 419 420
        <projections start-index="7" stop-index="30">
            <aggregation-projection type="COUNT" inner-expression-start-index="12" alias="orders_count" start-index="7" stop-index="14" />
        </projections>
421
        <where start-index="47" stop-index="140" literal-stop-index="146">
422 423 424
            <and-predicate>
                <!-- TODO add predication assert for ~~ -->
                <!--<predicate start-index="62" stop-index="79">-->
425
                    <!--<column-left-value name="status" start-index="53" stop-index="60">-->
426 427 428 429
                        <!--<owner name="o" start-index="53" stop-index="53" />-->
                    <!--</column>-->
                <!--</predicate>-->
                <predicate start-index="91" stop-index="109" literal-start-index="96" literal-stop-index="114">
430
                    <column-left-value name="user_id" start-index="91" stop-index="99" literal-start-index="96" literal-stop-index="104">
431
                        <owner name="o" start-index="91" stop-index="91" literal-start-index="96" literal-stop-index="96" />
432
                    </column-left-value>
433 434 435 436 437 438
                    <in-right-value>
                        <parameter-marker-expression value="1" />
                        <parameter-marker-expression value="2" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
439 440
                </predicate>
                <predicate start-index="115" stop-index="140" literal-start-index="120" literal-stop-index="146">
441
                    <column-left-value name="order_id" start-index="115" stop-index="124" literal-start-index="120" literal-stop-index="129">
442
                        <owner name="o" start-index="115" stop-index="115" literal-start-index="120" literal-stop-index="120" />
443
                    </column-left-value>
L
Liang Zhang 已提交
444 445 446 447 448 449
                    <between-right-value>
                        <between-parameter-marker-expression value="3" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="4" />
                        <and-literal-expression value="10" />
                    </between-right-value>
450 451 452
                </predicate>
            </and-predicate>
        </where>
453
    </select>
T
terrymanu 已提交
454
    
455
    <select sql-case-id="select_sharding_route_with_binding_tables" parameters="1, 2, 9, 10">
456 457
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
458
        <projections start-index="7" stop-index="9">
459 460 461
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
462
        </projections>
463
        <where start-index="99" stop-index="154" literal-stop-index="155">
464 465
            <and-predicate>
                <predicate start-index="105" stop-index="123">
466
                    <column-left-value name="user_id" start-index="105" stop-index="113">
467
                        <owner name="o" start-index="105" stop-index="105" />
468
                    </column-left-value>
469 470 471 472 473 474
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
475 476
                </predicate>
                <predicate start-index="129" stop-index="154" literal-stop-index="155">
477
                    <column-left-value name="order_id" start-index="129" stop-index="138">
478
                        <owner name="o" start-index="129" stop-index="129" />
479
                    </column-left-value>
L
Liang Zhang 已提交
480 481 482 483 484 485
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="10" />
                    </between-right-value>
486 487 488
                </predicate>
            </and-predicate>
        </where>
489 490 491 492 493
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="165" stop-index="165" literal-start-index="166" literal-stop-index="166" />
            </column-item>
        </order-by>
494
    </select>
495
    
496
    <select sql-case-id="select_full_route_with_binding_tables">
497 498
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
499 500 501 502 503
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
504 505 506 507 508
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="108" stop-index="108" />
            </column-item>
        </order-by>
509
    </select>
T
terrymanu 已提交
510
    
511
    <select sql-case-id="select_sharding_route_with_broadcast_table" parameters="1, 2, 9, 10, 'init'">
512 513 514
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
        <table name="t_broadcast_table" alias="c" start-index="104" stop-index="120" />
515 516 517 518 519
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
520
        <where start-index="147" stop-index="219" literal-stop-index="225">
521 522
            <and-predicate>
                <predicate start-index="153" stop-index="171">
523
                    <column-left-value name="user_id" start-index="153" stop-index="161">
524
                        <owner name="o" start-index="153" stop-index="153" />
525
                    </column-left-value>
526 527 528 529 530 531
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
532 533
                </predicate>
                <predicate start-index="177" stop-index="202" literal-stop-index="203">
534
                    <column-left-value name="order_id" start-index="177" stop-index="186">
535
                        <owner name="o" start-index="177" stop-index="177" />
536
                    </column-left-value>
L
Liang Zhang 已提交
537 538 539 540 541 542
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="10" />
                    </between-right-value>
543 544
                </predicate>
                <predicate start-index="208" stop-index="219" literal-start-index="209" literal-stop-index="225">
545
                    <column-left-value name="status" start-index="208" stop-index="215" literal-start-index="209" literal-stop-index="216">
546
                        <owner name="o" start-index="208" stop-index="208" literal-start-index="209" literal-stop-index="209" />
547
                    </column-left-value>
548 549 550 551 552
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="init" />
                    </compare-right-value>
553 554 555
                </predicate>
            </and-predicate>
        </where>
556 557 558 559 560
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="230" stop-index="230" literal-start-index="236" literal-stop-index="236" />
            </column-item>
        </order-by>
561
    </select>
T
tuohai666 已提交
562
    
563
    <select sql-case-id="select_keyword_table_name_with_back_quotes" parameters="1, 2, 9, 10, 'init'">
564 565 566
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
        <table name="select" alias="c" start-delimiter="`" end-delimiter="`" start-index="104" stop-index="111" />
567 568 569 570 571
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
572
        <where start-index="138" stop-index="210" literal-stop-index="216">
573 574
            <and-predicate>
                <predicate start-index="144" stop-index="162">
575
                    <column-left-value name="user_id" start-index="144" stop-index="152">
576
                        <owner name="o" start-index="144" stop-index="144" />
577
                    </column-left-value>
578 579 580 581 582 583
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
584 585
                </predicate>
                <predicate start-index="168" stop-index="193" literal-stop-index="194">
586
                    <column-left-value name="order_id" start-index="168" stop-index="177">
587
                        <owner name="o" start-index="168" stop-index="168" />
588
                    </column-left-value>
L
Liang Zhang 已提交
589 590 591 592 593 594
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="10" />
                    </between-right-value>
595 596
                </predicate>
                <predicate start-index="199" stop-index="210" literal-start-index="200" literal-stop-index="216">
597
                    <column-left-value name="status" start-index="199" stop-index="206" literal-start-index="200" literal-stop-index="207">
598
                        <owner name="o" start-index="199" stop-index="199" literal-start-index="200" literal-stop-index="200" />
599
                    </column-left-value>
600 601 602 603 604
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="init" />
                    </compare-right-value>
605 606 607
                </predicate>
            </and-predicate>
        </where>
608 609 610 611 612
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="221" stop-index="221" literal-start-index="227" literal-stop-index="227" />
            </column-item>
        </order-by>
613
    </select>
T
tuohai666 已提交
614
    
615
    <select sql-case-id="select_keyword_table_name_with_double_quotes" parameters="1, 2, 9, 10, 'init'">
616 617 618
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
        <table name="select" alias="c" start-delimiter="&quot;" end-delimiter="&quot;" start-index="104" stop-index="111" />
619 620 621 622 623
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9" >
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
624
        <where start-index="138" stop-index="210" literal-stop-index="216">
625 626
            <and-predicate>
                <predicate start-index="144" stop-index="162">
627
                    <column-left-value name="user_id" start-index="144" stop-index="152">
628
                        <owner name="o" start-index="144" stop-index="144" />
629
                    </column-left-value>
630 631 632 633 634 635
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
636 637
                </predicate>
                <predicate start-index="168" stop-index="193" literal-stop-index="194">
638
                    <column-left-value name="order_id" start-index="168" stop-index="177">
639
                        <owner name="o" start-index="168" stop-index="168" />
640
                    </column-left-value>
L
Liang Zhang 已提交
641 642 643 644 645 646
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="10" />
                    </between-right-value>
647 648
                </predicate>
                <predicate start-index="199" stop-index="210" literal-start-index="200" literal-stop-index="216">
649
                    <column-left-value name="status" start-index="199" stop-index="206" literal-start-index="200" literal-stop-index="207">
650
                        <owner name="c" start-index="199" stop-index="199" literal-start-index="200" literal-stop-index="200" />
651
                    </column-left-value>
652 653 654 655 656
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="init" />
                    </compare-right-value>
657 658 659
                </predicate>
            </and-predicate>
        </where>
660 661 662 663 664
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="221" stop-index="221" literal-start-index="227" literal-stop-index="227" />
            </column-item>
        </order-by>
665
    </select>
T
tuohai666 已提交
666
    
667
    <select sql-case-id="select_keyword_table_name_with_square_brackets" parameters="1, 2, 9, 10, 'init'">
668 669 670
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="31" stop-index="42" />
        <table name="select" alias="c" start-delimiter="[" end-delimiter="]" start-index="104" stop-index="111" />
671 672 673 674 675
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
676
        <where start-index="138" stop-index="210" literal-stop-index="216">
677 678
            <and-predicate>
                <predicate start-index="144" stop-index="162">
679
                    <column-left-value name="user_id" start-index="144" stop-index="152">
680
                        <owner name="o" start-index="144" stop-index="144" />
681
                    </column-left-value>
682 683 684 685 686 687
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1" />
                        <literal-expression value="2" />
                    </in-right-value>
688 689
                </predicate>
                <predicate start-index="168" stop-index="193" literal-stop-index="194">
690
                    <column-left-value name="order_id" start-index="168" stop-index="177">
691
                        <owner name="o" start-index="168" stop-index="168" />
692
                    </column-left-value>
L
Liang Zhang 已提交
693 694 695 696 697 698
                    <between-right-value>
                        <between-parameter-marker-expression value="2" />
                        <between-literal-expression value="9" />
                        <and-parameter-marker-expression value="3" />
                        <and-literal-expression value="10" />
                    </between-right-value>
699 700
                </predicate>
                <predicate start-index="199" stop-index="210" literal-start-index="200" literal-stop-index="216">
701
                    <column-left-value name="status" start-index="199" stop-index="206" literal-start-index="200" literal-stop-index="207">
702
                        <owner name="c" start-index="199" stop-index="199" literal-start-index="200" literal-stop-index="200" />
703
                    </column-left-value>
704 705 706 707 708
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="init" />
                    </compare-right-value>
709 710 711
                </predicate>
            </and-predicate>
        </where>
712 713 714 715 716
        <order-by>
            <column-item name="item_id">
                <owner name="i" start-index="221" stop-index="221" literal-start-index="227" literal-stop-index="227" />
            </column-item>
        </order-by>
717
    </select>
718
    
719
    <select sql-case-id="select_alias_as_keyword" parameters="1">
720
        <table name="t_order_item" alias="length" start-index="36" stop-index="47" />
721 722 723 724 725
        <projections start-index="7" stop-index="29">
            <column-projection name="item_id" alias="password" start-index="7" stop-index="20">
                <owner name="length" start-index="7" stop-index="12" />
            </column-projection>>
        </projections>
726
        <where start-index="56" stop-index="79">
727 728
            <and-predicate>
                <predicate start-index="62" stop-index="79">
729
                    <column-left-value name="item_id" start-index="62" stop-index="75">
730
                        <owner name="length" start-index="62" stop-index="67" />
731
                    </column-left-value>
732 733 734 735 736
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
737 738 739
                </predicate>
            </and-predicate>
        </where>
740
    </select>
741
    
742
    <select sql-case-id="select_with_force_index_join" parameters="1000">
743 744
        <table name="t_order" alias="o" start-index="16" stop-index="22" />
        <table name="t_order_item" alias="i" start-index="56" stop-index="67" />
745 746 747 748 749
        <projections start-index="7" stop-index="9">
            <shorthand-projection start-index="7" stop-index="9">
                <owner name="i" start-index="7" stop-index="7" />
            </shorthand-projection>
        </projections>
750
        <where start-index="96" stop-index="115" literal-stop-index="118">
751 752
            <and-predicate>
                <predicate start-index="102" stop-index="115" literal-stop-index="118">
753
                    <column-left-value name="order_id" start-index="102" stop-index="111">
754
                        <owner name="o" start-index="102" stop-index="102" />
755
                    </column-left-value>
756 757 758 759 760
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1000" />
                    </compare-right-value>
761 762 763
                </predicate>
            </and-predicate>
        </where>
764
    </select>
765

766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804
    <select sql-case-id="select_equal_with_geography" parameters="'{&quot;rule2&quot;:&quot;null2&quot;}', 100, 200, 1, 2">
        <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="148" literal-stop-index="170">
            <and-predicate>
                <predicate start-index="28" stop-index="42" literal-stop-index="60">
                    <column-left-value name="rule" start-index="28" stop-index="31" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="{&quot;rule2&quot;:&quot;null2&quot;}'::json" />
                    </compare-right-value>
                </predicate>
                <predicate start-index="48" stop-index="115" literal-start-index="66" literal-stop-index="137">
                    <column-left-value name="start_point" start-index="48" stop-index="58" literal-start-index="66" literal-stop-index="76" />
                    <operator type="=" />
                    <!-- TODO assert expression -->
                </predicate>
                <predicate start-index="121" stop-index="131" literal-start-index="143" literal-stop-index="153">
                    <column-left-value name="user_id" start-index="121" stop-index="127" literal-start-index="143" literal-stop-index="149" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="3" />
                        <literal-expression value="1" />
                    </compare-right-value>
                </predicate>
                <predicate start-index="137" stop-index="148" literal-start-index="159" literal-stop-index="170">
                    <column-left-value name="order_id" start-index="137" stop-index="144" literal-start-index="159" literal-stop-index="166" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="2" />
                    </compare-right-value>
                </predicate>
            </and-predicate>
        </where>
    </select>
805

806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845
    <select sql-case-id="select_in_with_geography" parameters="'{&quot;rule2&quot;:&quot;null2&quot;}', '{&quot;rule3&quot;:&quot;null3&quot;}', 100, 200, 1, 2">
        <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="161" literal-stop-index="201">
            <and-predicate>
                <predicate start-index="28" stop-index="55" literal-stop-index="91">
                    <column-left-value name="rule" start-index="28" stop-index="31" />
                    <in-right-value>
                        <parameter-marker-expression value="0" />
                        <parameter-marker-expression value="1" />
                        <literal-expression value="{&quot;rule2&quot;:&quot;null2&quot;}'::json" />
                        <literal-expression value="{&quot;rule3&quot;:&quot;null3&quot;}'::json" />
                    </in-right-value>
                </predicate>
                <predicate start-index="61" stop-index="128" literal-start-index="97" literal-stop-index="168">
                    <column-left-value name="start_point" start-index="61" stop-index="71" literal-start-index="97" literal-stop-index="107" />
                    <operator type="=" />
                    <!-- TODO assert expr -->
                </predicate>
                <predicate start-index="134" stop-index="144" literal-start-index="174" literal-stop-index="184">
                    <column-left-value name="user_id" start-index="134" stop-index="140" literal-start-index="174" literal-stop-index="180" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="1" />
                    </compare-right-value>
                </predicate>
                <predicate start-index="150" stop-index="161" literal-start-index="190" literal-stop-index="201">
                    <column-left-value name="order_id" start-index="150" stop-index="157" literal-start-index="190" literal-stop-index="197" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="5" />
                        <literal-expression value="2" />
                    </compare-right-value>
                </predicate>
            </and-predicate>
        </where>
    </select>
T
tuohai666 已提交
846
    
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878
    <select sql-case-id="select_between_with_geography" parameters="'{&quot;rule2&quot;:&quot;null2&quot;}', '{&quot;rule3&quot;:&quot;null3&quot;}', 100, 200, 1">
        <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="151" literal-stop-index="191">
            <and-predicate>
                <predicate start-index="28" stop-index="61" literal-stop-index="97">
                    <column-left-value name="rule" start-index="28" stop-index="31" />
                    <between-right-value>
                        <between-parameter-marker-expression value="0" />
                        <between-literal-expression value="{&quot;rule2&quot;:&quot;null2&quot;}'::json" />
                        <and-parameter-marker-expression value="1" />
                        <and-literal-expression value="{&quot;rule3&quot;:&quot;null3&quot;}'::json" />
                    </between-right-value>
                </predicate>
                <predicate start-index="67" stop-index="134" literal-start-index="103" literal-stop-index="174">
                    <column-left-value name="start_point" start-index="67" stop-index="77" literal-start-index="103" literal-stop-index="113" />
                    <operator type="=" />
                    <!-- TODO assert right value -->
                </predicate>
                <predicate start-index="140" stop-index="151" literal-start-index="180" literal-stop-index="191">
                    <column-left-value name="order_id" start-index="140" stop-index="147" literal-start-index="180" literal-stop-index="187" />
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="4" />
                        <literal-expression value="1" />
                    </compare-right-value>
                </predicate>
            </and-predicate>
        </where>
    </select>
T
tuohai666 已提交
879
    
880
    <select sql-case-id="select_with_double_quotes" parameters="1">
881
        <table name="t_order_item" start-delimiter="&quot;" end-delimiter="&quot;" start-index="14" stop-index="27" />
882 883 884
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
885
        <where start-index="29" stop-index="48">
886 887
            <and-predicate>
                <predicate start-index="35" stop-index="48">
888
                    <column-left-value name="item_id" start-delimiter="&quot;" end-delimiter="&quot;" start-index="35" stop-index="43" />
889 890 891 892 893
                    <operator type="!=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="1" />
                    </compare-right-value>
894 895 896
                </predicate>
            </and-predicate>
        </where>
897 898 899
        <order-by>
            <column-item name="item_id" />
        </order-by>
900
    </select>
T
tristaZero 已提交
901
    
902
    <select sql-case-id="select_distinct_with_single_column" >
903
        <table name="t_order_item" start-index="29" stop-index="40" />
904 905 906
        <projections start-index="16" stop-index="22" distinct-row="true">
            <column-projection name="item_id" start-index="16" stop-index="22" />
        </projections>
907 908 909
        <order-by>
            <column-item name="item_id" />
        </order-by>
910
    </select>
T
terrymanu 已提交
911
    
912
    <select sql-case-id="select_distinct_with_owner_column" >
913
        <table name="t_order" start-index="38" stop-index="44" />
914 915 916 917 918
        <projections start-index="16" stop-index="31" distinct-row="true">
            <column-projection name="order_id" start-index="16" stop-index="31">
                <owner name="t_order" start-index="16" stop-index="22" />
            </column-projection>
        </projections>
919 920 921
        <order-by>
            <column-item name="order_id" />
        </order-by>
922
    </select>
T
terrymanu 已提交
923
    
924
    <select sql-case-id="select_distinct_with_multi_column" >
925
        <table name="t_order" start-index="47" stop-index="53" />
926 927 928 929 930
        <projections start-index="16" stop-index="40" distinct-row="true">
            <column-projection name="order_id" start-index="16" stop-index="23" />
            <column-projection name="user_id" start-index="26" stop-index="32" />
            <column-projection name="status" start-index="35" stop-index="40" />
        </projections>
931 932 933
        <order-by>
            <column-item name="order_id" />
        </order-by>
934
    </select>
T
tristaZero 已提交
935
    
936
    <select sql-case-id="select_distinct_with_star" >
937
        <table name="t_order" start-index="23" stop-index="29" />
938 939 940
        <projections distinct-row="true" start-index="16" stop-index="16">
            <shorthand-projection start-index="16" stop-index="16" />
        </projections>
941
        <where start-index="31" stop-index="51">
942 943
            <and-predicate>
                <predicate start-index="37" stop-index="51">
944
                    <column-left-value name="order_id" start-index="37" stop-index="44" />
945 946 947 948
                    <operator type="&gt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
949 950 951
                </predicate>
            </and-predicate>
        </where>
952 953 954
        <order-by>
            <column-item name="order_id" />
        </order-by>
955
    </select>
T
terrymanu 已提交
956
    
957
    <select sql-case-id="select_distinct_with_owner_star">
958 959
        <table name="t_order" start-index="54" stop-index="60" />
        <table name="t_order_item" start-index="63" stop-index="74" />
960 961 962 963 964 965 966 967
        <projections distinct-row="true" start-index="16" stop-index="47">
            <shorthand-projection start-index="16" stop-index="24">
                <owner name="t_order" start-index="16" stop-index="22" />
            </shorthand-projection>
            <column-projection name="order_id" start-index="27" stop-index="47">
                <owner name="t_order_item" start-index="27" stop-index="38" />
            </column-projection>
        </projections>
968
        <where start-index="76" stop-index="121">
969 970
            <and-predicate>
                <predicate start-index="82" stop-index="121">
971
                    <column-left-value name="order_id" start-index="82" stop-index="97">
972
                        <owner name="t_order" start-index="82" stop-index="88" />
973 974 975 976
                    </column-left-value>
                    <column-right-value name="order_id" start-index="101" stop-index="121">
                        <owner name="t_order_item" start-index="101" stop-index="112" />
                    </column-right-value>
977 978 979
                </predicate>
            </and-predicate>
        </where>
980 981 982 983 984
        <order-by>
            <column-item name="order_id">
                <owner name="t_order" start-index="132" stop-index="138" />
            </column-item>
        </order-by>
985
    </select>
T
tristaZero 已提交
986
    
987
    <select sql-case-id="select_distinct_with_sum" >
988
        <table name="t_order" start-index="37" stop-index="43" />
989
        <projections start-index="7" stop-index="30">
990
            <aggregation-distinct-projection type="SUM" inner-expression-start-index="10" distinct-expression="order_id" alias="s" start-index="7" stop-index="28" />
991
        </projections>
992
        <where start-index="45" stop-index="65">
993 994
            <and-predicate>
                <predicate start-index="51" stop-index="65">
995
                    <column-left-value name="order_id" start-index="51" stop-index="58" />
996 997 998 999
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1000 1001 1002
                </predicate>
            </and-predicate>
        </where>
1003
    </select>
1004
    
1005
    <select sql-case-id="select_distinct_with_count">
1006
        <table name="t_order" start-index="39" stop-index="45" />
1007 1008
        <projections start-index="7" stop-index="32">
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="12" distinct-expression="order_id" alias="c" start-index="7" stop-index="30" />
1009
        </projections>
1010
        <where start-index="47" stop-index="67">
1011 1012
            <and-predicate>
                <predicate start-index="53" stop-index="67">
1013
                    <column-left-value name="order_id" start-index="53" stop-index="60" />
1014 1015 1016 1017
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1018 1019 1020
                </predicate>
            </and-predicate>
        </where>
1021
    </select>
T
terrymanu 已提交
1022
    
1023
    <select sql-case-id="select_distinct_with_avg">
1024
        <table name="t_order" start-index="35" stop-index="41" />
1025
        <projections start-index="7" stop-index="28">
1026
            <aggregation-distinct-projection type="AVG" inner-expression-start-index="10" distinct-expression="order_id" start-index="7" stop-index="28" />
1027
        </projections>
1028
        <where start-index="43" stop-index="63">
1029 1030
            <and-predicate>
                <predicate start-index="49" stop-index="63">
1031
                    <column-left-value name="order_id" start-index="49" stop-index="56" />
1032 1033 1034 1035
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1036 1037 1038
                </predicate>
            </and-predicate>
        </where>
1039
    </select>
T
tristaZero 已提交
1040
    
1041
    <select sql-case-id="select_distinct_with_count_sum" >
1042
        <table name="t_order" start-index="61" stop-index="67" />
1043
        <projections start-index="7" stop-index="54">
1044 1045
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="12" distinct-expression="order_id" start-index="7" stop-index="30" />
            <aggregation-distinct-projection type="SUM" inner-expression-start-index="36" distinct-expression="order_id" start-index="33" stop-index="54" />
1046
        </projections>
1047
        <where start-index="75" stop-index="89">
1048 1049
            <and-predicate>
                <predicate start-index="75" stop-index="89">
1050
                    <column-left-value name="order_id" start-index="75" stop-index="82" />
1051 1052 1053 1054
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1055 1056 1057
                </predicate>
            </and-predicate>
        </where>
1058
    </select>
T
terrymanu 已提交
1059
    
1060
    <select sql-case-id="select_distinct_with_single_count_group_by" >
1061
        <table name="t_order" start-index="49" stop-index="55" />
1062
        <projections start-index="7" stop-index="42">
1063 1064
            <column-projection name="order_id" start-index="7" stop-index="14" />
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="22" distinct-expression="order_id" alias="c" start-index="17" stop-index="40" />
1065
        </projections>
1066
        <where start-index="57" stop-index="77">
1067 1068
            <and-predicate>
                <predicate start-index="63" stop-index="77">
1069
                    <column-left-value name="order_id" start-index="63" stop-index="70" />
1070 1071 1072 1073
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1074 1075 1076
                </predicate>
            </and-predicate>
        </where>
1077 1078 1079
        <group-by>
            <column-item name="order_id" />
        </group-by>
1080 1081 1082
        <order-by>
            <column-item name="order_id" />
        </order-by>
1083
    </select>
1084
    
1085
    <select sql-case-id="select_distinct_with_count_group_by" >
1086
        <table name="t_order" start-index="49" stop-index="55" />
1087
        <projections start-index="7" stop-index="42">
1088 1089
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="12" distinct-expression="order_id" alias="c" start-index="7" stop-index="30" />
            <column-projection name="order_id" start-index="35" stop-index="42" />
1090
        </projections>
1091 1092 1093
        <group-by>
            <column-item name="order_id" />
        </group-by>
1094 1095 1096
        <order-by>
            <column-item name="order_id" />
        </order-by>
1097
    </select>
1098
    
1099
    <select sql-case-id="select_distinct_function">
1100
        <table name="t_order_item" start-index="30" stop-index="41" />
1101 1102 1103
        <projections distinct-row="true" start-index="15" stop-index="23">
            <expression-projection start-index="15" stop-index="23" />
        </projections>
1104 1105 1106
        <order-by>
            <column-item name="item_id" />
        </order-by>
1107
    </select>
T
tristaZero 已提交
1108
    
1109
    <select sql-case-id="select_distinct_with_count_calculation" >
1110
        <table name="t_order" start-index="49" stop-index="55" />
1111
        <projections start-index="7" stop-index="42">
1112
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="12" distinct-expression="user_id+order_id" alias="c" start-index="7" stop-index="40" />
1113
        </projections>
1114
        <where start-index="57" stop-index="77">
1115 1116
            <and-predicate>
                <predicate start-index="63" stop-index="77">
1117
                    <column-left-value name="order_id" start-index="63" stop-index="70" />
1118 1119 1120 1121
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1122 1123 1124
                </predicate>
            </and-predicate>
        </where>
1125
    </select>
1126
    
1127
    <select sql-case-id="select_distinct_with_aggregation_functions" >
1128
        <table name="t_order" start-index="77" stop-index="83" />
1129
        <projections start-index="7" stop-index="69">
1130 1131 1132
            <aggregation-distinct-projection type="SUM" inner-expression-start-index="10" distinct-expression="order_id" start-index="7" stop-index="28" />
            <aggregation-distinct-projection type="COUNT" inner-expression-start-index="35" distinct-expression="order_id" start-index="30" stop-index="53" />
            <aggregation-projection type="COUNT" inner-expression-start-index="60" start-index="55" stop-index="69" />
1133
        </projections>
1134
        <where start-index="85" stop-index="105">
1135 1136
            <and-predicate>
                <predicate start-index="91" stop-index="105">
1137
                    <column-left-value name="order_id" start-index="91" stop-index="98" />
1138 1139 1140 1141
                    <operator type="&lt;" />
                    <compare-right-value>
                        <literal-expression value="1100" />
                    </compare-right-value>
1142 1143 1144
                </predicate>
            </and-predicate>
        </where>
1145
    </select>
C
codefairy08 已提交
1146
    
1147
    <select sql-case-id="select_with_schema" >
1148
        <table name="t_order" start-index="14" stop-index="24">
1149 1150
                <owner name="db1" start-index="14" stop-index="16" />
            </table>
1151
        <projections start-index="7" stop-index="7">
1152
            <shorthand-projection start-index="7" stop-index="7" />
1153
        </projections>
1154
    </select>
C
codefairy08 已提交
1155
    
1156
    <select sql-case-id="select_escape_with_single_quota" >
1157
        <table name="t_order" start-index="14" stop-index="20" />
1158 1159 1160
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
1161
        <where start-index="22" stop-index="38">
1162 1163
            <and-predicate>
                <predicate start-index="28" stop-index="38">
1164
                    <column-left-value name="status" start-index="28" stop-index="33" />
1165 1166 1167 1168
                    <operator type="=" />
                    <compare-right-value>
                        <literal-expression value="\'" />
                    </compare-right-value>
1169 1170 1171
                </predicate>
            </and-predicate>
        </where>
1172
    </select>
C
codefairy08 已提交
1173
    
1174
    <select sql-case-id="select_escape_with_double_quota" >
1175
        <table name="t_order" start-index="14" stop-index="20" />
1176 1177 1178
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
1179
        <where start-index="22" stop-index="38">
1180 1181
            <and-predicate>
                <predicate start-index="28" stop-index="38">
1182 1183 1184
                    <column-left-value name="status" start-index="28" stop-index="33" />
                    <!-- FIXME incorrect parse result as column type: "\"" -->
                    <column-right-value name="\" start-delimiter="&quot;" end-delimiter="&quot;" start-index="35" stop-index="38" />
1185 1186 1187
                </predicate>
            </and-predicate>
        </where>
1188
    </select>
C
codefairy08 已提交
1189
    
1190
    <select sql-case-id="select_with_block_comment" >
1191
        <table name="t_order" start-index="83" stop-index="89" />
1192 1193 1194
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
1195
        <where start-index="90" stop-index="104">
1196 1197 1198
            <and-predicate>
                <!-- FIXME \n's index is incorrect --> 
                <predicate start-index="97" stop-index="106">
1199
                    <column-left-value name="status" start-index="97" stop-index="102" />
1200 1201 1202 1203
                    <operator type="=" />
                    <compare-right-value>
                        <literal-expression value="1" />
                    </compare-right-value>
1204 1205 1206
                </predicate>
            </and-predicate>
        </where>
1207
    </select>
C
codefairy08 已提交
1208
    
1209
    <select sql-case-id="select_with_single_comment" >
1210
        <table name="t_order" start-index="78" stop-index="84" />
1211 1212 1213
        <projections start-index="7" stop-index="7">
            <shorthand-projection start-index="7" stop-index="7" />
        </projections>
1214
        <!-- FIXME incorrect for start index and stop index with \n -->
1215
        <where start-index="85" stop-index="101">
1216 1217
            <and-predicate>
                <predicate start-index="92" stop-index="101">
1218
                    <column-left-value name="status" start-index="92" stop-index="97" />
1219 1220 1221 1222
                    <operator type="=" />
                    <compare-right-value>
                        <literal-expression value="1" />
                    </compare-right-value>
1223 1224 1225
                </predicate>
            </and-predicate>
        </where>
1226
    </select>
C
codefairy08 已提交
1227
    
1228
    <select sql-case-id="select_alias_as_single_quote_string">
1229
        <table name="t_order" start-index="31" stop-index="37" />
1230
        <projections start-index="7" stop-index="24">
1231
            <column-projection alias="status" name="status" start-index="7" stop-index="12" />
1232
        </projections>
1233
    </select>
C
codefairy08 已提交
1234
    
1235
    <select sql-case-id="select_alias_as_string_double_quote">
1236
        <table name="t_order" start-index="31" stop-index="37" />
1237
        <projections start-index="7" stop-index="24">
1238
            <column-projection name="status" alias="status" start-index="7" stop-index="12" />
1239
        </projections>
1240
    </select>
T
terrymanu 已提交
1241
    
1242
    <select sql-case-id="select_special_function_nested" parameters="12, 1000">
1243
        <table name="t_order" start-index="48" stop-index="54" />
1244 1245
        <projections start-index="7" stop-index="41">
            <aggregation-projection type="SUM" inner-expression-start-index="10" alias="func_status" start-index="7" stop-index="29" />
1246
        </projections>
1247
        <where start-index="56" stop-index="89" literal-stop-index="93">
1248 1249
            <and-predicate>
                <predicate start-index="62" stop-index="72" literal-stop-index="73">
1250
                    <column-left-value name="user_id" start-index="62" stop-index="68" />
1251 1252 1253 1254 1255
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="12" />
                    </compare-right-value>
1256 1257
                </predicate>
                <predicate start-index="78" stop-index="89" literal-start-index="79" literal-stop-index="93">
1258
                    <column-left-value name="order_id" start-index="78" stop-index="85" literal-start-index="79" literal-stop-index="86" />
1259 1260 1261 1262 1263
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1000" />
                    </compare-right-value>
1264 1265 1266
                </predicate>
            </and-predicate>
        </where>
1267
    </select>
T
terrymanu 已提交
1268
    
1269
    <select sql-case-id="select_with_row_subquery_without_row_keyword">
1270
        <table name="t_order" start-index="14" stop-index="20" />
1271
        <projections start-index="7" stop-index="7">
1272
            <shorthand-projection start-index="7" stop-index="7" />
1273
        </projections>
1274
        <where start-index="92" stop-index="105">
1275 1276
            <!-- FIXME cannot parse subquery's predicate -->
        </where>
1277
    </select>
T
terrymanu 已提交
1278
    
1279
    <select sql-case-id="select_with_row_subquery">
1280
        <table name="t_order" start-index="14" stop-index="20" />
1281
        <projections start-index="7" stop-index="7">
1282
            <shorthand-projection start-index="7" stop-index="7" />
1283
        </projections>
1284
        <where start-index="95" stop-index="107">
1285 1286
            <!-- FIXME cannot parse subquery's predicate -->
        </where>
1287
    </select>
T
terrymanu 已提交
1288
    
1289
    <select sql-case-id="select_with_interval_function" parameters="12, 1000">
1290
        <table name="t_order" start-index="45" stop-index="51" />
1291 1292
        <projections start-index="7" stop-index="38">
            <expression-projection alias="func_status" start-index="7" stop-index="26" />
1293
        </projections>
1294
        <where start-index="53" stop-index="86" literal-stop-index="90">
1295 1296
            <and-predicate>
                <predicate start-index="59" stop-index="69" literal-stop-index="70">
1297
                    <column-left-value name="user_id" start-index="59" stop-index="65" />
1298 1299 1300 1301 1302
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="12" />
                    </compare-right-value>
1303 1304
                </predicate>
                <predicate start-index="75" stop-index="86" literal-start-index="76" literal-stop-index="90">
1305
                    <column-left-value name="order_id" start-index="75" stop-index="82" literal-start-index="76" literal-stop-index="83" />
1306 1307 1308 1309 1310
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="1" />
                        <literal-expression value="1000" />
                    </compare-right-value>
1311 1312 1313
                </predicate>
            </and-predicate>
        </where>
1314
    </select>
T
terrymanu 已提交
1315
    
1316
    <select sql-case-id="select_with_left_function">
1317
        <table name="t_order_item" start-index="44" stop-index="55" />
1318 1319
        <projections start-index="7" stop-index="37">
            <expression-projection start-index="7" stop-index="37" />
1320
        </projections>
1321
        <where start-index="57" stop-index="74">
1322 1323
            <and-predicate>
                <predicate start-index="63" stop-index="74">
1324
                    <column-left-value name="user_id" start-index="63" stop-index="69" />
1325 1326 1327 1328
                    <operator type="=" />
                    <compare-right-value>
                        <literal-expression value="10" />
                    </compare-right-value>
1329 1330 1331
                </predicate>
            </and-predicate>
        </where>
1332
    </select>
T
terrymanu 已提交
1333
    
1334
    <select sql-case-id="select_for_update" parameters="10">
1335
        <table name="t_order" start-index="14" stop-index="20" />
1336
        <projections start-index="7" stop-index="7">
1337
            <shorthand-projection start-index="7" stop-index="7" />
1338
        </projections>
1339
        <where start-index="22" stop-index="38" literal-stop-index="39">
1340 1341
            <and-predicate>
                <predicate start-index="28" stop-index="38" literal-stop-index="39">
1342
                    <column-left-value name="user_id" start-index="28" stop-index="34"  literal-stop-index="34" />
1343 1344 1345 1346 1347
                    <operator type="=" />
                    <compare-right-value>
                        <parameter-marker-expression value="0" />
                        <literal-expression value="10" />
                    </compare-right-value>
1348 1349 1350
                </predicate>
            </and-predicate>
        </where>
1351
    </select>
T
terrymanu 已提交
1352
    
1353
    <select sql-case-id="select_database">
1354
        <projections start-index="7" stop-index="16">
1355
            <expression-projection start-index="7" stop-index="16" />
1356
        </projections>
1357
    </select>
T
terrymanu 已提交
1358
    
1359
    <select sql-case-id="select_with_mod_function">
1360
        <table name="t_order" start-index="14" stop-index="20" />
1361
        <projections start-index="7" stop-index="7">
1362
            <shorthand-projection start-index="7" stop-index="7" />
1363
        </projections>
1364
        <where start-index="22" stop-index="47">
1365 1366
            <!-- FIXME cannot parse expr in left value -->
        </where>
1367
    </select>
T
terrymanu 已提交
1368
    
1369
    <select sql-case-id="select_with_date_format_function">
1370
        <table name="t_order" start-index="14" stop-index="20" />
1371
        <projections start-index="7" stop-index="7">
1372
            <shorthand-projection start-index="7" stop-index="7" />
1373
        </projections>
1374
        <where start-index="22" stop-index="79">
1375 1376 1377 1378 1379
            <!-- FIXME cannot parse expr in left value for predicate -->
            <!--<and-predicate>-->
                <!--<predicate start-index="28" stop-index="79" />-->
            <!--</and-predicate>-->
        </where>
1380
    </select>
T
terrymanu 已提交
1381
    
1382
    <select sql-case-id="select_with_spatial_function">
1383
        <table name="t_order" start-index="14" stop-index="20" />
1384
        <projections start-index="7" stop-index="7">
1385
            <shorthand-projection start-index="7" stop-index="7" />
1386
        </projections>
1387
        <where start-index="22" stop-index="106">
1388 1389 1390 1391 1392
            <!-- FIXME cannot parse expr in left value -->
            <!--<and-predicate>-->
                <!--<predicate start-index="28" stop-index="106" />-->
            <!--</and-predicate>-->
        </where>
1393
    </select>
N
Nicholas Jiang 已提交
1394

1395
    <select sql-case-id="select_current_user">
1396 1397
        <projections start-index="7" stop-index="18">
            <expression-projection start-index="7" stop-index="18" />
1398
        </projections>
1399 1400
    </select>
</sql-parser-test-cases>