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