0
use database DQ_MART;

use schema WORKING;

WITH ASCENDER_EMPLOYEE AS (
    **SELECT DISTINCT EMPLOYEE_ID FROM RECONCILLIATION_ASCENDER_WORKER_TIMESHEET**
),
     WORKDAY_EMPLOYEE AS (
         **SELECT DISTINCT EMPLOYEE_ID FROM RECONCILLIATION_WORKDAY_WORKER_TIMESHEET**
     )
     
SELECT 'Missing employee in Ascender'              DQ_RULE_NAME,
       RECONCILLIATION_WORKDAY_WORKER_TIMESHEET.EMPLOYEE_ID                         KEY
      
FROM WORKDAY_EMPLOYEE WORKDAY
         LEFT OUTER JOIN ASCENDER_EMPLOYEE ASCENDER
                         ON ASCENDER.EMPLOYEE_ID = WORKDAY.EMPLOYEE_ID
;

大家好,我对 Snowflake SQL CTE 有点陌生。在上面的查询中,我收到一个错误,错误:此行中的无效标识符“RECONCILLIATION_WORKDAY_WORKER_TIMESHEET.EMPLOYEE_ID”(第 16 行)

RECONCILLIATION_WORKDAY_WORKER_TIMESHEET.EMPLOYEE_ID

访问同一个表的选择语句运行正常。表所在的数据库和模式设置正确,并且我确实对表有 SELECT 授权。

Snowflake 中是否存在导致错误发生的范围可见性。任何建议都将受到欢迎。

4

1 回答 1

0

“RECONCILLIATION_WORKDAY_WORKER_TIMESHEET.EMPLOYEE_ID”表示“RECONCILLIATION_WORKDAY_WORKER_TIMESHEET”表中的“EMPLOYEE_ID”列。

您使用此列的选择语句是:

SELECT <column list>
FROM WORKDAY_EMPLOYEE WORKDAY
LEFT OUTER JOIN ASCENDER_EMPLOYEE ASCENDER
ON ASCENDER.EMPLOYEE_ID = WORKDAY.EMPLOYEE_ID

其中不包括名为 RECONCILLIATION_WORKDAY_WORKER_TIMESHEET 的表 - 这就是您收到错误的原因

于 2021-05-27T13:22:04.350 回答