Skip to content

Commit cfd21b2

Browse files
override get_from_hint_text to include FINAL
1 parent 9c6acf5 commit cfd21b2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

clickhouse_connect/cc_sqlalchemy/sql/compiler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,8 @@ def visit_empty_set_expr(self, element_types, **kw):
8383

8484
def visit_sequence(self, sequence, **kw):
8585
raise NotImplementedError("ClickHouse doesn't support sequences")
86+
87+
def get_from_hint_text(self, table, text):
88+
if text == "FINAL":
89+
return "FINAL"
90+
return super().get_from_hint_text(table, text)

tests/integration_tests/test_sqlalchemy/test_ddl.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,8 @@ def test_final_modifier_replacing_merge_tree(test_engine: Engine, test_db: str):
123123

124124
query_with_final = select(test_table).final().order_by(test_table.c.id)
125125
compiled = query_with_final.compile(dialect=test_engine.dialect)
126-
127-
# In low-load test envs, the merge usually happens so fast that FINAL doesn't
128-
# seem to make a difference, but the important part is seeing FINAL in the
129-
# actual compiled compiled query.
130-
assert "FINAL" in str(compiled).upper()
126+
compiled_str = str(compiled)
127+
assert " FINAL" in compiled_str
131128
result = conn.execute(query_with_final)
132129
rows = result.fetchall()
133130
assert len(rows) == 2

0 commit comments

Comments
 (0)