雪花无法识别枢轴对象
Pivot object not being recognized by snowflake
我在 snowflake 中编写了一个 SQL 代码来创建一个枢轴 table。我在另一个查询中使用了枢轴 table 的对象,但未被识别。
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
我都试过了,我现在不知道该怎么办。有人可以解释一下吗?
GPALPIVOT
不是您创建的 table 的名称——它只是原始 SELECT 语句内部的别名,用于 table 表达式您在第一个查询中构建。在后续查询中引用的 table 名称应该是
"SCRATCH"."ASHISHKUMAR".pivoted2
我在 snowflake 中编写了一个 SQL 代码来创建一个枢轴 table。我在另一个查询中使用了枢轴 table 的对象,但未被识别。
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
我都试过了,我现在不知道该怎么办。有人可以解释一下吗?
GPALPIVOT
不是您创建的 table 的名称——它只是原始 SELECT 语句内部的别名,用于 table 表达式您在第一个查询中构建。在后续查询中引用的 table 名称应该是
"SCRATCH"."ASHISHKUMAR".pivoted2