Skip to content
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

Added Json type to the sqlalchemy parser #436

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/databricks/sqlalchemy/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def process_literal_param_hack(value: Any):
@compiles(sqlalchemy.types.Unicode, "databricks")
@compiles(sqlalchemy.types.UnicodeText, "databricks")
@compiles(sqlalchemy.types.Uuid, "databricks")
@compiles(sqlalchemy.types.JSON, "databricks")
def compile_string_databricks(type_, compiler, **kw):
"""
We override the default compilation for Enum(), String(), Text(), and Time() because SQLAlchemy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this comment as well - to match decorators list for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, adding this

Expand Down
1 change: 1 addition & 0 deletions src/databricks/sqlalchemy/test_local/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def test_numeric_renders_as_decimal_with_precision_and_scale(self):
sqlalchemy.types.INT: DatabricksDataType.INT,
sqlalchemy.types.SMALLINT: DatabricksDataType.SMALLINT,
sqlalchemy.types.TIMESTAMP: DatabricksDataType.TIMESTAMP,
sqlalchemy.types.JSON: DatabricksDataType.STRING,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Others with more knowledge can chime in, but I wonder if you need to do something similar to TinyIntegerTest to see if the type mapping will actually work. I think this addition makes sure the type will be recognized and translated, but I actually do not know how you would know the value is rendered as a literal string properly.

TINYINT: DatabricksDataType.TINYINT,
TIMESTAMP: DatabricksDataType.TIMESTAMP,
TIMESTAMP_NTZ: DatabricksDataType.TIMESTAMP_NTZ,
Expand Down
Loading