coral icon indicating copy to clipboard operation
coral copied to clipboard

Incorrect schema for views with unnamed columns in the view SQL

Open shardulm94 opened this issue 4 years ago • 1 comments

If we create a Hive view with columns that are not explicitly named in the SQL, Hive with autogenerate column names for such columns persisting the view to the Metastore. E.g. Consider the following view

hive> CREATE VIEW v AS SELECT TRUE, lower('STR') FROM some_table;

Here is the persisted information in the metastore

hive> DESC FORMATTED v;
OK
# col_name            	data_type           	comment

_c0                 	boolean
_c1                 	string
.
.
.
# View Information
View Original Text: 	SELECT TRUE, lower('STR') FROM some_table
View Expanded Text: 	SELECT TRUE, lower('STR') FROM `some_table`

Trying to retrieve view schema using coral-schema for this view returns EXPR_0 and EXPR_1 as column names, which I assume are auto generated by Calcite. I think we should respect the column names provided by Hive here i.e. _c0 and c1 since they have been persisted as column metadata in the metastore.

shardulm94 avatar Dec 16 '21 04:12 shardulm94

Thanks @shardulm94 for reporting it, opened a PR #214 to fix it.

ljfgem avatar Dec 16 '21 15:12 ljfgem