Skip to content

Conversation

@alfiyas-datahub
Copy link
Contributor

Summary

  • Fixed SQL statement splitter incorrectly treating closing parentheses from function calls (e.g., GETDATE()) as CTE indicators.
  • The _has_preceding_cte() method now checks that the statement actually starts with WITH before assuming a CTE context.
  • Added regression test for this scenario.

…s with parentheses

Fixed SQL statement splitter incorrectly treating closing parentheses from
function calls (e.g., GETDATE()) as CTE indicators. The _has_preceding_cte()
method now checks that the statement actually starts with WITH before
assuming a CTE context.
@github-actions github-actions bot added the ingestion PR or Issue related to the ingestion of metadata label Dec 19, 2025
@github-actions
Copy link
Contributor

Linear: ING-1302

@codecov
Copy link

codecov bot commented Dec 19, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
12173 1 12172 82
View the top 1 failed test(s) by shortest run time
tests.unit.sql_parsing.test_split_statements::test_cte_with_select_not_split
Stack Traces | 0.007s run time
def test_cte_with_select_not_split():
        """
        Verify CTEs (WITH ... AS) followed by SELECT are kept together as one statement.
        This ensures the fix for parenthesis splitting doesn't break CTE handling.
        """
        test_sql = """\
        WITH temp_cte AS (
            SELECT * FROM source WHERE date > GETDATE()
        )
        SELECT * FROM temp_cte"""
    
        statements = [s.strip() for s in split_statements(test_sql)]
    
        assert len(statements) == 1
>       assert statements[0] == test_sql
E       AssertionError: assert 'WITH temp_cte AS (\n        SELECT * FROM source WHERE date > GETDATE()\n    )\n    SELECT * FROM temp_cte' == '    WITH temp_cte AS (\n        SELECT * FROM source WHERE date > GETDATE()\n    )\n    SELECT * FROM temp_cte'
E         
E         -     WITH temp_cte AS (
E         ? ----
E         + WITH temp_cte AS (
E                   SELECT * FROM source WHERE date > GETDATE()
E               )
E               SELECT * FROM temp_cte

.../unit/sql_parsing/test_split_statements.py:286: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@alwaysmeticulous
Copy link

alwaysmeticulous bot commented Dec 19, 2025

✅ Meticulous spotted 0 visual differences across 998 screens tested: view results.

Meticulous evaluated ~8 hours of user flows against your PR.

Expected differences? Click here. Last updated for commit ad40b76. This comment will update as new commits are pushed.

@codecov
Copy link

codecov bot commented Dec 19, 2025

Bundle Report

Bundle size has no change ✅

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

Labels

ingestion PR or Issue related to the ingestion of metadata needs-review Label for PRs that need review from a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants