-
Notifications
You must be signed in to change notification settings - Fork 116
Use SQLAlchemy 2.0's type_compiler_cls and type_compiler_instance #895
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| from typing import ( | ||
| TYPE_CHECKING, | ||
| Any, | ||
| ClassVar, | ||
| cast, | ||
| ) | ||
|
|
||
|
|
@@ -143,7 +144,7 @@ class AthenaDialect(DefaultDialect): | |
| preparer: type[IdentifierPreparer] = AthenaDMLIdentifierPreparer | ||
| statement_compiler: type[SQLCompiler] = AthenaStatementCompiler | ||
| ddl_compiler: type[DDLCompiler] = AthenaDDLCompiler | ||
| type_compiler: type[GenericTypeCompiler] = AthenaTypeCompiler | ||
| type_compiler_cls: ClassVar[type[GenericTypeCompiler]] = AthenaTypeCompiler | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Independent review, relayed. The reviewer was Codex CLI 0.157.1 ( Scope: the full diff at e273459 in a detached snapshot. The prompt did not include the PR number, PR body, commit message, or earlier findings. Static review only: no builds or tests. Result: CLEAN. "No actionable findings in the specified diff." Covered: SQLAlchemy 2.0.46's |
||
| default_paramstyle: str = pyathena.paramstyle | ||
| max_identifier_length: int = 255 | ||
| cte_follows_insert: bool = True | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1182,7 +1182,7 @@ def get_column_specification(self, column: Column[Any], **kwargs) -> str: | |
| type_ = "INT" | ||
| else: | ||
| # type_expression marks column DDL so STRUCT and MAP use Hive syntax. | ||
| type_ = self.dialect.type_compiler.process(column.type, type_expression=column) | ||
| type_ = self.dialect.type_compiler_instance.process(column.type, type_expression=column) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Self-review round two (claims, callers, and operations), by the authoring model; not an independent review. Scope: the same base and head, plus the PR body, the commit message, and #894. Result: CLEAN. Claims checked:
Callers:
Operations: no AWS behavior changes; this changes only how the dialect selects its type compiler. |
||
| text = [f"{self.preparer.format_column(column)} {type_}"] | ||
| if column.comment: | ||
| text.append(f"{self._get_comment_specification(column.comment)}") | ||
|
|
||
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.
Self-review round one (behavior and implementation), by the authoring model; not an independent review.
Scope: base cf673c2, head e273459, all 3 changed files.
Result: CLEAN.
Checked:
DefaultDialect.__init__resolveslegacy_tt_callable = getattr(self, 'type_compiler', None)beforetype_compiler_cls. No class in the dialect hierarchy definestype_compilerany more (git grepfinds it only in the new test). The test asserts this forAthenaDialectandAthenaAioDialect, and the pandas, arrow, polars, s3fs, and rest dialects inherit from them.type_compiler_instanceand the instance-leveltype_compilerare the same object (default.py:self.type_compiler_instance = self.type_compiler = tt_callable(self)), soget_column_specificationrenders the same DDL. On real Athena, 59 create_table and dialect tests passed (sync and aio).ClassVar[type[GenericTypeCompiler]]matches SQLAlchemy'sClassVar[Type[TypeCompiler]]declaration; mypy passes.