Repository: meltano/sdk
Pull request #3065 (2025-05-28 15:58:55)

fix: Revert table name splitting by `-` in SQL targets when `default_target_schema` is set, introduced in #3020
Reverts #3020.

## Summary by Sourcery

Revert the special case that disabled hyphen splitting for SQL table names when default_target_schema is set, restoring splitting behavior and updating tests.

Bug Fixes:
- Remove the conditional that prevented stream names from being split by hyphens when default_target_schema is provided

Tests:
- Adjust expected table names in SQL sink tests to reflect hyphen splitting for two- and three-part stream names

sourcery-ai[bot]: <!-- Generated by sourcery-ai[bot]: start review_guide -->

🧙 Sourcery is reviewing your pull request!

---

<details>
<summary>Tips and commands</summary>

#### Interacting with Sourcery

- **Trigger a new review:** Comment `@sourcery-ai review` on the pull request.
- **Continue discussions:** Reply directly to Sourcery's review comments.
- **Generate a GitHub issue from a review comment:** Ask Sourcery to create an
  issue from a review comment by replying to it. You can also reply to a
  review comment with `@sourcery-ai issue` to create an issue from it.
- **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull
  request title to generate a title at any time. You can also comment
  `@sourcery-ai title` on the pull request to (re-)generate the title at any time.
- **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in
  the pull request body to generate a PR summary at any time exactly where you
  want it. You can also comment `@sourcery-ai summary` on the pull request to
  (re-)generate the summary at any time.
- **Generate reviewer's guide:** Comment `@sourcery-ai guide` on the pull
  request to (re-)generate the reviewer's guide at any time.
- **Resolve all Sourcery comments:** Comment `@sourcery-ai resolve` on the
  pull request to resolve all Sourcery comments. Useful if you've already
  addressed all the comments and don't want to see them anymore.
- **Dismiss all Sourcery reviews:** Comment `@sourcery-ai dismiss` on the pull
  request to dismiss all existing Sourcery reviews. Especially useful if you
  want to start fresh with a new review - don't forget to comment
  `@sourcery-ai review` to trigger a new review!

#### Customizing Your Experience

Access your [dashboard](https://app.sourcery.ai) to:
- Enable or disable review features such as the Sourcery-generated pull request
  summary, the reviewer's guide, and others.
- Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.

#### Getting Help

- [Contact our support team](mailto:support@sourcery.ai) for questions or feedback.
- Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information.
- Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).

</details>

<!-- Generated by sourcery-ai[bot]: end review_guide -->
codspeed-hq[bot]: <!-- __CODSPEED_PERFORMANCE_REPORT_COMMENT__ -->
<!-- __CODSPEED_INSTRUMENTATION_PERFORMANCE_REPORT_COMMENT__ -->

## [CodSpeed Performance Report](https://codspeed.io/meltano/sdk/branches/edgarrmondragon%2Frevert%2F3020-split-schema-table-name-default-target-schema)

### Merging #3065 will **not alter performance**

<sub>Comparing <code>edgarrmondragon/revert/3020-split-schema-table-name-default-target-schema</code> (53ab3a2) with <code>main</code> (f89f179)</sub>



### Summary

`✅ 8` untouched benchmarks  





Patch:
diff --git a/singer_sdk/sinks/sql.py b/singer_sdk/sinks/sql.py
index 43d7a7cc..28256282 100644
--- a/singer_sdk/sinks/sql.py
+++ b/singer_sdk/sinks/sql.py
@@ -90,9 +90,6 @@ class SQLSink(BatchSink, t.Generic[_C]):
         Returns:
             The target table name.
         """
-        if self.default_target_schema:
-            return self.stream_name
-
         parts = self.stream_name.split("-")
         table = self.stream_name if len(parts) == 1 else parts[-1]
         return self.conform_name(table, "table")


Test patch:
diff --git a/tests/core/sinks/test_sql_sink.py b/tests/core/sinks/test_sql_sink.py
index 7eaf8f93..2522ea45 100644
--- a/tests/core/sinks/test_sql_sink.py
+++ b/tests/core/sinks/test_sql_sink.py
@@ -99,14 +99,14 @@ class TestDuckDBSink:
             pytest.param(
                 "foo-bar",  # stream_name
                 "test",  # default_target_schema
-                "foo-bar",  # expected_table_name
+                "bar",  # expected_table_name
                 "test",  # expected_schema_name
                 id="default-schema-2-part",
             ),
             pytest.param(
                 "foo-bar-baz",  # stream_name
                 "test",  # default_target_schema
-                "foo-bar-baz",  # expected_table_name
+                "baz",  # expected_table_name
                 "test",  # expected_schema_name
                 id="default-schema-3-part",
             ),