feat: add Google SQLCommenter support and ADK stale-session detection#408
Merged
feat: add Google SQLCommenter support and ADK stale-session detection#408
Conversation
Implements Google SQLCommenter spec: URL-encoded key-value pairs in lexicographically sorted SQL comments for query attribution. Includes generate_comment(), append_comment(), and parse_comment() with full round-trip fidelity.
Follows the existing extension pattern (otel, prometheus, etc.) rather than living at the top level.
- create_sqlcommenter_transformer() factory with static attr caching - StatementConfig gains enable_sqlcommenter, sqlcommenter_attributes, and sqlcommenter_enable_traceparent flags - Auto-constructs output_transformer with chaining support - W3C traceparent auto-population from OpenTelemetry span context - Move tests to extensions/test_sqlcommenter/
- SQLCommenterContext for request-scoped attribute storage - Litestar SQLCommenterMiddleware extracts route/controller/action - Starlette/FastAPI SQLCommenterMiddleware extracts route/action - Transformer enable_context flag reads from SQLCommenterContext - StatementConfig gains sqlcommenter_enable_context flag
- Move from sqlspec/extensions/sqlcommenter/ to sqlspec/core/sqlcommenter.py - Replace string-based comment manipulation with sqlglot AST (expression.add_comments) so sqlcommenter coexists with existing comments and optimizer hints - Change from output_transformer to statement_transformer (AST-level) - StatementConfig appends sqlcommenter transformer to statement_transformers instead of wrapping output_transformer - Included in mypyc compilation via existing core/**/*.py glob
… in SQLSpec session service
Oracle fixed their packaging — 9.6.0 ships cp312, cp313, and cp314 wheels. The exclude-newer-package constraint is no longer needed.
- Introduced configuration options for enabling SQLCommenter middleware in SQLSpecConfigState. - Updated SQLSpecPlugin to manage SQLCommenter middleware initialization based on configuration. - Implemented SQLCommenterMiddleware to capture SQL comments with correlation IDs. - Enhanced unit tests to cover SQLCommenter functionality and correlation ID integration. - Updated dependencies in lock file for compatibility with Python versions.
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
expression.add_comments()on the parsed expression tree, coexisting with existing SQL comments and optimizer hints (/*+ ... */)statement_transformer(AST-level), notoutput_transformer(string-level)