Skip to content
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

render func.sysdate as SYSDATE() #394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/snowflake/sqlalchemy/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class SnowflakeCompiler(compiler.SQLCompiler):
def visit_sequence(self, sequence, **kw):
return self.dialect.identifier_preparer.format_sequence(sequence) + ".nextval"

def visit_sysdate_func(self, sysdate, **kw):
return "SYSDATE()"

def visit_merge_into(self, merge_into, **kw):
clauses = " ".join(
clause._compiler_dispatch(self, **kw) for clause in merge_into.clauses
Expand Down
10 changes: 9 additions & 1 deletion tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
#

from sqlalchemy import Integer, String, and_, select
from sqlalchemy import Integer, String, and_, func, select
from sqlalchemy.schema import DropColumnComment, DropTableComment
from sqlalchemy.sql import column, quoted_name, table
from sqlalchemy.testing import AssertsCompiledSQL
Expand All @@ -23,6 +23,14 @@
class TestSnowflakeCompiler(AssertsCompiledSQL):
__dialect__ = "snowflake"

def test_sysdate(self):
statement = select(func.sysdate())
self.assert_compile(
statement,
"SELECT SYSDATE() AS sysdate_1",
dialect="snowflake",
)

def test_multi_table_delete(self):
statement = table1.delete().where(table1.c.id == table2.c.id)
self.assert_compile(
Expand Down