Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Let the datetime parser support the time zone offset ant time zone name. #984

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
8e16374
Let the datetime parser support the time zone offset ant time zone name.
Shylock-Hg Apr 25, 2021
4da4489
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Apr 25, 2021
4694e86
Split the time zone database and time zone initialization.
Shylock-Hg Apr 25, 2021
e37af49
Test the time zone name and utc offset together.
Shylock-Hg Apr 26, 2021
4d27cdd
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Apr 28, 2021
aab0d8d
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg May 7, 2021
18eda24
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg May 8, 2021
03e37d9
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg May 10, 2021
ca12ef3
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg May 25, 2021
5b2ef3e
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 3, 2021
4c47dd7
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 3, 2021
2c3bc73
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 4, 2021
1b65d41
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 7, 2021
ddf8d92
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 17, 2021
2d1cb01
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jun 18, 2021
bba17d5
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jul 5, 2021
2bdebe9
Merge branch 'master' into feature/datetime-parse-timezone
Shylock-Hg Jul 19, 2021
6608c7d
Correct the timezone conversion.
Shylock-Hg Jul 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/daemons/GraphDaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ int main(int argc, char *argv[]) {
// TODO: Check the ip is valid
nebula::HostAddr localhost{FLAGS_local_ip, FLAGS_port};

// load the time zone data
status = nebula::time::Timezone::init();
if (!status.ok()) {
LOG(ERROR) << status;
return EXIT_FAILURE;
}

// Initialize the global timezone, it's only used for datetime type compute
// won't affect the process timezone.
status = nebula::time::Timezone::initializeGlobalTimezone();
Expand Down
5 changes: 4 additions & 1 deletion tests/common/nebula_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ def _copy_nebula_conf(self):
shutil.copy(storage_conf_path + '/nebula-metad.conf.default',
self.work_dir + '/conf/nebula-metad.conf')

# gflags.json
resources_dir = self.work_dir + '/share/resources/'
os.makedirs(resources_dir)
# gflags.json
shutil.copy(self.build_dir + '/../resources/gflags.json', resources_dir)
# timezone file
shutil.copy(self.build_dir + '/../resources/date_time_zonespec.csv', resources_dir)


def _format_nebula_command(self, name, meta_port, ports, debug_log=True):
params = [
Expand Down
70 changes: 70 additions & 0 deletions tests/tck/features/mutate/InsertWithTimeType.feature
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,76 @@ Feature: Insert with time-dependent types
Then the result should be, in any order:
| edge_date._src | edge_date._dst | edge_date._rank | edge_date.f_date | edge_date.f_time | edge_date.f_datetime |
| 'test_src' | 'test_dst' | 0 | '2017-03-04' | '23:01:00.000000' | '2017-03-04T22:30:40.000000' |
# insert with timezone offset and microseconds
When try to execute query:
"""
INSERT VERTEX tag_date(f_date, f_time, f_datetime) VALUES "test":(date("2017-03-04"), time("23:01:00.010000+01:00"), datetime("2017-03-04T22:30:40.003000-02:30"));
INSERT EDGE edge_date(f_date, f_time, f_datetime) VALUES "test_src"->"test_dst":(date("2017-03-04"), time("23:01:00.010000+01:00"), datetime("2017-03-04T22:30:40.003000-02:30"));
"""
Then the execution should be successful
When executing query:
"""
FETCH PROP ON tag_date "test" YIELD tag_date.f_date, tag_date.f_time, tag_date.f_datetime;
"""
Then the result should be, in any order:
| VertexID | tag_date.f_date | tag_date.f_time | tag_date.f_datetime |
| 'test' | '2017-03-04' | '22:01:00.010000' | '2017-03-05T01:00:40.003000' |
When executing query:
"""
FETCH PROP ON edge_date "test_src"->"test_dst" YIELD edge_date.f_date, edge_date.f_time, edge_date.f_datetime;
"""
Then the result should be, in any order:
| edge_date._src | edge_date._dst | edge_date._rank | edge_date.f_date | edge_date.f_time | edge_date.f_datetime |
| 'test_src' | 'test_dst' | 0 | '2017-03-04' | '22:01:00.010000' | '2017-03-05T01:00:40.003000' |
# insert with timezone name and microseconds
When try to execute query:
"""
INSERT VERTEX tag_date(f_date, f_time, f_datetime) VALUES "test":(date("2017-03-04"), time("23:01:00.010000[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000[Asia/Shanghai]"));
INSERT EDGE edge_date(f_date, f_time, f_datetime) VALUES "test_src"->"test_dst":(date("2017-03-04"), time("23:01:00.010000[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000[Asia/Shanghai]"));
"""
Then the execution should be successful
When executing query:
"""
FETCH PROP ON tag_date "test" YIELD tag_date.f_date, tag_date.f_time, tag_date.f_datetime;
"""
Then the result should be, in any order:
| VertexID | tag_date.f_date | tag_date.f_time | tag_date.f_datetime |
| 'test' | '2017-03-04' | '15:01:00.010000' | '2017-03-04T14:30:40.003000' |
When executing query:
"""
FETCH PROP ON edge_date "test_src"->"test_dst" YIELD edge_date.f_date, edge_date.f_time, edge_date.f_datetime;
"""
Then the result should be, in any order:
| edge_date._src | edge_date._dst | edge_date._rank | edge_date.f_date | edge_date.f_time | edge_date.f_datetime |
| 'test_src' | 'test_dst' | 0 | '2017-03-04' | '15:01:00.010000' | '2017-03-04T14:30:40.003000' |
# insert with timezone name and utc offset
When try to execute query:
"""
INSERT VERTEX tag_date(f_date, f_time, f_datetime) VALUES "test":(date("2017-03-04"), time("23:01:00.010000+08:00[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000+08:00[Asia/Shanghai]"));
INSERT EDGE edge_date(f_date, f_time, f_datetime) VALUES "test_src"->"test_dst":(date("2017-03-04"), time("23:01:00.010000+08:00[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000+08:00[Asia/Shanghai]"));
"""
Then the execution should be successful
When executing query:
"""
FETCH PROP ON tag_date "test" YIELD tag_date.f_date, tag_date.f_time, tag_date.f_datetime;
"""
Then the result should be, in any order:
| VertexID | tag_date.f_date | tag_date.f_time | tag_date.f_datetime |
| 'test' | '2017-03-04' | '15:01:00.010000' | '2017-03-04T14:30:40.003000' |
When executing query:
"""
FETCH PROP ON edge_date "test_src"->"test_dst" YIELD edge_date.f_date, edge_date.f_time, edge_date.f_datetime;
"""
Then the result should be, in any order:
| edge_date._src | edge_date._dst | edge_date._rank | edge_date.f_date | edge_date.f_time | edge_date.f_datetime |
| 'test_src' | 'test_dst' | 0 | '2017-03-04' | '15:01:00.010000' | '2017-03-04T14:30:40.003000' |
# insert with timezone name and mismatched utc offset
When try to execute query:
"""
INSERT VERTEX tag_date(f_date, f_time, f_datetime) VALUES "test":(date("2017-03-04"), time("23:01:00.010000-03:00[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000+03:00[Asia/Shanghai]"));
INSERT EDGE edge_date(f_date, f_time, f_datetime) VALUES "test_src"->"test_dst":(date("2017-03-04"), time("23:01:00.010000-03:00[Asia/Shanghai]"), datetime("2017-03-04T22:30:40.003000+03:00[Asia/Shanghai]"));
"""
Then a ExecutionError should be raised at runtime: Wrong value type: time("23:01:00.010000-03:00[Asia/Shanghai]")
When executing query:
"""
UPDATE VERTEX "test"
Expand Down