[
https://issues.apache.org/jira/browse/HIVE-11797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14740756#comment-14740756
]
Chaoyu Tang commented on HIVE-11797:
------------------------------------
[~joysn1980] I think it is because currently Hive treats Avro Serde not as HMS
backed SerDe and its column metadata is from its Avro schema instead of HMS.
> Alter table change columnname doesn't work on avro serde hive table
> -------------------------------------------------------------------
>
> Key: HIVE-11797
> URL: https://issues.apache.org/jira/browse/HIVE-11797
> Project: Hive
> Issue Type: Bug
> Reporter: Joy SN
> Assignee: Chaoyu Tang
>
> We create a table using Avro serde
> Hive table name hive_t1.
> Then we try to change the column name.
> The commands ends successfully but the name of the column is not modified.
> create table if not exists hive_t1
> partitioned by (p1 int)
> row format SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
> STORED AS
> INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
> OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
> TBLPROPERTIES ('avro.schema.literal'='{
> "namespace": "testing.hive.avro.serde",
> "name": "avro_table",
> "type": "record",
> "fields": [
> {
> "name":"number",
> "type":"int",
> "doc":"Order of playing the role"
> },
> {
> "name":"first_name",
> "type":"string",
> "doc":"first name of actor playing role"
> },
> {
> "name":"last_name",
> "type":"string",
> "doc":"last name of actor playing role"
> },
> {
> "name":"extra_field",
> "type":"string",
> "doc:":"an extra field not in the original file",
> "default":"fishfingers and custard"
> }
> ]
> }');
> hive> alter table hive_t1 change column number number1 int;
> OK
> Time taken: 0.12 seconds
> hive> select * from hive_t1 limit 5;
> OK
> hive_t1.number hive_t1.first_name hive_t1.last_name
> hive_t1.extra_field hive_t1.p1
> 6 Colin Baker fishfingers and custard 100
> 3 Jon Pertwee fishfingers and custard 100
> 4 Tom Baker fishfingers and custard 100
> 5 Peter Davison fishfingers and custard 100
> 11 Matt Smith fishfingers and custard 100
> Time taken: 0.05 seconds, Fetched: 5 row(s)
> hive> describe hive_t1;
> OK
> col_name data_type comment
> number int from deserializer
> first_name string from deserializer
> last_name string from deserializer
> extra_field string from deserializer
> p1 int
>
> # Partition Information
> # col_name data_type comment
>
> p1 int
> Time taken: 0.051 seconds, Fetched: 10 row(s)
> -- Using the below command also the column name is not changed from "number"
> to "number1"
> hive> alter table hive_t1 change number number1 int;
> OK
> Time taken: 0.081 seconds
> hive> describe hive_t1;
> OK
> col_name data_type comment
> number int from deserializer
> first_name string from deserializer
> last_name string from deserializer
> extra_field string from deserializer
> p1 int
>
> # Partition Information
> # col_name data_type comment
>
> p1 int
> Time taken: 0.054 seconds, Fetched: 10 row(s)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)