UNRESOLVED_COLUMN錯誤類別
無法解析具有名稱 <objectName>
的資料行或函式參數。
這個錯誤類別具有下列衍生的錯誤類別。
WITHOUT_SUGGESTION
參數
- objectName :無法解析的資料行或參數名稱。
WITH_SUGGESTION
您的意思是下列其中一項嗎? [<proposal>
]
參數
- objectName :無法解析的資料行或參數名稱。
- 提案 :潛在候選項目的逗號分隔清單。
說明
每當 Azure Databricks 無法識別預期資料行、資料行別名或函式參數的內容中的識別碼時,就會引發此錯誤。
此錯誤有數個原因:
- 資料行名稱 或 參數名稱 中的 拼字錯誤。
- 您實際上是要指定字串常值,而不是識別碼。
- 資料行已使用 ALTER TABLE 重新命名或卸載
- 資料行未包含在子查詢的選取清單中。
- 資料行已使用 資料表別名 或 資料行別名 重新命名。
- 資料行參考相互關聯,而且您未指定 LATERAL 。
- 資料行參考是看不到的物件,因為它出現在相同選取清單中或純量子查詢中。
降低
錯誤的風險降低取決於原因:
名稱和限定詞的拼字不正確嗎?
與 中
objectList
提供的資料行比較,並修正拼字。您是否要改為指定字串常值?
以單引號括住常值,而不是反引號(輔色墳墓)。
資料行是否已從子查詢中省略?
將資料行新增至子查詢的選取清單。
您是否在與 子句中先前的關聯性中參考資料行?
LATERAL
使用未解析的資料行在子查詢之前新增 關鍵字。 相互關聯的查詢支援有限。 您可能需要重寫查詢(取消相互關聯)。目前還不清楚為何無法解析資料行或欄位?
範例
> CREATE OR REPLACE TEMPORARY VIEW colors(cyan, magenta, yellow) AS VALUES(10, 20, 5);
-- The column reference has been misspelled
> SELECT jello FROM colors;
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `jello` cannot be resolved.
Did you mean one of the following? [`colors`.`cyan`, `colors`.`yellow`, `colors`.`magenta`]
-- Correct the spelling
> SELECT yellow FROM colors;
5
-- The qualifier has been misspelled
> SELECT color.yellow FROM colors;
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `color`.`yellow` cannot be resolved.
Did you mean one of the following? [`colors`.`cyan`, `colors`.`yellow`, `colors`.`magenta`]
-- Correct the spelling
> SELECT colors.yellow FROM colors;
5
-- Forgot to quote a literal
> SELECT hello;
[UNRESOLVED_COLUMN.WITHOUT_SUGGESTION] A column or function parameter with name `hello` cannot be resolved.
-- Use single quotes
> SELECT 'hello';
-- Used the wrong quotes for a literal
> SELECT `hello`;
[UNRESOLVED_COLUMN.WITHOUT_SUGGESTION] A column or function parameter with name `hello` cannot be resolved.
-- Use single quotes instead
> SELECT 'hello';
-- Column "got lost" in a subquery.
> SELECT cyan, magenta, yellow
FROM (SELECT cyan, magenta
FROM colors) AS c;
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `yellow` cannot be resolved.
Did you mean one of the following? [`c`.`cyan`, `c`.`magenta`]
-- Add the missing column
> SELECT cyan, magenta, yellow
FROM (SELECT cyan, magenta, yellow
FROM colors) AS c;
10 20 5
-- Columns got renamed in the table alias
> SELECT cyan, magenta, yellow
FROM (SELECT cyan, magenta, yellow
FROM colors) AS c(c, m, y);
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `cyan` cannot be resolved.
Did you mean one of the following? [`c`.`c`, `c`.`m`, `c`.`y`];
-- Adjust the names
> SELECT c, m, y
FROM (SELECT cyan, magenta, yellow
FROM colors) AS c(c, m, y);
10 20 5
-- A correlated reference
> SELECT * FROM colors, (SELECT cyan + magenta + yellow AS total_use);
[UNRESOLVED_COLUMN.WITHOUT_SUGGESTION] A column or function parameter with name `cyan` cannot be resolved.
-- Add LATERAL to permit correation
> SELECT * FROM colors, LATERAL(SELECT cyan + magenta + yellow AS total_use);
10 20 5 35
-- Or de-correlate
> SELECT *, cyan + magenta + yellow AS total_use FROM colors;
10 20 5 35
-- A misspelled parameter name
> CREATE OR REPLACE FUNCTION plus(a INT, b INT) RETURNS INT RETURN arg1 + arg2;
[UNRESOLVED_COLUMN.WITH_SUGGESTION] A column or function parameter with name `arg1` cannot be resolved.
Did you mean one of the following? [`plus`.`a`, `plus`.`b`]
-- Fix the names
> CREATE OR REPLACE FUNCTION plus(a INT, b INT) RETURNS INT RETURN a + b;
> SELECT plus(1, 2);
3