Beehive - rename fields with the same name as the data type

I have a Hive table such as:

CREATE TABLE mytest (name int, timestamp bigint, donation int);

I am using Hive 0.12. Pay attention to the "timestamp" field. By the way, in Hive 0.12+ there is a new data type called timestamp. Say I want to rename this field totime_stamp

I tried:

  • ALTER TABLE mytest CHANGE timestamp time_stamp BIGINT;
  • ALTER TABLE mytest CHANGE COLUMN timestamp time_stamp BIGINT;
  • ALTER TABLE mytest CHANGE [timestamp] time_stamp BIGINT;
  • ALTER TABLE mytest CHANGE `timestamp` time_stamp BIGINT;

However, they all give me the following error:

FAILED: ParseException line 1:38 mismatched input 'CHANGE' expecting KW_EXCHANGE near 'mytest' in alter exchange partition

I am sure that this is because the name of my field matches the name of the data type. How to change the circuit for mytest without to do the following?

CREATE mytest_cpy AS SELECT mytest.name, mytest.timestamp AS time_stamp, 
mytest.donation FROM mytest; 

DROP TABLE mytest; 

ALTER TABLE mytest_cpy RENAME TO mytest;

Thank! Any / all help is appreciated!

+4
source share
3 answers

, , , . Hive 0.14:

ALTER TABLE mytest CHANGE COLUMN `timestamp` time_stamp BIGINT;
+2

MS SQL:

EXECUTE sp_rename 'dbo.mytest.timestamp', 'time_stamp', 'COLUMN' 

MYSQL :

USE database_name;
ALTER TABLE mytest CHANGE timestamp time_stamp BIGINT;

ALTER TABLE database_name.mytest CHANGE timestamp time_stamp BIGINT;
0

Although this post has answers, but still:

If you try to name the Reserved Keywords column for HIVE , then an error will occur.

To override reserved keywords, use can use a backward link (`), this is a character below your tilde key or left by 1.

0
source

Source: https://habr.com/ru/post/1538920/


All Articles