-
Notifications
You must be signed in to change notification settings - Fork 361
Open
Description
On version 0.214.0 of SQL Mesh and 27.9.0 of SQL Glot, column names are not resolved correctly for Snowflake in the builtin audit, unique_values_audit().
This model was working previously on version 0.193.1
We have a model that looks like this:
MODEL (
name extra.sidetrade.customer_items,
kind VIEW,
description 'SideTrade BFF Table',
cron '20 11 * * *',
grain "Item functional number",
audits (NOT_NULL(columns := (
"Item functional number"
)), UNIQUE_VALUES(columns := (
"Item functional number"
)))
);
WITH CUSTOMERS AS (
SELECT
*
FROM EXTRA.SIDETRADE_PREP.COMBINED_DATA
QUALIFY
ROW_NUMBER() OVER (PARTITION BY TECHNICAL_CUSTOMER_CODE ORDER BY SFDC_CREATED_DATE) = 1
)
SELECT
LEFT(CS.TECHNICAL_CUSTOMER_CODE::VARCHAR, 64) AS "Technical Customer Code",
LEFT(CS.FUNCTIONAL_CUSTOMER_CODE::VARCHAR, 20) AS "Functional Customer Code",
LEFT(CS.CUSTOMER_NAME::VARCHAR, 240) AS "Customer Name",
LEFT(COALESCE(CS.ZIP_CODE, '.'), 10) AS "Zip Code",
LEFT(COALESCE(CS.CITY, '.'), 40) AS "City",
LEFT(COALESCE(CS.COUNTRY_CODE, 'US'), 2) AS "Country code",
LEFT(CS.TELEPHONE, 20) AS "Telephone",
COALESCE(CD.PAYMENT_METHOD, 'NDE') AS "Method of payment",
FROM CUSTOMERS AS CS
JOIN EXTRA.SIDETRADE_PREP.COMBINED_DATA AS CD
ON CS.TECHNICAL_CUSTOMER_CODE = CD.TECHNICAL_CUSTOMER_CODE
And we get the following error during runtime:
sqlmesh.utils.errors.ConfigError: Failed to resolve macros for
SELECT
*
FROM (
SELECT
@EACH(
@columns,
c -> ROW_NUMBER() OVER (PARTITION BY c ORDER BY c NULLS FIRST) AS rank_@c
)
FROM @this_model
WHERE
@condition
)
WHERE
@REDUCE(@EACH(@columns, c -> rank_@c > 1), (l, r) -> l OR r)
Expecting ). Line 1, Col: 149.
(PARTITION BY "Item functional number" ORDER BY "Item functional number" NULLS FIRST) AS rank_Item functional number FROM "EXTRA"."sqlmesh__SIDETRADE"."SIDETRADE__CUSTOMER_ITEMS__4041991335" WHERE TRUE) WHERE
at '.'
Because the audit is on a quoted column and the audit doesn't preserve quotes, the audit fails with a syntax error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels