Repository navigation
Conversation
HiveDialect didn't define colspecs, so it inherited sqlalchemy.engine.default.DefaultDialect.colspecs directly -- the exact same dict object, not a copy. Every SQLAlchemy built-in dialect (postgresql, mysql, etc.) defines its own colspecs for this reason: a mutation like HiveDialect.colspecs[SomeType] = ... -- a normal way to customize type rendering per dialect -- otherwise corrupts type handling for every other dialect sharing the inherited default, for the rest of the process. This is a real downstream hit, not a hypothetical: apache/superset's Databricks engine spec patches colspecs on HiveDialect (PyHive's Databricks support subclasses it) and the shared-object aliasing broke type compilation for ~38 unrelated dialects loaded in the same process until Superset worked around it on its own side (apache/superset#44707). Verified directly: >>> HiveDialect.colspecs is DefaultDialect.colspecs True # before this fix False # after Zero behavior change otherwise -- colspecs was and remains empty for this dialect, it's just no longer the same object as the default's. Co-Authored-By: Evan Rusackas <evan@preset.io> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or 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
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.
Summary
HiveDialectnever defines its owncolspecs, so it inheritssqlalchemy.engine.default.DefaultDialect.colspecsdirectly -- the exact same dict object, not a copy:Every SQLAlchemy built-in dialect (
postgresql,mysql, etc.) defines its owncolspecsdict, even when there's nothing to override yet, specifically to avoid this. The reason: mutating a dialect'scolspecsin place (HiveDialect.colspecs[SomeType] = ...) is a completely normal way to customize how a type renders for one dialect. Without its own dict, that mutation silently corrupts type handling for every other dialect in the process that also hasn't defined its owncolspecs-- not just Hive.This isn't hypothetical. Apache Superset's Databricks engine spec (which subclasses PyHive's
HiveDialectfor Databricks support) patchesHiveDialect.colspecs[types.String] = ...to customize string-type handling. Because of the shared object, that one line broke type compilation for ~38 unrelated third-party dialects loaded in the same process, until Superset worked around it on its own side: apache/superset#44707.Fix
Give
HiveDialectits own (currently empty)colspecsdict, same as every SQLAlchemy built-in dialect does:Verified this fully isolates it with no other behavior change --
colspecswas and remains empty for this dialect; it's just no longer the same object asDefaultDialect's:Testing
pyhive/tests/test_sqlalchemy_hive.pyrequires a live Hive server onlocalhost:10000, which I didn't have available to run the full suite. This change touches only a class-level attribute with no effect on connection or query logic, so I'm confident it's safe, but flagging that I couldn't run the existing integration tests end to end.馃 Generated with Claude Code