HIVE-29474: DESCRIBE FORMATTED for columns produces wrong output when…#6333
HIVE-29474: DESCRIBE FORMATTED for columns produces wrong output when…#6333tanishq-chugh wants to merge 2 commits intoapache:masterfrom
Conversation
… the column datatype is STRUCT
|
soumyakanti3578
left a comment
There was a problem hiding this comment.
HiveMetaStoreUtils#getFieldsFromDeserializer should be agnostic of where it was called from, so adding a boolean variable in its args is not ideal.
Also, I don't like the idea that we have to add false everywhere we are calling the method from, as the changes seem irrelevant, just to add true in a couple of places.
It seems we are running into this issue because the tableName in method getFieldsFromDeserializer is default.[tbl].point. This is then split into names:
String[] names = tableName.split("\\.");
String last_name = names[names.length - 1];
for (int i = 2; i < names.length; i++) {
and since the length of names is 3, we go into the for loop to iterate through the fields of point.
You could probably just pass the colName instead of desc.getColumnPath() in:
Hive.getFieldsFromDeserializer(desc.getColumnPath(), deserializer, context.getConf()));
in DescTableOperation.java. This will force it to skip over the for loop as there will just be 1 item in names.
Probably you won't need to change anything anywhere else. Please try this and let's see if all the tests pass.



… the column datatype is STRUCT
What changes were proposed in this pull request?
Fix DESCRIBE FORMATTED for STRUCT datatype columns output
Why are the changes needed?
Currently, when we have a table with STRUCT datatype column, running the DESCRIBE FORMATTED query on the particular STRUCT column produces wrong output,
For Exm:
CREATE TABLE tbl_t (id int, point STRUCT<x:INT, y:INT>);DESCRIBE FORMATTED tbl_t point;gives the following output:

Here as we can observe that the col_name & data_type are wrong & instead should be point & struct<x:int,y:int> respectively.
Does this PR introduce any user-facing change?
Yes
How was this patch tested?
Manual Testing & Qtest