Repository navigation
Conversation
TypeDecorator does not take python_type from its impl, so TIMESTAMP, TIMESTAMP_NTZ, TINYINT, DatabricksTimeType and DatabricksStringType fell back to the TypeEngine default: NotImplementedError on SQLAlchemy 2.0 and `object` on 2.1. TIMESTAMP, TIMESTAMP_NTZ and TINYINT are what column reflection returns for timestamp, timestamp_ntz and tinyint, so tools that read python_type from reflected columns (sqlacodegen, for one) got no usable type for them. Declare python_type on each of the five types, matching the values their process_result_value returns. Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
0z5a
requested review from
deeksha-db,
gopalldb,
jackyhu-db,
jayantsing-db,
jprakash-db,
samikshya-db,
shivam2680 and
vikrantpuppala
as code owners
November 21, 2026 16:32
This branch has not been deployed
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.
I started from #81 and checked it against the code.
What did you change, and why?
TypeDecoratordoes not takepython_typefrom itsimpl. Five of the dialect's types areTypeDecorators that don't declare it, so they report theTypeEnginedefault:NotImplementedErroron SQLAlchemy 2.0 andobjecton 2.1.python_typebeforeTIMESTAMPtimestampobject/ raisesdatetimeTIMESTAMP_NTZtimestamp_ntz, colspecs forDateTimeobject/ raisesdatetimeTINYINTtinyintobject/ raisesintDatabricksTimeTypeTimeobject/ raisestimeDatabricksStringTypeStringobject/ raisesstrEach type now declares
python_type, matching what itsprocess_result_valuereturns (or itsimplreturns, where there is noprocess_result_value).DatabricksArray,DatabricksMapandDatabricksVariantstill reportobject, as #81 explains: their values depend on connector settings.How I found it
From #81. I reproduced it offline on SQLAlchemy 2.1.9 (
objectfor all five) and 2.0.58 (NotImplementedErrorfor all five). As a control, the stock types they wrap,DateTime()andBigInteger(), reportdatetimeandinton both versions.Where this can show up in practice
The report in #81 is from generating ORM models with sqlacodegen:
TIMESTAMPandTINYINTcolumns came out asMapped[object | None]instead ofMapped[datetime | None]andMapped[int | None]. On SQLAlchemy 2.0, any code that readscolumn.type.python_typeon a reflectedtimestamp,timestamp_ntzortinyintcolumn gets aNotImplementedErrorinstead.How do you know it works?
TestPythonTypeintests/test_local/test_types.py:python_typefor the five typesGET_COLUMNS_TYPE_MAPexceptvariantreports a concrete type, so a type added to the map later is covered toomainwith SQLAlchemy 2.1.9, 8 of the new cases fail: the five types plus thetimestamp,timestamp_ntzandtinyintentries of the reflection map. The other 16 new cases pass.tests/test_local/test_types.pypasses on SQLAlchemy 2.1.9 and on 2.0.58 (83 tests each).tests/test_local, excludinge2e, pass on SQLAlchemy 2.1.9.black --check srcpasses.