prestodb / presto

The official home of the Presto distributed SQL query engine for big data
http://prestodb.io
Apache License 2.0
16.06k stars 5.38k forks source link

Presto use hive data source, time will change? #8713

Closed annisun closed 7 years ago

annisun commented 7 years ago

Presto use hive data source, time will change? In hive,the time is '2017-08-10 00:00:00.000', but in presto, the time changes like this : '2017-08-10 08:00:00.000'.

Where can I configure it?

fiedukow commented 7 years ago

The way TIMESTAMP from Hive is displayed in presto currently can be determined by two factors. 1) CLI timezone - the value is adjusted by Presto to timezone demanded by user. Timezone can be chosen by passing -Duser.timezone=<YourTZ>[1] to jvm while starting cli executable. By default it's of course determined by client operating system settings. Example CLI start: java -jar -Duser.timezone=Asia/Kathmandu presto-cli-0.183-SNAPSHOT-executable.jar 2) Presto Server timezone - it's recommended to align TZ in which Presto Server JVM works with timezone used by Hive. You can do that by applying same flag as to CLI but to the server (-Duser.timezone may be added to jvm.config). If for some reason you cannot do that, you can preserve some functionality by setting hive.time-zone connector property to timezone of Hive. In that setup you will not be able to do inserts into hive though. Please note that if you will not follow one of those steps Presto configuration is considered invalid, and for that reason the behaviour is undefined and untested - you are basically lying to Presto about what timezone does hive operate in.

To summarise: Make sure that presto server is configured properly. If you are sure that the configuration is correct, you can adjust timezone in which TIMESTAMP is displayed(!) by setting CLI timezone.

Note that current TIMESTAMP behaviour may change in the future (#7480).

[1] List of possible timezones for JVM: https://garygregory.wordpress.com/2013/06/18/what-are-the-java-timezone-ids/

annisun commented 7 years ago

thanks ! I will try it

fiedukow commented 7 years ago

Closing for now. Feel free to reopen if required.