-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix: scan hint checks order asc #4365
fix: scan hint checks order asc #4365
Conversation
WalkthroughThe recent changes primarily focus on SQL query optimizations and adjustments to SQL analysis processes. A new SQL query with an Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- src/mito2/src/read/scan_region.rs (2 hunks)
- src/mito2/src/read/seq_scan.rs (1 hunks)
- src/mito2/src/read/unordered_scan.rs (1 hunks)
- src/query/src/optimizer/scan_hint.rs (2 hunks)
- src/store-api/src/storage/requests.rs (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.result (1 hunks)
- tests/cases/standalone/common/show/show_databases_tables.sql (1 hunks)
- tests/cases/standalone/common/system/information_schema.result (1 hunks)
- tests/cases/standalone/common/system/information_schema.sql (1 hunks)
- tests/cases/standalone/common/view/create.result (1 hunks)
- tests/cases/standalone/common/view/create.sql (1 hunks)
- tests/cases/standalone/optimizer/last_value.result (1 hunks)
- tests/cases/standalone/optimizer/last_value.sql (1 hunks)
Files skipped from review due to trivial changes (4)
- tests/cases/standalone/common/show/show_databases_tables.sql
- tests/cases/standalone/common/system/information_schema.sql
- tests/cases/standalone/common/view/create.result
- tests/cases/standalone/common/view/create.sql
Additional comments not posted (11)
tests/cases/standalone/optimizer/last_value.sql (1)
19-26
: Ensure thelast_value
function is used correctly.The
last_value
function is used with anorder by
clause to ensure the correct value is selected. Verify that thets
column is indexed and that the optimizer correctly handles this query.Verification successful
The
last_value
function is used correctly, and thets
column is indexed.
- The
ts
column is indexed in the relevantcreate table
statements.- The
last_value
function is used with theorder by ts
clause correctly.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `last_value` function usage and indexing of `ts` column. # Test: Check if `ts` column is indexed. Expect: Index on `ts` column. rg --type sql -A 5 $'create table t (\n ts timestamp time index,'Length of output: 341
Script:
#!/bin/bash # Description: Verify the `last_value` function usage and indexing of `ts` column. # Test: Check if `ts` column is indexed. Expect: Index on `ts` column. rg --type sql -A 5 'create table t' | grep -i 'ts timestamp' # Test: Verify the usage of `last_value` function in the SQL query. rg --type sql 'last_value'Length of output: 4946
src/store-api/src/storage/requests.rs (1)
17-17
: LGTM! TheDisplay
trait addition is appropriate.The addition of the
Display
trait to theTimeSeriesRowSelector
enum is a useful enhancement for formatted output.tests/cases/standalone/optimizer/last_value.result (1)
1-51
: Verify the expected results for theexplain analyze
query.The expected results for the
explain analyze
query withlast_value
functions should be verified to ensure accuracy. Ensure that the query plan and results match the expected behavior.tests/cases/standalone/common/show/show_databases_tables.result (1)
107-108
: Ensure regex replacements are accurate.The regex replacements for datetime and whitespace matching should be verified to ensure they correctly match the expected patterns.
src/mito2/src/read/unordered_scan.rs (1)
217-217
: Method name change looks good.The method name
format_parts
has been changed toformat_for_explain
to better reflect its purpose.src/query/src/optimizer/scan_hint.rs (1)
215-217
: Order by expression validation looks good.The conditions ensure that the
order by
expression is in ascending order and is a bare column reference, which is necessary for thelast_value
function.src/mito2/src/read/seq_scan.rs (1)
451-451
: Method name change looks good.The method name
format_parts
has been changed toformat_for_explain
to better reflect its purpose.src/mito2/src/read/scan_region.rs (1)
Line range hint
820-842
:
Method name change looks good.The method name
format_parts
has been changed toformat_for_explain
to better reflect its purpose.tests/cases/standalone/common/system/information_schema.result (3)
7-7
: Regex pattern for datetime matching looks good.The pattern
(\s[\-0-9T:\.]{15,})
is appropriate for matching datetime strings.
8-8
: Regex pattern for whitespace matching looks good.The pattern
[\u0020\-]+
is appropriate for matching whitespace characters.
14-48
: Table data additions look good.The table data in the
information_schema.tables
table is consistent and correct. The datetime values are standardized toDATETIME
.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4365 +/- ##
==========================================
- Coverage 85.15% 84.86% -0.29%
==========================================
Files 1063 1064 +1
Lines 189987 190003 +16
==========================================
- Hits 161782 161255 -527
- Misses 28205 28748 +543 |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- tests/cases/standalone/optimizer/last_value.result (1 hunks)
- tests/cases/standalone/optimizer/last_value.sql (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- tests/cases/standalone/optimizer/last_value.result
Additional comments not posted (2)
tests/cases/standalone/optimizer/last_value.sql (2)
19-20
: Ensure redacted content is handled correctly.The comments indicate redacted replacements for metrics and partitioning. Ensure that these replacements are handled correctly in the actual implementation.
21-27
: Verify theexplain analyze
statement andselect
query.The
explain analyze
statement is correctly used to analyze the query performance. Theselect
query utilizeslast_value
functions with anorder by ts
clause and groups byhost
. Ensure that thelast_value
functions and theorder by ts
clause are correctly implemented to achieve the desired ascending sort order.
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/query/src/optimizer/scan_hint.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/query/src/optimizer/scan_hint.rs
I hereby agree to the terms of the GreptimeDB CLA.
Refer to a related PR or issue link (optional)
What's changed and what's your intention?
The scan hint optimizer should ensure the sort expr is asc instead of desc.
This PR also fixes some unstable sqlness tests.
Checklist
Summary by CodeRabbit
New Features
Enhancements
explain analyze
andlast_value
functions for more detailed query analysis.ScanHintVisitor
to enforce constraints on column references forlast_value()
functions.Tests