-
Notifications
You must be signed in to change notification settings - Fork 328
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
Support for specifying time zone in client connections #2907
Comments
Already supports it in MySQL protocol. |
I think the difficult part is that if we convey this timezone config in the optimizer context. Even we support this statement in the MySQL server codepath now, it's used only for adjust outputs. |
Correct, that's what the third task "Pass client timezone in session context" requests. Luckily we have gathered those conversion logic in a few places (ref to #2905). |
A few context:
|
Currently supported query protocols
MySQLMove Set the time zone (parser dispose the SQL):
Query the current time zone:
PGSet the time zone (parser dispose the SQL, a common way of writing pg):
Query the current time zone:
gRPCAdd an additional Use the gRPC client to provide functions to set the time zone. Although gRPC can also pass SQL statements, SQL statements such as SET/SHOW have no effect on gRPC. Sqlness related: When we do sqlness integration testing, the underlying implementation uses gRPC protocol to transmit SQL queries. We still need to test some SQL statements related to setting time zones. In response to this situation, we need to modify the sqlness test code. Using a similar idea to HTTPAdd a Timezone http header and pass this header every time you query curl -X POST \
-H 'Authorization: Basic Z3JlcHRpbWVfdXNlcjpncmVwdGltZV9wd2Q=' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Timezone: +8:00' \
-d 'sql=SELECT * from host WHERE ts > '1960-01-01 00:00:00'; \
http://localhost:4000/v1/sql?db=public OpenTSDBWhether it is Telnet API or HTTP API, timestamps are written, regardless of time zone. Influxdb line protocolThis protocol is a writing protocol and has nothing to do with time zones. What is written is UTC timestamp. Time zone related behavior
Currently we don't have any support for either of these The conversion from string to timestamp is mainly reflected in:
|
According to some discussion with @waynexia:
|
Another solution is to make |
@Taylor-lagrange Hello, as the main designer of this feature, could you write the document that describes our timezone-related behavior? |
I will add doc about timezone setting. |
We already support set timezone in gRPC protocol, but it seems our gRPC client https://github.com/GreptimeTeam/greptimedb-ingester-go/ still not support set timezone when config client |
What about other languages? Like Java and Rust, cc @fengjiachun @sunng87. Let me add a section about ingester to the list |
We previously discussed this, but since our clients only do writing and do not require string-to-timestamp conversions, it seems that timezone setting is unnecessary. |
Makes sense. gRPC protocol is strong typed and doesn't support string as timestamp. |
What's left of the todos in this issue is a little vague, I think we can close this issue for now. |
What problem does the new feature solve?
Currently, DB only supports using the server’s timezone for writing/querying data. However, this can be inconvenient in situations when the server and client time zones are different. Additionally, it can lead to confusion due to inconsistent behavior between timestamp numbers and strings. Therefore, the new feature aims to address these issues by allowing the specification of a timezone in client connections.
What does the feature do?
The proposed feature enables clients to specify a timezone during their connection/session establishment. This additional parameter will serve as a fallback value when the timezone is not explicitly provided in write or query operations. By supporting the specification of a timezone on the client-side, the feature enhances flexibility and convenience for users.
This feature will greatly benefit users who frequently encounter scenarios where the server and client timezones do not align. And those who need to serve clients from different timezones. It will eliminate confusion caused by inconsistent behavior related to timestamps and strings. Additionally, it will provide users with a more streamlined and efficient approach to handle discrepancies in timezones between the server and clients.
Implementation details
SET time_zone = xxx
(TODO: verify the current state) clause Does greptimedb support timezone? #28931970-01-01 00:00:00/user_tz
feat: change Range Query’s default align behavior aware of timezone #3219Ingester SDKThe text was updated successfully, but these errors were encountered: