Customizing Time Zones

Starting in Impala 3.1, you can customize the time zone definitions used in Impala.

  • By default, Impala uses the OS’s time zone database located in /usr/share/zoneinfo. This directory contains the IANA timezone database in a compiled binary format. The contents of the zoneinfo directory is controlled by the OS’s package manager.

  • Use the following start-up flags to customize the time zone definitions.

    • ‑‑hdfs_zone_info_zip: This flag allows Impala administrators to specify a custom timezone database. The flag should be set to a shared (not necessarily HDFS) path that points to a zip archive of a custom IANA timezone database. The timezone database is expected to be in a compiled binary format. If the startup flag is set, Impala will use the specified timezone database instead of the default /usr/share/zoneinfo database. The timezone db upgrade process is described in detail below.
    • ‑‑hdfs_zone_alias_conf: This flag allows Impala administrators to specify definitions for custom timezone aliases. The flag should be set to a shared (not necessarily HDFS) path that specifies a config file containing custom timezone alias definitions. This config file can be used as a workaround for users who want to keep using their legacy timezone names. Configuring custom aliases is described in detail below.

Upgrading custom IANA time zone database:

  1. Download latest IANA time zone database distribution:

    1. git clone https://github.com/eggert/tz

    Alternatively, download a specific tzdb version from:

    1. https://www.iana.org/time-zones/repository
  2. Build timezone tools:

    1. cd tz
    2. make TOPDIR=tzdata install
  3. Generate the compiled binary time zone database:

    1. ./zic -d ./tzdata/etc/zoneinfo africa antarctica asia australasia backward backzone etcetera europe factory northamerica pacificnew southamerica systemv
  4. Create zip archive:

    1. pushd ./tzdata/etc
    2. zip -r zoneinfo.zip zoneinfo
    3. popd
  5. Copy the time zone database to HDFS:

    1. hdfs dfs -mkdir -p /tzdb/latest
    2. hdfs dfs -copyFromLocal ./tzdata/etc/zoneinfo.zip /tzdb/latest
  6. Set the ‑‑hdfs_zone_info_zip startup flag to /tzdb/latest/zoneinfo.zip as an impalad safety valve.

  7. Perform a full restart of Impala service.

Configuring custom time zone aliases:

  1. Create a tzalias.conf config file that contains time zone alias definitions formatted as *ALIAS* = *DEFINITION*. For example:

    1. #
    2. # Define aliases for existing timezone names:
    3. #
    4. Universal Coordinated Time = UTC
    5. Mideast/Riyadh89 = Asia/Riyadh
    6. PDT = America/Los_Angeles
    7. #
    8. # Define aliases as UTC offsets in seconds:
    9. #
    10. GMT-01:00 = 3600
    11. GMT+01:00 = -3600
  2. Copy the config file to HDFS:

    1. hdfs dfs -mkdir -p /tzdb
    2. hdfs dfs -copyFromLocal tzalias.conf /tzdb
  3. Set the ‑‑hdfs_zone_alias_conf startup flag to /tzdb/tzalias.conf as an impalad safety valve.

  4. Perform a full restart of Impala service.

Added in: Impala 3.1

Parent topic: TIMESTAMP Data Type