Skip to content
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

feat: support HTTP&gRPC&pg set timezone #3125

Merged
merged 3 commits into from Jan 15, 2024

Conversation

Taylor-lagrange
Copy link
Contributor

@Taylor-lagrange Taylor-lagrange commented Jan 10, 2024

I hereby agree to the terms of the GreptimeDB CLA

What's changed and what's your intention?

Support set/get timezone in HTTP&gRPC&pg&mysql

Use unify SQL layer to dispose SQL SET time_zone = xxx and show variables xxxx, make all protocol support set/get timezone

HTTP

Add a Header named x-greptime-timezone, user can carry timezone by this http header

gRPC

Add timezone in GreptimeRequest::RequestHeader make gRPC query aware timezone info

Related pr GreptimeTeam/greptime-proto#132

PG

Use SHOW VARIABLES system_timezone; and SHOW VARIABLES timezone; to query system timezone and timezone

Use Set time_zone = xxx to set user timezone, system time indicate by timezone in frontend config file

MYSQL

Because MYSQL federated intercept SQL parse like SHOW VARIABLES xxx.

In mysql, we still use Select @@system_timezone; and Select @@timezone; to query system timezone and timezone

Use Set time_zone = xxx to set user timezone, same with PG

Documents will be updated after #2907 finish

Checklist

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR does not require documentation updates.

Refer to a related PR or issue link (optional)

#2907

@github-actions github-actions bot added docs-not-required This change does not impact docs. Size: L labels Jan 10, 2024
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 32 lines in your changes are missing coverage. Please review.

Comparison is base (1fc168b) 85.52% compared to head (69f9e68) 84.93%.
Report is 23 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3125      +/-   ##
==========================================
- Coverage   85.52%   84.93%   -0.59%     
==========================================
  Files         818      825       +7     
  Lines      133850   135081    +1231     
==========================================
+ Hits       114474   114730     +256     
- Misses      19376    20351     +975     

src/client/src/database.rs Outdated Show resolved Hide resolved
src/client/src/database.rs Outdated Show resolved Hide resolved
src/query/src/sql.rs Outdated Show resolved Hide resolved
src/servers/src/grpc/greptime_handler.rs Outdated Show resolved Hide resolved
src/servers/src/http/authorize.rs Outdated Show resolved Hide resolved
src/servers/src/http/header.rs Outdated Show resolved Hide resolved
src/servers/src/mysql/federated.rs Show resolved Hide resolved
src/session/src/context.rs Outdated Show resolved Hide resolved
tests-integration/tests/grpc.rs Show resolved Hide resolved
tests-integration/tests/http.rs Show resolved Hide resolved
Copy link
Contributor

@killme2008 killme2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added docs-required This change requires docs update. and removed docs-not-required This change does not impact docs. labels Jan 12, 2024
Copy link
Member

@waynexia waynexia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about the change from "".to_string() to String::default(). Is clippy complaining about it?

src/common/time/src/timezone.rs Show resolved Hide resolved
@Taylor-lagrange
Copy link
Contributor Author

In my practice, "".to_string() to String::default() may help to discover case like

fn s(s: Option<String>) -> String {
    s.unwrap_or("".to_string())
}

clippy won't complain about it, but String::default() will suggust use unwrap_or_default

@github-actions github-actions bot added docs-not-required This change does not impact docs. and removed docs-required This change requires docs update. labels Jan 12, 2024
@waynexia waynexia added this pull request to the merge queue Jan 15, 2024
Merged via the queue into GreptimeTeam:main with commit 816d948 Jan 15, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs-not-required This change does not impact docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants