Skip to content

Conversation

hiroyukinakazato-db
Copy link

Changes

This PR adds the llm-transpile command for LLM-powered SQL conversion using the Switch transpiler.

What does this PR do?

Adds llm-transpile CLI command that runs Switch transpiler jobs with parameter passing support.

Relevant implementation details

CLI Integration:

  • Add llm-transpile command to Lakebridge CLI
  • Input source validation (workspace paths and local files)
  • Parameter passing to Switch job runs

Switch Runner Implementation:

  • SwitchConfig: manages Switch resources and job ID retrieval from InstallState
  • SwitchRunner: orchestrates Switch job execution with parameters

Testing:

  • Unit tests for Switch runner with parameter verification
  • Integration tests for Switch installation lifecycle

Development Environment:

  • Add .env to .gitignore for local development credentials

Caveats/things to watch out for when reviewing:

  • Parameter design: Follows transpile and recon command patterns
  • Catalog/schema usage: Uses values configured during Switch installation (following recon pattern)
  • Output parameter naming: Uses --output-ws-folder (not --output-folder) to explicitly indicate workspace folder
  • Dependencies: Requires PR Add Switch transpiler with --include-llm-transpiler flag #2066 (Switch installation) to be merged first

Linked issues

Resolves #2047

Functionality

  • added relevant user documentation
  • added new CLI command: databricks labs lakebridge llm-transpile
  • modified existing command

Tests

  • manually tested
  • added unit tests
  • added integration tests

hiroyukinakazato-db and others added 6 commits October 1, 2025 00:31
- Add Switch installer with resource configuration and job creation
- Implement uninstall functionality with proper cleanup
- Add comprehensive test coverage for SwitchInstaller
- Improve path handling and type-safe configuration
- Add include-llm-transpiler option for flexible installation
@hiroyukinakazato-db hiroyukinakazato-db added enhancement New feature or request feat/cli actions that are visible to the user labels Oct 6, 2025
Copy link

github-actions bot commented Oct 6, 2025

✅ 29/29 passed, 2 flaky, 2m17s total

Flaky tests:

  • 🤪 test_transpiles_informatica_with_sparksql (11.791s)
  • 🤪 test_transpile_sql_file (15.231s)

Running from acceptance #2615

Implement SwitchInstaller to integrate Switch transpiler with Lakebridge:
- Install Switch package to local virtual environment and deploy to workspace
- Create and manage Databricks job for Switch transpilation
- Configure Switch resources (catalog, schema, volume) interactively
- Support job-level parameters with JobParameterDefinition for flexibility
- Handle installation state and job lifecycle management
- Add comprehensive test suite covering installation, job management, and configuration
The SwitchInstaller was failing to find the config when the config.yml
used "Switch" (capitalized) as the name, while the code only checked
for "switch" (lowercase). This caused job creation to fail with a
"config.yml not found" error.

Updated _get_switch_job_parameters() to check both the display name
(capitalized) and transpiler ID (lowercase) to handle both cases.
@hiroyukinakazato-db hiroyukinakazato-db marked this pull request as ready for review October 8, 2025 02:15
@hiroyukinakazato-db hiroyukinakazato-db requested a review from a team as a code owner October 8, 2025 02:15
hiroyukinakazato-db and others added 7 commits October 9, 2025 11:13
Separates Switch transpiler's local installation logic from workspace
deployment, following established patterns (BladebridgeInstaller for
local installation, ReconDeployment for workspace deployment).

Key changes:
- Add SwitchDeployment class (~260 lines) for workspace operations
- Simplify SwitchInstaller to match BladebridgeInstaller pattern (~20 lines)
- Add include_llm and switch_resources fields to TranspileConfig
- Update WorkspaceInstallation to use SwitchDeployment
- Refactor tests to avoid protected member access using fixture separation
- Group Switch-related tests in TestSwitchInstallation class
Implement llm-transpile command for LLM-based code transpilation:
- Add SwitchInstaller for Switch transpiler package management
  - Install Switch package and deploy to workspace
  - Create and manage Databricks jobs with job-level parameters
  - Configure Switch resources (catalog, schema, volume)
- Add SwitchRunner for executing Switch transpilation jobs
  - Upload source files to workspace volume
  - Execute transpilation via Databricks job
  - Download results and handle job lifecycle
- Add llm-transpile CLI command with Switch transpiler support
- Add comprehensive unit and integration tests
Move _get_switch_package_path() from WorkspaceInstallation to SwitchDeployment
as a protected method, following Single Responsibility Principle. SwitchDeployment
now resolves its own package path internally.

Changes:
- Add _get_switch_package_path() protected method to SwitchDeployment
- Update SwitchDeployment.install() signature to remove path parameter
- Remove duplicate _get_switch_package_path() from WorkspaceInstallation
- Remove unused sys and TranspilerRepository imports from installation.py
- Update tests to use new interface with mocked path resolution
Update test_installation.py to match the refactored SwitchDeployment.install()
interface that now takes only resources parameter (path resolution is internal).

Changes:
- Remove switch_repository fixture parameter from test methods
- Delete unused _StubTranspilerRepository stub class
- Remove unused imports (Path, TranspilerRepository)
- Update assertions to check only resources argument

The tests verify that:
1. Switch installation uses configured resources correctly
2. Missing resources logs appropriate error message
Sync with main branch to incorporate latest documentation updates

# Conflicts:
#	labs.yml
The wait_for_completion option is intended for local CLI execution only
and should not be included in Databricks job parameters. This change
filters it out when building job parameter definitions.

Changes:
- Add excluded_options set to filter local-only options
- Skip wait_for_completion when converting config.yml options
- Add test using FriendOfSwitchDeployment pattern to verify exclusion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feat/cli actions that are visible to the user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add Switch transpiler CLI integration and testing

1 participant