Set timezone variable in fe#1587
Merged
imay merged 8 commits intoapache:masterfrom Aug 7, 2019
Youngwb:timezone_dev
Merged
Conversation
HangyuanLiu
reviewed
Aug 5, 2019
| checkUpdate(setVar, ctx.getFlag()); | ||
| // Check variable time_zone value is valid | ||
| if (setVar.getVariable().toLowerCase().equals("time_zone")) { | ||
| if (!setVar.getValue().getStringValue().equalsIgnoreCase("SYSTEM")) { |
Contributor
There was a problem hiding this comment.
we don't support "system" variable because fe system time zone is different
imay
requested changes
Aug 5, 2019
| } | ||
|
|
||
| // Check if the time zone_value is valid | ||
| private static void checkTimeZoneValid(SetVar setVar) throws DdlException { |
Contributor
There was a problem hiding this comment.
I think is a common function that can be used by others.
we'd better to put this function another place.
| if (!value.contains("/") && !value.equals("CST") && !m.matches()) { | ||
| ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_TIME_ZONE, setVar.getValue().getStringValue()); | ||
| } | ||
| if (m.matches()) { |
Contributor
There was a problem hiding this comment.
Can you add some comments for this function to let people known what it want to do?
added 2 commits
August 6, 2019 10:30
imay
reviewed
Aug 6, 2019
| // Variables with this flag can not be seen with `SHOW VARIABLES` statement. | ||
| public static final int INVISIBLE = 16; | ||
| // set CST to +08:00 instead of America/Chicago | ||
| public static final ImmutableMap<String, String> timeZoneAliasMap = ImmutableMap.of("CST", "Asia/Shanghai"); |
Contributor
There was a problem hiding this comment.
I think it's better to put it in TimeUtils
| public static void checkTimeZoneValid(String value) throws DdlException { | ||
| try { | ||
| // match offset type, such as +08:00, -07:00 | ||
| Pattern p = Pattern.compile("^[+-]{1}\\d{2}\\:\\d{2}$"); |
Contributor
There was a problem hiding this comment.
I think you can make this static to compile it only one time
| if (!value.contains("/") && !value.equals("CST") && !m.matches()) { | ||
| ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_TIME_ZONE, value); | ||
| } | ||
| if (m.matches()) { |
Contributor
There was a problem hiding this comment.
you can make it better to avoid calling matches two times?
imay
approved these changes
Aug 7, 2019
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is part of support multiple time zone(Issue #1583 ), it just set the timezone variable in fe.
something to notice:
#1583