Files
impala/testdata/workloads/functional-query/queries/QueryTest/local-timestamp-functions.test
Csaba Ringhofer dc32bf7703 IMPALA-7362: Add query option to set timezone
This change adds a new query option "timezone" which
defines the timezone used for utc<->local conversions.
The main goal is to simplify testing, but I think that
some users may also find it useful so it is added as a
"general" query option.

Examples:
set timezone=UTC;
set timezone="Europe/Budapest"

The timezones are validated, but as query options are not
sent to the coordinator immediately, the error checking
will only happen when running a query.

Leading/trailing " and 'characters are stripped because the
/ character cannot be entered unquoted in some contexts.

Currently the timezone has effect in the following cases:
-function now()
-conversions between unix time and timestamp if flag
 use_local_tz_for_unix_timestamp_conversions is true
-reading parquet timestamps written by Hive if flag
 convert_legacy_hive_parquet_utc_timestamps is true

In the near future Parquet timestamps's isAdjustedToUTC
property will be supported, which will decide whether
to do utc->local conversion on a per file+column basis.
This conversion will be also affected.

Testing:
- Extended test_local_tz_conversion.py to actually
  test utc<->local conversion. Until now the effect
  of flag use_local_tz_for_unix_timestamp_conversions
  was practically untested.
- Added a shell test to check that the default of the
  query option is the system's timezone.
- Added a shell test to check timezone validation.

Change-Id: I73de86eff096e1c581d3b56a0d9330d686f77272
Reviewed-on: http://gerrit.cloudera.org:8080/11064
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2018-08-03 17:45:25 +00:00

62 lines
1.3 KiB
Plaintext

# This test should be run with -use_local_tz_for_unix_timestamp_conversions=true
====
---- QUERY
SET timezone=CET;
SELECT
from_unixtime(0),
from_unixtime((40 * 365) * 24 * 60 * 60),
from_unixtime((180 + 40 * 365) * 24 * 60 * 60);
---- TYPES
STRING,STRING,STRING
---- RESULTS
'1970-01-01 01:00:00','2009-12-22 01:00:00','2010-06-20 02:00:00'
====
---- QUERY
set timezone="America/Los_Angeles";
SELECT
from_unixtime(0),
from_unixtime((40 * 365) * 24 * 60 * 60),
from_unixtime((180 + 40 * 365) * 24 * 60 * 60);
---- TYPES
STRING,STRING,STRING
---- RESULTS
'1969-12-31 16:00:00','2009-12-21 16:00:00','2010-06-19 17:00:00'
====
---- QUERY
SET timezone=CET;
SELECT
unix_timestamp('1970-01-01 01:00:00'),
unix_timestamp('2009-12-22 01:00:00'),
unix_timestamp('2010-06-20 02:00:00');
---- TYPES
BIGINT,BIGINT,BIGINT
---- RESULTS
0,1261440000,1276992000
====
---- QUERY
set timezone="America/Los_Angeles";
SELECT
unix_timestamp('1969-12-31 16:00:00'),
unix_timestamp('2009-12-21 16:00:00'),
unix_timestamp('2010-06-19 17:00:00');
---- TYPES
BIGINT,BIGINT,BIGINT
---- RESULTS
0,1261440000,1276992000
====
---- QUERY
SET timezone=CET;
select cast(0 as timestamp);
---- TYPES
TIMESTAMP
---- RESULTS
1970-01-01 01:00:00
====
---- QUERY
SET timezone="America/Los_Angeles";
select cast(0 as timestamp);
---- TYPES
TIMESTAMP
---- RESULTS
1969-12-31 16:00:00