-
Notifications
You must be signed in to change notification settings - Fork 98
Support for array join and final modifier in sqlalchemy #584
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
base: main
Are you sure you want to change the base?
Support for array join and final modifier in sqlalchemy #584
Conversation
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.
Pull Request Overview
Adds SQLAlchemy core API support for ClickHouse-specific features: ARRAY JOIN clauses and FINAL modifier for ReplacingMergeTree tables.
- Introduces
array_join()function andArrayJoinclass for handling ClickHouse ARRAY JOIN operations - Adds
final()function andSelect.final()method to apply FINAL modifier for ReplacingMergeTree tables - Extends SQL compiler to properly render these ClickHouse-specific SQL constructs
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
clickhouse_connect/cc_sqlalchemy/sql/clauses.py |
Implements ArrayJoin class and array_join() function for ARRAY JOIN support |
clickhouse_connect/cc_sqlalchemy/sql/__init__.py |
Adds final() function and monkey-patches Select class with .final() method |
clickhouse_connect/cc_sqlalchemy/sql/compiler.py |
Extends compiler to handle ArrayJoin and FINAL hint rendering |
clickhouse_connect/cc_sqlalchemy/__init__.py |
Exports new array_join, ArrayJoin, and final symbols |
tests/integration_tests/test_sqlalchemy/test_array_join.py |
Integration tests for ARRAY JOIN functionality |
tests/integration_tests/test_sqlalchemy/test_ddl.py |
Tests for FINAL modifier with error case validation |
tests/integration_tests/test_sqlalchemy/test_select.py |
Additional test for argMax aggregate function |
tests/integration_tests/test_sqlalchemy/conftest.py |
Helper functions for table creation in tests |
README.md |
Updates feature list to mention ARRAY JOIN and FINAL support |
CHANGELOG.md |
Documents the new feature addition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert rows[1].latest_name == "Bob_v2" | ||
| assert rows[1].latest_value == 250 | ||
|
|
||
| test_table.drop(conn) |
Copilot
AI
Oct 31, 2025
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.
The table drop operation is redundant since the test uses table_context which already handles cleanup. This line should be removed to avoid duplication.
| test_table.drop(conn) |
Summary
Adds support to the SQLAlchemy core API for:
[LEFT] ARRAY JOINs e.g.FINALmodifier for use withReplacing*tablesExamples
Assume this is our table:
ARRAY JOINNow you can build a query like
This will result in:
LEFT ARRAY JOINSimilarly, a
LEFT ARRAY JOIN:This will result in:
FINALmodifierAssume we have this table in a
ReplacingMergeTreetableNow you can use the
.final()method to ensureFINALis included in the generated SQL, forcing ClickHouse to fully merge the data at query time. Use it like this:This will generate SQL like:
Checklist
Delete items not relevant to your PR:
Closes #579