雪花无法识别枢轴对象

时间:2019-11-19 23:12:04

标签: sql snowflake-data-warehouse snowflake-schema

我已经在雪花中编写了一个SQL代码来创建数据透视表。我在另一个查询中使用数据透视表的对象,但无法识别。

create or replace table "SCRATCH"."ASHISHKUMAR".pivoted2 as
SELECT * FROM
(SELECT
  sample_number,customer_sample_number, grower, farm, field, test_parameter,result, SYM, project_id
FROM
    "SCRATCH"."ASHISHKUMAR"."PIVOTED" test
)
PIVOT(
   avg (result)
   FOR test_parameter IN ('Falling Number',
'Damaged Kernels Total',
'Alpine Screen O/100',
'Width (W)',
'Area (135 min.)',
'Absorption',
'Peak',
'Tolerance (Stability)',
'Bread Score Total (100)',
'Weight',
'Ratio No. (Max) (135 min.)',
'Area (90 min.)',
'Ratio No. (R/E) (90 min.)',
'Resistance (90 min.)',
'Shrunken & Broken',
'Wheat of Other Classes',
'Alpine Screen O/45',
'Bake Absorption',
'Crumb Color (10)',
'Digital Image Analysis',
'Max. Resistance (135 min.)',
'0/9',
'Weight (Average)',
'Water',
'Dough Temp.',
'Volume 1',
'Top Grain Score',
'Extensibility (45 min.)',
'Resistance (45 min.)',
'Hardness (Std. Deviation)',
'Moisture (Std. Deviation)',
'Dry Gluten',
'T/9',
'Diameter (Std. Deviation)',
'Weight (Std. Deviation)',
'Contrasting Classes',
'Heat Damage',
'Alpine Screen O/140',
'Bake @ 425°',
'Mix 1 (straight dough)',
'Taste (10)',
'Uniformity (10)',
'Spread Factor (W/T)',
'Ratio No. (R/E) (45 min.)',
'Proof Time',
'Extensibility (90 min.)',
'Protein',
'Test Weight (kg/hl)',
'Total Defects',
'Alpine Screen T/325',
'Ash',
'Crust (10)',
'Symmetry (10)',
'B*',
'Extensibility (135 min.)',
'1000 Kernel Weight',
'Aroma (10)',
'Volume 2',
'L*',
'Ratio No. (Max) (90 min.)',
'Ratio No. (R/E) (135 min.)',
'0/7',
'Max. Resistance (45 min.)',
'Ochratoxin A (Elisa)',
'Yield (Experimental Milling)',
'Dockage',
'Grade',
'Alpine Screen O/200',
'Thickness (T)',
'Area (45 min.)',
'Max. Resistance (90 min.)',
'Lactic Acid',
'Starch Damage',
'M.T.I.',
'Wet Gluten',
'Gluten Index',
'Vomitoxin (Elisa)',
'Foreign Material',
'Test Weight (lb/bu)',
'Moisture',
'Alpine Screen O/325',
'Bread Score:',
'Grain (20)',
'Specific Volume',
'Texture (20)',
'Resistance (135 min.)',
'Moisture (Average)',
'Sucrose',
'Amylograph',
'Fermentation Time',
'Ratio No. (Max) (45 min.)',
'Diameter (Average)',
'Loaf Height',
'Sodium Carbonate',
'Hardness (Average)',
'A*'
)
) AS GPALPIVOT order by project_id;
select * from "PARTHENON"."AGRONOMY"."INDIGO_LOT_ALL" lots left join GPALPIVOT
  on lots.id ilike GPALPIVOT.customer_sample_number
left JOIN PARTHENON.ORACLE.WHEAT_HARVEST_2019_INVENTORY inv
   on GPALPIVOT.customer_sample_number = inv.subinv_description||'_'||split_part(inv.locator,'.',1)||'-'||split_part(inv.locator,'.',2);

尝试运行此程序时出现错误。 PFB错误的屏幕截图:

Link of the screenshot of the error

我已经尝试了一切,但现在却不知所措。有人可以请问一下吗?

1 个答案:

答案 0 :(得分:0)

GPALPIVOT不是您创建的表的名称,它只是您在第一个查询中构造的表表达式的别名,位于原始SELECT语句的内部。后续查询中要引用的表名应为 "SCRATCH"."ASHISHKUMAR".pivoted2