-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](point-query) Fix point query ignoring session timezone for functions like from_unixtime #60913
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
eldenmoon
wants to merge
1
commit into
apache:master
Choose a base branch
from
eldenmoon:pq-time
base: master
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.
Open
[fix](point-query) Fix point query ignoring session timezone for functions like from_unixtime #60913
Changes from all commits
Commits
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
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
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
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 |
|---|---|---|
|
|
@@ -381,6 +381,8 @@ message PTabletKeyLookupRequest { | |
| optional int64 version = 7; | ||
| // serilized from TQueryOptions | ||
| optional bytes query_options = 8; | ||
| // timezone string, e.g. "America/Mexico_City" | ||
| optional string time_zone = 9; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we directly pass a whole TQueryGlobals?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PTabletKeyLookupRequest is protobuf but TQueryGlobals is thrift |
||
| } | ||
|
|
||
| message PTabletKeyLookupResponse { | ||
|
|
||
15 changes: 15 additions & 0 deletions
15
regression-test/data/point_query_p0/test_point_query_timezone.out
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,15 @@ | ||
| -- This file is automatically generated. You should know what you did if you want to edit this | ||
| -- !full_scan -- | ||
| job_001 2024-01-31 18:00:00.000000 | ||
| job_002 2024-02-01 18:00:00.000000 | ||
|
|
||
| -- !point_query -- | ||
| job_001 2024-01-31 18:00:00.000000 | ||
|
|
||
| -- !full_scan_tokyo -- | ||
| job_001 2024-02-01 09:00:00.000000 | ||
| job_002 2024-02-02 09:00:00.000000 | ||
|
|
||
| -- !point_query_tokyo -- | ||
| job_001 2024-02-01 09:00:00.000000 | ||
|
|
71 changes: 71 additions & 0 deletions
71
regression-test/suites/point_query_p0/test_point_query_timezone.groovy
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,71 @@ | ||
| // 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. | ||
|
|
||
| // Test point query timezone handling (cir_19478) | ||
| // Point queries on unique key tables with row store should respect | ||
| // session timezone for functions like from_unixtime() | ||
| suite("test_point_query_timezone") { | ||
| def tableName = "test_point_query_timezone_tbl" | ||
|
|
||
| sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
| sql """ | ||
| CREATE TABLE ${tableName} ( | ||
| `job_id` VARCHAR(50) NOT NULL, | ||
| `capture_time` BIGINT NOT NULL, | ||
| `event_time` BIGINT NULL | ||
| ) ENGINE=OLAP | ||
| UNIQUE KEY(`job_id`, `capture_time`) | ||
| DISTRIBUTED BY HASH(`job_id`) BUCKETS 1 | ||
| PROPERTIES ( | ||
| "replication_allocation" = "tag.location.default: 1", | ||
| "store_row_column" = "true", | ||
| "enable_unique_key_merge_on_write" = "true" | ||
| ) | ||
| """ | ||
|
|
||
| sql """ INSERT INTO ${tableName} VALUES ('job_001', 1706745600000, 1706745600000) """ | ||
| sql """ INSERT INTO ${tableName} VALUES ('job_002', 1706832000000, 1706832000000) """ | ||
|
|
||
| // Verify it's a short-circuit (point) query | ||
| explain { | ||
| sql("SELECT * FROM ${tableName} WHERE job_id = 'job_001' AND capture_time = 1706745600000") | ||
| contains "SHORT-CIRCUIT" | ||
| } | ||
|
|
||
| // Test with America/Mexico_City timezone (UTC-6) | ||
| // 1706745600 = 2024-02-01 00:00:00 UTC = 2024-01-31 18:00:00 Mexico_City | ||
| sql """ SET time_zone = 'America/Mexico_City' """ | ||
|
|
||
| // Full table scan - should use session timezone | ||
| qt_full_scan """ SELECT job_id, from_unixtime(event_time/1000) AS t FROM ${tableName} ORDER BY job_id """ | ||
|
|
||
| // Point query - should also use session timezone (this was the bug) | ||
| qt_point_query """ SELECT job_id, from_unixtime(event_time/1000) AS t FROM ${tableName} WHERE job_id = 'job_001' AND capture_time = 1706745600000 """ | ||
|
|
||
| // Test with Asia/Tokyo timezone (UTC+9) | ||
| // 1706745600 = 2024-02-01 00:00:00 UTC = 2024-02-01 09:00:00 Tokyo | ||
| sql """ SET time_zone = 'Asia/Tokyo' """ | ||
|
|
||
| qt_full_scan_tokyo """ SELECT job_id, from_unixtime(event_time/1000) AS t FROM ${tableName} ORDER BY job_id """ | ||
|
|
||
| qt_point_query_tokyo """ SELECT job_id, from_unixtime(event_time/1000) AS t FROM ${tableName} WHERE job_id = 'job_001' AND capture_time = 1706745600000 """ | ||
|
|
||
| // Reset timezone | ||
| sql """ SET time_zone = 'Asia/Shanghai' """ | ||
|
|
||
| sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.