-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for TIME(p) and TIMESTAMP(p) to SQLAlchemy #181
Conversation
bd14188
to
2eeb2dc
Compare
trino/sqlalchemy/compiler.py
Outdated
@@ -147,6 +147,39 @@ def visit_BLOB(self, type_, **kw): | |||
def visit_DATETIME(self, type_, **kw): | |||
return self.visit_TIMESTAMP(type_, **kw) | |||
|
|||
def visit_INTERVAL(self, type_, **kw): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure whether it's a correct approach. Interval in Trino has a different value and data type.
For instance:
- data type:
INTERVAL YEAR TO MONTH
- value:
INTERVAL '3' MONTH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this func supposed to return the data type or value? It seems like it returns a mix of both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a part when I'm not sure in which way to go. Other SQLAlchemy dialects which support INTERVAL
data type handles it in different way (one return a value, other data type). INTERVAL
data type doesn't seem to be supported for other dialects..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will move to other PR.
Many checks are failing. |
I've opened a new PR just with just |
2bda620
to
2eeb2dc
Compare
2eeb2dc
to
b039b35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please provide simple test script? As you already know, we don't have integration tests for sqlalchemy. I hesitate to merge with confidence.
Use the below script to test it. from sqlalchemy import create_engine
from sqlalchemy.schema import MetaData, Column, Table
from trino.sqlalchemy.datatype import TIMESTAMP, TIME
engine = create_engine('trino://user@localhost:8080/memory/default')
metadata_obj = MetaData()
user = Table('test_time_timestamp', metadata_obj,
Column('col1', TIME(precision=6, timezone=False)),
Column('col2', TIMESTAMP(precision=3, timezone=True))
)
metadata_obj.create_all(engine)
It's a good candidate to create a new issue. |
@hovaesco Thanks for providing the code. Could you test with |
b039b35
to
a8a0026
Compare
Thanks for spotting this out @ebyhr. I fixed it and added an assertion. |
a8a0026
to
a5cf57f
Compare
LGTM pending ebyhr approval. |
a5cf57f
to
b7a59a0
Compare
Merge, thanks! |
First point from #107