Skip to content

Conversation

@anmolg1997
Copy link
Contributor

@anmolg1997 anmolg1997 commented Feb 10, 2026

Link to Issue or Description of Change

Problem:

The DatabaseSessionService schema types (DynamicJSON and PreciseTimestamp) only have explicit handling for PostgreSQL, MySQL, and SQLite dialects. Other dialects fall through to defaults, which may not be optimal.

Solution:

Adds explicit Databricks dialect handling to the DynamicJSON and PreciseTimestamp type decorators, and introduces a _DATABRICKS_DIALECT constant. This ensures schema types produce correct SQL types when used with a Databricks backend.

Changes:

  • DynamicJSON.load_dialect_impl(): explicit Text for Databricks (matches how Databricks stores JSON as STRING)
  • PreciseTimestamp.load_dialect_impl(): explicit DateTime for Databricks (native microsecond precision)
  • New _DATABRICKS_DIALECT = "databricks" constant

Note: The databricks-sqlalchemy driver currently lacks async support, so full DatabaseSessionService usage with Databricks requires a future async-capable driver. This change prepares the schema layer for that.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Existing dialect-related tests continue to pass:

$ pytest tests/unittests/sessions/test_session_service.py -k "dialect or pool_pre_ping" -v
5 passed in 0.85s

Adds dialect-specific handling for Databricks SQL in the session service
schema types (DynamicJSON and PreciseTimestamp), and introduces a
_DATABRICKS_DIALECT constant for future use.

This ensures the TypeDecorator classes explicitly handle the Databricks
dialect rather than falling through to default TEXT behavior. While the
databricks-sqlalchemy driver currently lacks async support, this change
prepares the codebase for when async compatibility is available.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @anmolg1997, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the DatabaseSessionService by adding explicit awareness and handling for the Databricks SQL dialect. Previously, schema types like DynamicJSON and PreciseTimestamp only had specific implementations for PostgreSQL, MySQL, and SQLite, falling back to generic defaults for other dialects. This change ensures that when used with a Databricks backend, these schema types generate the correct underlying SQL types, preparing the schema layer for future integration with an async-capable Databricks driver.

Highlights

  • Databricks Dialect Constant: Introduced a new _DATABRICKS_DIALECT constant to explicitly identify the Databricks dialect within the session service.
  • DynamicJSON Type Handling: Added explicit handling for the Databricks dialect in DynamicJSON.load_dialect_impl(), ensuring JSON data is stored as Text (STRING) in Databricks SQL, aligning with its native storage mechanism.
  • PreciseTimestamp Type Handling: Implemented specific logic for the Databricks dialect in PreciseTimestamp.load_dialect_impl(), utilizing the native DateTime type which supports microsecond precision in Databricks.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/sessions/database_session_service.py
    • Added _DATABRICKS_DIALECT constant.
  • src/google/adk/sessions/schemas/shared.py
    • Updated DynamicJSON.load_dialect_impl to return Text for Databricks dialect.
    • Updated PreciseTimestamp.load_dialect_impl to return DateTime for Databricks dialect.
Activity
  • The author has confirmed that existing dialect-related unit tests continue to pass after these changes.
  • The author has indicated that new or updated unit tests were not added, but existing tests cover the dialect changes.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds dialect awareness for Databricks. While the intention is good, the specific implementations for DynamicJSON and PreciseTimestamp introduce redundant code, as the existing default logic already handles the Databricks dialect correctly. My feedback includes suggestions to remove this redundant code for better clarity and maintainability.

Comment on lines +40 to +42
if dialect.name == "databricks":
# Databricks SQL stores JSON as STRING; use Text (the default)
return dialect.type_descriptor(Text)
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.

Comment on lines +70 to +72
if dialect.name == "databricks":
# Databricks TIMESTAMP type natively supports microsecond precision
return dialect.type_descriptor(DateTime)
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.

@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants