-
Notifications
You must be signed in to change notification settings - Fork 5k
fix: order by abs(col) column not found if col not in table #33722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tony2h
wants to merge
3
commits into
3.3.6
Choose a base branch
from
fix/3.3.6/TD-38284
base: 3.3.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+85
−5
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
80 changes: 80 additions & 0 deletions
80
test/cases/07-DataQuerying/04-OrderBy/test_order_by_select_list.py
This file contains hidden or 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,80 @@ | ||
| from new_test_framework.utils import tdLog, tdSql | ||
|
|
||
| class TestOrderBySelectList: | ||
| def setup(cls): | ||
| tdLog.debug(f"start to execute {__file__}") | ||
|
|
||
| def test_order_by_select_list(self): | ||
| """Order By Select List | ||
| Query the table with order by select list | ||
| Catalog: | ||
| - Query:OrderBy | ||
| Since: v3.3.6.34 | ||
| Labels: common,ci | ||
| Jira: TD-38284 | ||
| History: | ||
| - 2025-11-26 Tony Zhang add this test case for TD-38284 | ||
| """ | ||
|
|
||
| tdLog.info(f"=============== Start test Order By Select List") | ||
|
|
||
| tdSql.execute("create database if not exists db keep 3650;", show=1) | ||
| tdSql.execute("use db;", show=1) | ||
| tdSql.execute("create table tt (ts timestamp, v1 int, v2 int);", show=1) | ||
| tdSql.execute(""" | ||
| insert into tt values | ||
| ('2025-01-01 09:00:00', 1, -3), | ||
| ('2025-01-01 10:00:00', -2, 2), | ||
| ('2025-01-01 11:00:00', 3, 1); | ||
| """, show=1) | ||
|
|
||
| # 'vv' only exists in select list | ||
| tdSql.query("select ts, v1 as vv from tt order by vv asc", show=1) | ||
| tdSql.checkRows(3) | ||
| tdSql.checkData(0, 0, '2025-01-01 10:00:00') | ||
| tdSql.checkData(0, 1, -2) | ||
| tdSql.checkData(1, 0, '2025-01-01 09:00:00') | ||
| tdSql.checkData(1, 1, 1) | ||
| tdSql.checkData(2, 0, '2025-01-01 11:00:00') | ||
| tdSql.checkData(2, 1, 3) | ||
|
|
||
| # 'vv' only exists in select list | ||
| tdSql.query("select ts, v1 as vv from tt order by abs(vv) asc", show=1) | ||
| tdSql.checkRows(3) | ||
| tdSql.checkData(0, 0, '2025-01-01 09:00:00') | ||
| tdSql.checkData(0, 1, 1) | ||
| tdSql.checkData(1, 0, '2025-01-01 10:00:00') | ||
| tdSql.checkData(1, 1, -2) | ||
| tdSql.checkData(2, 0, '2025-01-01 11:00:00') | ||
| tdSql.checkData(2, 1, 3) | ||
|
|
||
| # 'v1' exists in both select list and table tt | ||
| # prefer to use column from select list | ||
| tdSql.query("select ts, v2 as v1 from tt order by v1 asc", show=1) | ||
| tdSql.checkRows(3) | ||
| tdSql.checkData(0, 0, '2025-01-01 09:00:00') | ||
| tdSql.checkData(0, 1, -3) | ||
| tdSql.checkData(1, 0, '2025-01-01 11:00:00') | ||
| tdSql.checkData(1, 1, 1) | ||
| tdSql.checkData(2, 0, '2025-01-01 10:00:00') | ||
| tdSql.checkData(2, 1, 2) | ||
|
|
||
| # 'v1' exists in both select list and table tt | ||
| # prefer to use column from table tt | ||
| tdSql.query("select ts, v2 as v1 from tt order by abs(v1) asc", show=1) | ||
| tdSql.checkRows(3) | ||
| tdSql.checkData(0, 0, '2025-01-01 09:00:00') | ||
| tdSql.checkData(0, 1, -3) | ||
| tdSql.checkData(1, 0, '2025-01-01 10:00:00') | ||
| tdSql.checkData(1, 1, 2) | ||
| tdSql.checkData(2, 0, '2025-01-01 11:00:00') | ||
| tdSql.checkData(2, 1, 1) | ||
|
|
||
| tdLog.info(f"=============== End test Order By Select List") | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里逻辑有点混乱,应该是基于找没找到的结果进行处理,res为错误可能是真的错误,也可能是没找到,要区分处理