Repository navigation
feat: render SDK SQL through the Bruin CLI - #10
Draft
sabrikaragonen wants to merge 1 commit into
Draft
sabrikaragonen wants to merge 1 commit into
sabrikaragonen wants to merge 1 commit into
Conversation
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.
Both
bruin.query()andget_connection(...).query()now render SQL through the Bruin CLI before sending it to the existing Python database client. This enables Jinja and environment schema prefixes while preserving the selected connection, query annotations, and existing DataFrame/None behavior. The CLI only supplies SQL; database results stay in Python.The shared
_run_cli()helper handles binary selection (BRUIN_PATHor PATH), shell-free subprocess execution, stdin, environment forwarding, timeouts, and process errors. Render failures raiseQueryErrorbefore client initialization, with no fallback to the original SQL. Documentation and tests cover the process boundary and query execution.Pending CLI integration
This PR is prepared for the separate Bruin CLI render implementation. The command contract below is provisional and has not been validated against that implementation:
The SDK also passes
--environment, start/end dates,--full-refresh, and typed--var KEY=JSONvalues when present. It inherits the full environment and working directory, overriding only the child'sBRUIN_CONNECTIONwith the selected name.For the CLI agent: align
_render.py, its tests, and README with the final command/response contract; verify Jinja, schema prefixes, selected connection/environment, and inherited run context against a real CLI build. Ensure query-only rendering excludes materialization and asset hooks. Identify the compatible CLI release before merging/releasing this SDK change. No CLI code is changed here.Validation
uv run ruff check .anduv run ruff format --check .passed.uv run python -m pytest tests/ -q: 256 passed, 13 skipped.