Skip to content

Conversation

@harshvardhan-j
Copy link
Contributor

@harshvardhan-j harshvardhan-j commented Dec 5, 2025

resolves #
#1059

Problem

If the model has event_time filters or micro-batch implemented the source_column_name returns the complete query for the relation like so

cast('(select * from "db"."sch"."em_bounces" where partition_date >= '2025-11-10 00:00:00+00:00' and partition_date < '2025-11-11 00:00:00+00:00')' as TEXT) as _dbt_source_relation,

This causes the macro to break and prevents setting up sampling and other related features.

This occurs because of the function in dbt-core here which is used in the str method that is used by dbt.string_literal.

Solution

Use the 'render' method on the relation to obtain the relevant information as a string literal rather than the str method of the relation.

It returns the expected SQL

WITH test_cte AS (



        (
            select
                cast('a.b.c' as TEXT) as source_system

Checklist

  • This code is associated with an issue which has been triaged and accepted for development.
  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • I have updated the README.md (if applicable)

@harshvardhan-j harshvardhan-j requested a review from a team as a code owner December 5, 2025 07:29
@harshvardhan-j
Copy link
Contributor Author

Hello,

Is it possible to get a review on this?

Thank you.

Copy link
Contributor

@joellabes joellabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice - thank you!

@joellabes joellabes added this pull request to the merge queue Dec 9, 2025
Merged via the queue into dbt-labs:main with commit 855e1e2 Dec 9, 2025
9 checks passed
@harshvardhan-j
Copy link
Contributor Author

Thank you @joellabes for merging it.

What's the release process like?

I'm trying to use this in my codebase, but unfortunately I cannot use the git revision owing to the duplicate project error.

If I could get a tag for the same it'll help.

Thank you once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants