Skip to content

[v3-4-test] Fix log template sync failing when a custom SQL Alchemy schema is configured (#70793) - #75194

Merged
vatsrahul1001 merged 2 commits into
v3-4-testfrom
backport-6aee277-v3-4-test
Oct 20, 2026
Merged

vatsrahul1001 merged 2 commits into
v3-4-testfrom
backport-6aee277-v3-4-test

Conversation

@github-actions

Copy link
Copy Markdown
Contributor
  • Fix log template sync failing when a custom SQL Alchemy schema is configured

When sql_alchemy_schema is set, reflect_tables() derived the schema to
reflect a mapped class's table under by splitting its bare tablename
on a dot, which discards the schema entirely for classes like
LogTemplate whose table name has no dot. synchronize_log_template()
then looked up the reflected table by that same bare name, which also
does not match how SQLAlchemy keys schema-qualified tables in the
reflected metadata. Together these left the log_template table
unrecognized under a custom schema, causing triggering a Dag to fail
with a TypeError.

Derive the schema from the mapped class's own configured table instead
of parsing its name, and look the reflected table up by its schema
-qualified key.

  • Add newsfragment for log template custom schema fix

  • Remove newsfragment for log template custom schema fix

Not needed for this change per review feedback.

  • Use inspect().local_table instead of getattr for the mapped class's schema

getattr(tbl, "table") worked around table not being declared on
MappedClassProtocol, but SQLAlchemy's inspect() already exposes the same
table through a properly typed Mapper.local_table, so the getattr and its
explanatory comment are no longer needed.
(cherry picked from commit 6aee277)

Co-authored-by: Aaryan Mahajan aaryanmhjn@gmail.com

…chema is configured (#70793)

* Fix log template sync failing when a custom SQL Alchemy schema is configured

When sql_alchemy_schema is set, reflect_tables() derived the schema to
reflect a mapped class's table under by splitting its bare __tablename__
on a dot, which discards the schema entirely for classes like
LogTemplate whose table name has no dot. synchronize_log_template()
then looked up the reflected table by that same bare name, which also
does not match how SQLAlchemy keys schema-qualified tables in the
reflected metadata. Together these left the log_template table
unrecognized under a custom schema, causing triggering a Dag to fail
with a TypeError.

Derive the schema from the mapped class's own configured table instead
of parsing its name, and look the reflected table up by its schema
-qualified key.

* Add newsfragment for log template custom schema fix

* Remove newsfragment for log template custom schema fix

Not needed for this change per review feedback.

* Use inspect().local_table instead of getattr for the mapped class's schema

getattr(tbl, "__table__") worked around __table__ not being declared on
MappedClassProtocol, but SQLAlchemy's inspect() already exposes the same
table through a properly typed Mapper.local_table, so the getattr and its
explanatory comment are no longer needed.
(cherry picked from commit 6aee277)

Co-authored-by: Aaryan Mahajan <aaryanmhjn@gmail.com>
@vatsrahul1001
vatsrahul1001 merged commit d12c9a0 into v3-4-test Oct 20, 2026
78 checks passed
@vatsrahul1001
vatsrahul1001 deleted the backport-6aee277-v3-4-test branch October 20, 2026 09:36
@github-actions github-actions Bot added this to the Airflow 3.4.1 milestone Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Hi maintainer, this PR was merged without a milestone set.
We've automatically set the milestone to Airflow 3.4.1 based on: bug fix merged to version branch
If this milestone is not correct, please update it to the appropriate milestone.

This comment was generated by Milestone Tag Assistant.

vatsrahul1001 added a commit that referenced this pull request Oct 20, 2026
…chema is configured (#70793) (#75194)

* Fix log template sync failing when a custom SQL Alchemy schema is configured

When sql_alchemy_schema is set, reflect_tables() derived the schema to
reflect a mapped class's table under by splitting its bare __tablename__
on a dot, which discards the schema entirely for classes like
LogTemplate whose table name has no dot. synchronize_log_template()
then looked up the reflected table by that same bare name, which also
does not match how SQLAlchemy keys schema-qualified tables in the
reflected metadata. Together these left the log_template table
unrecognized under a custom schema, causing triggering a Dag to fail
with a TypeError.

Derive the schema from the mapped class's own configured table instead
of parsing its name, and look the reflected table up by its schema
-qualified key.

* Add newsfragment for log template custom schema fix

* Remove newsfragment for log template custom schema fix

Not needed for this change per review feedback.

* Use inspect().local_table instead of getattr for the mapped class's schema

getattr(tbl, "__table__") worked around __table__ not being declared on
MappedClassProtocol, but SQLAlchemy's inspect() already exposes the same
table through a properly typed Mapper.local_table, so the getattr and its
explanatory comment are no longer needed.
(cherry picked from commit 6aee277)

Co-authored-by: Aaryan Mahajan <aaryanmhjn@gmail.com>
Co-authored-by: Rahul Vats <43964496+vatsrahul1001@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants