You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromdatetimeimportdatetimeimportsnowflake.sqlalchemy.snowdialectfromsqlalchemyimportselect, Column, DateTime, INT, Stringfromsqlalchemy.ext.declarativeimportdeclarative_basefromsqlalchemy.sql.functionsimportrankBase=declarative_base()
classTestTbl(Base):
__tablename__="test"id=Column(INT, primary_key=True)
processing_timestamp=Column(DateTime(timezone=True), nullable=False)
booking_id=Column(INT, nullable=False)
description=Column(String)
if__name__=='__main__':
query=select(TestTbl.booking_id, TestTbl.description).filter(TestTbl.processing_timestamp>datetime(2023,3,5))
a=rank().over(partition_by=TestTbl.booking_id,
order_by=[TestTbl.booking_id, TestTbl.processing_timestamp.desc(), TestTbl.id.desc()]
) ==1qry=query.having(a)
actual=qry.compile(dialect=snowflake.sqlalchemy.snowdialect.dialect(), compile_kwargs={'literal_binds': True})
print(str(actual))
# prints# SELECT test.booking_id, test.description # FROM test # WHERE test.processing_timestamp > '2023-03-05 00:00:00.000000' # HAVING rank() OVER (PARTITION BY test.booking_id ORDER BY test.booking_id, test.processing_timestamp DESC, test.id DESC) = 1
What did you expect to see?
should print
SELECT test.booking_id, test.description
FROM test
WHERE test.processing_timestamp > '2023-03-05 00:00:00.000000'
QUALIFY rank() OVER (PARTITION BY test.booking_id ORDER BY test.booking_id, test.processing_timestamp DESC, test.id DESC) = 1
Can you set logging to DEBUG and collect the logs?
N/A. This example doesn't log anything
The text was updated successfully, but these errors were encountered:
Hey this is useful feature and we will add to our backlog, but we won't be able to prioritize this unfortunately. If you are open to create a PR, we will be happy to review!
Currently, I don't see any way that the
QUALIFY
clause is supported.Python 3.8.12 (default, Nov 5 2021, 11:45:44)
[Clang 13.0.0 (clang-1300.0.29.3)]
macOS-13.5-x86_64-i386-64bit
pip freeze
)?should print
Can you set logging to DEBUG and collect the logs?
N/A. This example doesn't log anything
The text was updated successfully, but these errors were encountered: