Skip to content

Recursive CTEs treated as an external model #5614

@siddharth-sc1903

Description

@siddharth-sc1903

SQLMesh version: 0.224.0
Dialect: Databricks

Despite using WITH RECURSIVE, SQLMesh/SQLGlot still treats the CTE name as an external model.

Model:
MODEL (
name silver.test_recursive_cte,
kind FULL,
cron "@daily"
);

WITH RECURSIVE number_series (n) AS (
SELECT 1 AS n
UNION ALL
SELECT n + 1 FROM number_series WHERE n < 10
)
SELECT n AS number_value FROM number_series;Error:

sqlmesh plan

Error: [TABLE_OR_VIEW_NOT_FOUND] The table or view number_series cannot be found. Verify the
spelling and correctness of the schema and catalog.
If you did not qualify the name with a schema, verify the current_schema() output, or
qualify the name with the correct schema and catalog.
To tolerate the error on drop use DROP VIEW IF EXISTS or DROP TABLE IF EXISTS. SQLSTATE:
42P01; line 1 pos 350

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions