Skip to content
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/google/adk/sessions/database_session_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
_MARIADB_DIALECT = "mariadb"
_MYSQL_DIALECT = "mysql"
_POSTGRESQL_DIALECT = "postgresql"
_DATABRICKS_DIALECT = "databricks"
# Tuple key order for in-process per-session lock maps:
# (app_name, user_id, session_id).
_SessionLockKey: TypeAlias = tuple[str, str, str]
Expand Down
6 changes: 6 additions & 0 deletions src/google/adk/sessions/schemas/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def load_dialect_impl(self, dialect: Dialect):
if dialect.name == "mysql":
# Use LONGTEXT for MySQL to address the data too long issue
return dialect.type_descriptor(mysql.LONGTEXT)
if dialect.name == "databricks":
# Databricks SQL stores JSON as STRING; use Text (the default)
return dialect.type_descriptor(Text)
Comment on lines +40 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This explicit check for the 'databricks' dialect is redundant. The default case on line 43 already returns dialect.type_descriptor(Text), which correctly handles the Databricks case (as noted in your comment). This if block can be removed to simplify the code without changing its behavior.

return dialect.type_descriptor(Text) # Default to Text for other dialects

def process_bind_param(self, value, dialect: Dialect):
Expand Down Expand Up @@ -64,4 +67,7 @@ class PreciseTimestamp(TypeDecorator):
def load_dialect_impl(self, dialect):
if dialect.name == "mysql":
return dialect.type_descriptor(mysql.DATETIME(fsp=6))
if dialect.name == "databricks":
# Databricks TIMESTAMP type natively supports microsecond precision
return dialect.type_descriptor(DateTime)
Comment on lines +70 to +72
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the DynamicJSON change, this explicit check for 'databricks' is redundant. The default implementation for this TypeDecorator is DateTime (via self.impl), and the fallback return self.impl on line 73 achieves the same result. This if block can be removed to make the code cleaner.

return self.impl
Loading