Configure timezone of Presto client in SQLAlchemy
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
Start with the presto.connect(...) and SQLAlchemy create_engine entry points shown in the issue, then trace how session_properties reaches Cursor.__init__. Reproduce both timezone configurations against the stated Presto and PyHive versions; done means the supported configuration is clear and the reported failure is either fixed or documented.
Written by the indexing model from the issue text.
Description
Configuring the presto's timezone in SQLAlchemy's create_engine function failed.
Details
Code:
# Option 1 - with http header
connect_args["protocol"] = "https"
connect_args["http_headers"] = {"X-Presto-Time-Zone": "America/New_York"}
# Option 2 - with session properties
connect_args["session_props"] = {"timezone": "America/Los_Angeles"}
# Or
# connect_args["session_properties"] = {"timezone": "America/Los_Angeles"}
Error:
E sqlalchemy.exc.DatabaseError: (pyhive.exc.DatabaseError) {'message': 'Unknown session property timezone', 'errorCode': 14, 'errorName': 'INVALID_SESSION_PROPERTY', 'errorType': 'USER_ERROR', 'retriable': False, 'failureInfo': {'type': 'com.facebook.presto.spi.PrestoException', 'message': 'Unknown session property timezone', 'suppressed': [], 'stack': ['com.facebook.presto.metadata.SessionPropertyManager.lambda$validateSystemSessionProperty$2(SessionPropertyManager.java:191)', 'java.base/java.util.Optional.orElseThrow(Optional.java:408)', 'com.facebook.presto.metadata.SessionPropertyManager.validateSystemSessionProperty(SessionPropertyManager.java:191)', 'com.facebook.presto.Session.beginTransactionId(Session.java:349)', 'com.facebook.presto.execution.QueryStateMachine.beginWithTicker(QueryStateMachine.java:254)', 'com.facebook.presto.execution.QueryStateMachine.begin(QueryStateMachine.java:219)', 'com.facebook.presto.dispatcher.LocalDispatchQueryFactory.createDispatchQuery(LocalDispatchQueryFactory.java:144)', 'com.facebook.presto.dispatcher.DispatchManager.createQueryInternal(DispatchManager.java:312)', 'com.facebook.presto.dispatcher.DispatchManager.lambda$createQuery$0(DispatchManager.java:254)', 'com.facebook.airlift.concurrent.BoundedExecutor.drainQueue(BoundedExecutor.java:78)', 'java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)', 'java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)', 'java.base/java.lang.Thread.run(Thread.java:829)']}}
The raw presto.connect(...) also failed with session_properties
Details
Code: ``` conn = presto.connect( host="localhost", port=8080, username="user", catalog="memory", schema="default", session_properties={ "timezone": "UTC", # or "session.time_zone": "America/New_York", }, ) ```
Error:
def cursor(self):
"""Return a new :py:class:`Cursor` object using the connection."""
> return Cursor(*self._args, **self._kwargs)
E TypeError: Cursor.__init__() got an unexpected keyword argument 'session_properties'
Is there a documentation about how to set timezone for presto connections (SQLAlchemy)? Or it is about SQLAlchemy or PyHive version? For the above experiment, the version SQLAlchemy is 1.4.46 and the version of PyHive is 0.7.0. The presto local instance has image tag 0.286.
Executing SET SESSION timezone = 'UTC'; in the presto instance also errored out:
presto> set SESSION timezone = 'UTC';
Query 20250519_083400_00062_kkxba failed: line 1:1: Session property timezone does not exist
set SESSION timezone = 'UTC'
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 545
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dropbox/PyHive
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100