You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Quanlong Huang (Jira)" <ji...@apache.org> on 2023/01/05 07:15:00 UTC
[jira] [Updated] (IMPALA-11824) View that cast column to the same type cannot be used
[ https://issues.apache.org/jira/browse/IMPALA-11824?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Quanlong Huang updated IMPALA-11824:
------------------------------------
Description:
I found this when debugging for another issue. For views that cast columns to the same types, any usage of it will failed with "Could not resolve column/field reference" error. Here's an example:
{code:sql}
create table t (id int) stored as textfile;
insert into t select 1;
create view v(id) as select cast(id as int) from t;
select * from v;
ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
select id from v;
ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
# Casting id to a different type works
create view v2(id) as select cast(id as tinyint) from t;
+----+
| id |
+----+
| 1 |
+----+
# Don't specifying the view column names also works
create view v3 as select cast(id as tinyint) from t;
+-----+
| _c0 |
+-----+
| 1 |
+-----+{code}
Note that it works if I create the view in Hive. Comparing the results of DESCRIBE FORMATTED, the difference is in the "View Expanded Text". In the Impala-created view, it's
{code:sql}
SELECT v.`_c0` AS id FROM (SELECT CAST(id AS INT) FROM `default`.t) v
{code}
In the Hive-created view, it's
{code:sql}
SELECT `id` AS `id` FROM (select `t`.`id` from `default`.`t`) `hive_view`
{code}
was:
I found this when debugging for another issue. For views that cast columns to the same types, any usage of it will failed with "Could not resolve column/field reference" error. Here's an example:
{code:java}
create table t (id int) stored as textfile;
insert into t select 1;
create view v(id) as select cast(id as int) from t;
select * from v;
ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
select id from v;
ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
# Casting id to a different type works
create view v2(id) as select cast(id as tinyint) from t;
+----+
| id |
+----+
| 1 |
+----+
# Don't specifying the view column names also works
create view v3 as select cast(id as tinyint) from t;
+-----+
| _c0 |
+-----+
| 1 |
+-----+{code}
> View that cast column to the same type cannot be used
> -----------------------------------------------------
>
> Key: IMPALA-11824
> URL: https://issues.apache.org/jira/browse/IMPALA-11824
> Project: IMPALA
> Issue Type: Bug
> Components: Frontend
> Reporter: Quanlong Huang
> Priority: Critical
>
> I found this when debugging for another issue. For views that cast columns to the same types, any usage of it will failed with "Could not resolve column/field reference" error. Here's an example:
> {code:sql}
> create table t (id int) stored as textfile;
> insert into t select 1;
> create view v(id) as select cast(id as int) from t;
> select * from v;
> ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
> select id from v;
> ERROR: AnalysisException: Could not resolve column/field reference: 'v._c0'
> # Casting id to a different type works
> create view v2(id) as select cast(id as tinyint) from t;
> +----+
> | id |
> +----+
> | 1 |
> +----+
> # Don't specifying the view column names also works
> create view v3 as select cast(id as tinyint) from t;
> +-----+
> | _c0 |
> +-----+
> | 1 |
> +-----+{code}
> Note that it works if I create the view in Hive. Comparing the results of DESCRIBE FORMATTED, the difference is in the "View Expanded Text". In the Impala-created view, it's
> {code:sql}
> SELECT v.`_c0` AS id FROM (SELECT CAST(id AS INT) FROM `default`.t) v
> {code}
> In the Hive-created view, it's
> {code:sql}
> SELECT `id` AS `id` FROM (select `t`.`id` from `default`.`t`) `hive_view`
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org