feat: Allow SQL targets to customize how they parse <db>-<schema>-<table> and <schema>-<table> stream names explicitly - #3776
edgarrmondragon wants to merge 4 commits into
Conversation
…able>` and `<schema>-<table>` stream names explicitly Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Reviewer's GuideIntroduces a centralized, overridable SQL stream-name parser and uses a SQLite-specific implementation to fold qualified stream names into physical tables, with tests updated to validate successful schema-qualified loads. Sequence diagram for SQLite qualified stream-name foldingsequenceDiagram
participant Stream as Stream name
participant SQLiteSink
participant SQLSink
participant SQLiteDB as SQLite database
Stream->>SQLiteSink: parse_stream_name(stream_name)
SQLiteSink->>SQLSink: parse_stream_name(stream_name)
SQLSink-->>SQLiteSink: db_name, schema_name, table_name
SQLiteSink-->>SQLiteSink: filter main/temp and join qualifiers with __
SQLiteSink-->>SQLiteSink: return None, None, folded_table_name
SQLiteSink->>SQLiteDB: load into folded physical table
Flow diagram for SQL stream-name component resolutionflowchart LR
A[stream_name] --> B[SQLSink.parse_stream_name]
B --> C[stream_name_parts]
C --> D[table_name]
C --> E[schema_name]
C --> F[database_name]
B --> G[SQLiteSink.parse_stream_name]
G --> H[Drop main/temp qualifiers]
H --> I[Join remaining qualifiers with __]
I --> J[SQLite physical table name]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Documentation build overview
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3776 +/- ##
=======================================
Coverage 94.47% 94.48%
=======================================
Files 74 74
Lines 6298 6309 +11
Branches 771 773 +2
=======================================
+ Hits 5950 5961 +11
Misses 260 260
Partials 88 88
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@sourcery-ai review |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="packages/meltano-target-sqlite/target_sqlite/target.py" line_range="136" />
<code_context>
+ for part in (db_name, schema_name)
+ if part and part.lower() not in self._default_schemas
+ ]
+ return None, None, "__".join([*qualifiers, table_name])
+
</code_context>
<issue_to_address>
**issue (bug_risk):** SQLite folds a qualified stream into a physical table name but the inherited `schema_name` still returns the configured `default_target_schema` whenever that setting is present. The sink then prepares and addresses the folded table under that SQLite schema, causing schema-qualified streams to fail with SQLite's unsupported schema handling instead of loading into the folded table.
**Triggers:** When the SQLite target configuration sets `default_target_schema` and the stream name contains a schema or database qualifier.
**Suggested fix:** Override `schema_name` for SQLite to always return `None`, or otherwise ensure the SQLite parser's folded representation takes precedence over `default_target_schema`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the parsing convention is wrong, records can be written to an unexpected physical table or with an unexpected folded name, and reverting will not remove or relocate those tables automatically. The misplaced data is bounded and can be repaired by moving or reloading it, rather than causing irreversible deletion or external side effects.
Blocking findings: packages/meltano-target-sqlite/target_sqlite/target.py:136
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
Signed-off-by: Edgar Ramírez Mondragón <edgarrm358@gmail.com>
a74a2de to
612a810
Compare
Related
<db>-<schema>-<name>,<schema>-<name>) #3777Summary by Sourcery
Enable customizable SQL stream-name parsing and adapt SQLite targets to represent qualifiers as physical table-name components.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: