-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix npe cause by parse MySQL select window statement (#29817)
* Fix npe cause by parse MySQL select window statement * Update MySQLContainer.java
- Loading branch information
1 parent
30c1ec4
commit 8b18d4e
Showing
3 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
test/it/parser/src/main/resources/case/dml/select-window.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<sql-parser-test-cases> | ||
<select sql-case-id="select_window" parameters="1"> | ||
<projections start-index="7" stop-index="112"> | ||
<column-projection name="user_id" start-index="7" stop-index="13" /> | ||
<expression-projection text="ROW_NUMBER() OVER w" start-index="16" stop-index="50" alias="row_number"> | ||
<expr> | ||
<!-- FIXME correct function-name parse --> | ||
<function start-index="16" stop-index="34" text="ROW_NUMBER() OVER w" function-name="OVER"> | ||
<parameter> | ||
<function start-index="16" stop-index="25" text="ROW_NUMBER()" function-name="ROW_NUMBER" /> | ||
</parameter> | ||
</function> | ||
</expr> | ||
</expression-projection> | ||
<expression-projection text="RANK() OVER w" start-index="53" stop-index="75" alias="rank"> | ||
<expr> | ||
<!-- FIXME correct function-name parse --> | ||
<function start-index="53" stop-index="65" text="RANK() OVER w" function-name="OVER"> | ||
<parameter> | ||
<function start-index="53" stop-index="56" text="RANK()" function-name="RANK" /> | ||
</parameter> | ||
</function> | ||
</expr> | ||
</expression-projection> | ||
<expression-projection text="DENSE_RANK() OVER w" start-index="78" stop-index="112" alias="dense_rank"> | ||
<expr> | ||
<!-- FIXME correct function-name parse --> | ||
<function start-index="78" stop-index="96" text="DENSE_RANK() OVER w" function-name="OVER"> | ||
<parameter> | ||
<function start-index="78" stop-index="87" text="DENSE_RANK()" function-name="DENSE_RANK" /> | ||
</parameter> | ||
</function> | ||
</expr> | ||
</expression-projection> | ||
</projections> | ||
<from> | ||
<simple-table name="t_order" start-index="119" stop-index="125" /> | ||
</from> | ||
<where start-index="127" stop-index="144"> | ||
<expr> | ||
<binary-operation-expression start-index="133" stop-index="144"> | ||
<left> | ||
<column name="order_id" start-index="133" stop-index="140" /> | ||
</left> | ||
<operator>=</operator> | ||
<right> | ||
<literal-expression value="1" start-index="144" stop-index="144" /> | ||
<parameter-marker-expression parameter-index="0" start-index="144" stop-index="144" /> | ||
</right> | ||
</binary-operation-expression> | ||
</expr> | ||
</where> | ||
<window start-index="146" stop-index="175" /> | ||
</select> | ||
</sql-parser-test-cases> |
21 changes: 21 additions & 0 deletions
21
test/it/parser/src/main/resources/sql/supported/dml/select-window.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<sql-cases> | ||
<sql-case id="select_window" value="SELECT user_id, ROW_NUMBER() OVER w AS 'row_number', RANK() OVER w AS 'rank', DENSE_RANK() OVER w AS 'dense_rank' FROM t_order WHERE order_id = ? WINDOW w AS (ORDER BY user_id)" db-types="MySQL" /> | ||
</sql-cases> |