だから私は新しいDBTユーザーで、とてもクールなものですが、union_relationsマクロで問題に遭遇しています. この関数にリレーションをフィードしていますが、コンパイル/実行クエリがリレーションから列を見つけられません。
ここに私が実行しているコードがあります:
{{dbt_utils.union_relations(relations=[ref('transform_hist_ca_map_stu_obj_assessment'), ref('transform_hist_sc_map_stu_obj_assessment')])}}
)
select *
from conformed_obj_assessment
where student_assessment_identifier is not null
and assessment_identifier is not null
and identification_code is not null
and student_unique_id is not null
and performance_level is not null
そして、これは私が受け取るエラーです:
syntax error at or near "from" LINE 1706: from __dbt__CTE__transform_hist_ca_map_stu_obj_a... ^ compiled SQL at target/run/rally_dw/conformed/conformed_student_objective_assessment.sql
基本的に最初の列は DBT 生成列で、その後にリレーションからの列があるはずなのですが、なぜかこれらの列が引き込まれていません。現在は一時的で具体化されていないため、それが問題を引き起こしているのではないかと考えています。これがコンパイルされた SQL です。CTE はデータを返しますが、何らかの理由で最後の CTE に取り込まれていません。
create table "dashboarding"."dev_em_conformed"."conformed_student_objective_assessment__dbt_tmp"
as (
with __dbt__CTE__historical_ca_map_stu_obj_assessment as (
with hist_ca_map_stu_obj_assess as (
select * from "dashboarding"."raw_ea"."historical_ca_map_student_obj_assessment"
),
cleaned as (
select distinct
source_org,
assessment_id as assessment_identifier,
student_assessment_identifier,
student_unique_id,
performance_levels as performance_level,
scale_score as score,
assessment_id,
to_date(test_date, 'YYYY-MM-DD') as test_date,
identification_code,
null as parent_objective_assessment_name
from hist_ca_map_stu_obj_assess
)
select * from cleaned
), __dbt__CTE__transform_hist_ca_map_stu_obj_assessment as (
with hist_ca_stu_obj_assess as (
select * from __dbt__CTE__historical_ca_map_stu_obj_assessment
),
final as(
select
null as source_org,
student_assessment_identifier,
assessment_id as assessment_identifier,
identification_code as identification_code,
null as school_year,
student_unique_id,
null as student_grade_level,
null as assessment_grade_level,
NULL as administration_date,
null as administration_end_date,
null as objective_assessment_name,
score,
performance_level,
parent_objective_assessment_name,
null as parent_objective_assessment_id
from hist_ca_stu_obj_assess
)
select * from final
), __dbt__CTE__historical_sc_map_stu_obj_assessment as (
with hist_sc_map_soa as (
select * from "dashboarding"."raw_ea"."historical_sc_map_student_obj_assessment"
),
cleaned as (
select distinct
source_org,
assessment_id as assessment_identifier,
student_assessment_identifier,
student_unique_id,
performance_levels as performance_level,
scale_score as score,
assessment_id,
to_date(test_date, 'YYYY-MM-DD') as test_date,
identification_code,
null as parent_objective_assessment_name
from hist_sc_map_soa
)
select * from cleaned
), __dbt__CTE__transform_hist_sc_map_stu_obj_assessment as (
with hist_sc_stu_obj_assess as (
select * from __dbt__CTE__historical_sc_map_stu_obj_assessment
),
final as(
select
null as source_org,
student_assessment_identifier,
assessment_id as assessment_identifier,
identification_code as identification_code,
null as school_year,
student_unique_id,
null as student_grade_level,
null as assessment_grade_level,
NULL as administration_date,
null as administration_end_date,
null as objective_assessment_name,
score,
performance_level,
parent_objective_assessment_name,
null as parent_objective_assessment_id
from hist_sc_stu_obj_assess
)
select * from final
), conformed_obj_assessment as(
(
select
cast('__dbt__CTE__transform_hist_ca_map_stu_obj_assessment' as
varchar
) as _dbt_source_relation,
---NO MORE COLUMNS???
from __dbt__CTE__transform_hist_ca_map_stu_obj_assessment
)
union all
(
select
cast('__dbt__CTE__transform_hist_sc_map_stu_obj_assessment' as
varchar
) as _dbt_source_relation,
---NO MORE COLUMNS??
from __dbt__CTE__transform_hist_sc_map_stu_obj_assessment
)
)
select *
from conformed_obj_assessment
where student_assessment_identifier is not null
and assessment_identifier is not null
and identification_code is not null
and student_unique_id is not null
and performance_level is not null
);
どんな考えでも大歓迎ですありがとう!