Fix SQLCompiler INSERT/FROM and slot AS direction (#48)#255
Open
amc-corey-cox wants to merge 1 commit into
Open
Fix SQLCompiler INSERT/FROM and slot AS direction (#48)#255amc-corey-cox wants to merge 1 commit into
amc-corey-cox wants to merge 1 commit into
Conversation
The FROM clause used the target class name, producing self-INSERTs that silently inserted zero rows. The slot-level alias direction was also inverted, referencing target column names in the source table. Existing test_compile previously passed because the two inverted bugs balanced column counts by accident; with correct SQL the test exposes SQLCompiler's missing target-column-shape handling (tracked in #150).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes two correctness issues in SQLCompiler that previously produced self-INSERT statements and inverted column aliasing, preventing data from being inserted from the intended source tables. It also adds focused regression tests to validate the corrected SQL output and a minimal end-to-end execution against DuckDB.
Changes:
- Fix
FROMclause generation to useClassDerivation.populated_from(falling back tocd.name). - Fix slot alias emission to
source_expr AS target_slot(instead of the inverted form). - Add targeted tests for
FROMbehavior, alias direction, and a minimal DuckDB execution smoke test; adjust the broadertest_compileto avoid executing INSERTs pending #150.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/linkml_map/compiler/sql_compiler.py |
Corrects the generated SELECT’s FROM table and slot alias direction to match the transformation specification semantics. |
tests/test_compiler/test_duckdb_compiler.py |
Adds regression + end-to-end tests for the SQLCompiler fixes and updates the existing compile smoke test to avoid the known #150 limitation. |
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.
Closes #48.
FROMclause now usescd.populated_from(falling back tocd.name) instead of the target class nametarget AS sourcetosource AS targetThe two bugs balanced column counts in
test_compile, hiding both. With the fix, that test surfaces SQLCompiler's missing target-shape handling (#150) — the INSERT execution is dropped fromtest_compilewith a TODO pointer; coverage moves to focused tests below.Test plan
test_from_clause_uses_class_populated_from— asserts FROM uses source classtest_slot_aliased_source_as_target— asserts AS direction issource AS targettest_compiled_sql_executes_against_duckdb— end-to-end: source rows land in target on a minimal specuv run pytest— 831 passed, 4 skippeduv run ruff check .anduv run ruff format --check .— clean