-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add table_kwargs
context manager to make pandas/Dask support CrateDB's special SQL DDL options
#139
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
amotl
force-pushed
the
amo/polyfill
branch
2 times, most recently
from
June 23, 2024 23:08
11076e8
to
5e39bbf
Compare
amotl
force-pushed
the
amo/support-table-kwargs
branch
2 times, most recently
from
June 23, 2024 23:59
b9af9da
to
7c9bd96
Compare
amotl
changed the title
Add
Add Jun 24, 2024
table_kwargs
context manager to make pandas/Dask support dialecttable_kwargs
context manager to make pandas/Dask support CrateDB's special SQL DDL options
amotl
force-pushed
the
amo/support-table-kwargs
branch
from
June 24, 2024 00:06
7c9bd96
to
a9855aa
Compare
amotl
force-pushed
the
amo/support-table-kwargs
branch
from
June 24, 2024 00:11
a9855aa
to
5c03117
Compare
amotl
force-pushed
the
amo/support-table-kwargs
branch
3 times, most recently
from
June 24, 2024 00:40
96d10a3
to
a8a61b9
Compare
matriv
reviewed
Jun 24, 2024
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.
Left some comments, thx!
amotl
commented
Jun 24, 2024
amotl
force-pushed
the
amo/support-table-kwargs
branch
from
June 24, 2024 09:59
bd92e0c
to
32c16b3
Compare
matriv
approved these changes
Jun 24, 2024
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.
LGTM, thx!
amotl
force-pushed
the
amo/polyfill
branch
3 times, most recently
from
June 24, 2024 14:15
ad9b870
to
a2898da
Compare
Unlock SQLAlchemy ORM's `__table_args__` on the pandas/Dask `to_sql()` interface, in order to support CrateDB's special SQL DDL options. Co-authored-by: Marios Trivyzas <5058131+matriv@users.noreply.github.com>
amotl
force-pushed
the
amo/support-table-kwargs
branch
from
June 24, 2024 14:27
32c16b3
to
1fe1488
Compare
This was referenced Jun 26, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In certain cases where SQLAlchemy orchestration is implemented within a framework, like at this spot 1 in pandas'
SQLTable._create_table_setup
, it is not easily possible to forward SQLAlchemy dialect options at table creation time.Idea
Unlock SQLAlchemy ORM's
__table_args__
on the pandas/Daskto_sql()
interface, in order to support CrateDB's special SQL DDL options.Solution
In order to augment the SQL DDL statement to make it honor database-specific dialect options, the only way to work around the unfortunate situation is by monkey-patching the call to
sa.Table()
at runtime, relaying additional dialect options through corresponding keyword arguments in their original<dialect>_<kwarg>
format 2.Synopsis
Using a context manager incantation like
with table_kwargs(crate_partitioned_by="time")
will render aPARTITIONED BY ("time")
SQL clause, without touching the call site ofsa.Table(...)
.Documentation
Preview: https://sqlalchemy-cratedb--139.org.readthedocs.build/support.html#context-manager-table-kwargs
References
ctk load table
interface cratedb-toolkit#149Backlog
Footnotes
https://github.com/pandas-dev/pandas/blob/v2.2.2/pandas/io/sql.py#L1282-L1285 ↩
https://docs.sqlalchemy.org/en/20/core/foundation.html#sqlalchemy.sql.base.DialectKWArgs.dialect_kwargs ↩