Changing column name in a Hive external table that contains dataDifference between Hive internal tables and external tables?What is the difference between partitioning and bucketing a table in Hive ?hive external partitioned tablesave dataframe as external hive tableIs it possible to compress Parquet file which contain Json data in hive external table?Hive external table with parquet data not selecting dataHive external table returns no dataAthena - creating external table with field name different from parquet column nameCreating Hive table on Parquet file which has JSON dataHive alter table change column name gives 'NULL' to the renamed column
Converting 3x7 to a 1x7. Is it possible with only existing parts?
Is it possible to install Firefox on Ubuntu with no desktop enviroment?
How would Japanese people react to someone refusing to say “itadakimasu” for religious reasons?
Using roof rails to set up hammock
Does WiFi affect the quality of images downloaded from the internet?
How do I become a better writer when I hate reading?
Co-worker is now managing my team. Does this mean that I'm being demoted?
How can I detect if I'm in a subshell?
Should I worry about having my credit pulled multiple times while car shopping?
...and then she held the gun
Can an opamp have its own voltage regulator?
Difference between "drift" and "wander"
For Saintsbury, which English novelists constituted the "great quartet of the mid-eighteenth century"?
Will users know a CardView is clickable
Can I give my friend the sour dough "throw away" as a starter to their sourdough starter?
How to search for Android apps without ads?
Dedicated bike GPS computer over smartphone
Threading data on TimeSeries
What should I be aware of in buying second-hand sinks and toilets?
Fastest path on a snakes and ladders board
How do credit card companies know what type of business I'm paying for?
Nth term of Van Eck Sequence
How to test soql with For Update statement
100-doors puzzle
Changing column name in a Hive external table that contains data
Difference between Hive internal tables and external tables?What is the difference between partitioning and bucketing a table in Hive ?hive external partitioned tablesave dataframe as external hive tableIs it possible to compress Parquet file which contain Json data in hive external table?Hive external table with parquet data not selecting dataHive external table returns no dataAthena - creating external table with field name different from parquet column nameCreating Hive table on Parquet file which has JSON dataHive alter table change column name gives 'NULL' to the renamed column
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have a column insert_process_id that I am trying to rename to process_id. This external table is in parquet file format. Please advise how to rename this column.
hadoop hive hiveql
add a comment |
I have a column insert_process_id that I am trying to rename to process_id. This external table is in parquet file format. Please advise how to rename this column.
hadoop hive hiveql
add a comment |
I have a column insert_process_id that I am trying to rename to process_id. This external table is in parquet file format. Please advise how to rename this column.
hadoop hive hiveql
I have a column insert_process_id that I am trying to rename to process_id. This external table is in parquet file format. Please advise how to rename this column.
hadoop hive hiveql
hadoop hive hiveql
asked Mar 25 at 2:44
VivekVivek
111
111
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
you can use the following syntax
ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type
[COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];
As this is an external table, you can drop the table and re-create again with specific changes.
add a comment |
You can change column name as below.
Syntax:
ALTER TABLE name CHANGE column_name col_spec ..
Example:
I have created table as below.
CREATE EXTERNAL Table IF NOT EXISTS Patient_external(
PatientID int, Name String, City String, Number String )
COMMENT 'Data about patient from Apollo Hospital'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS PARQUET
LOCATION '/user/training/external/data' ;Loaded data into table
LOAD DATA LOCAL INPATH
'/home/cloudera/Desktop/HiveTraining/Dataset/patient_details' INTO TABLE Patient_external;Describe the table
describe formatted Patient_external;
col_name data_type comment
**patientid** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormatChange the column name from PatientID to Patient_ID
Alter Table Patient_external change PatientID Patient_ID Int;
Now describe the table
describe formatted Patient_external;
col_name data_type comment
**patient_id** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330633%2fchanging-column-name-in-a-hive-external-table-that-contains-data%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can use the following syntax
ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type
[COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];
As this is an external table, you can drop the table and re-create again with specific changes.
add a comment |
you can use the following syntax
ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type
[COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];
As this is an external table, you can drop the table and re-create again with specific changes.
add a comment |
you can use the following syntax
ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type
[COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];
As this is an external table, you can drop the table and re-create again with specific changes.
you can use the following syntax
ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type
[COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];
As this is an external table, you can drop the table and re-create again with specific changes.
answered Mar 25 at 13:37
Gaurang ShahGaurang Shah
3,85921839
3,85921839
add a comment |
add a comment |
You can change column name as below.
Syntax:
ALTER TABLE name CHANGE column_name col_spec ..
Example:
I have created table as below.
CREATE EXTERNAL Table IF NOT EXISTS Patient_external(
PatientID int, Name String, City String, Number String )
COMMENT 'Data about patient from Apollo Hospital'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS PARQUET
LOCATION '/user/training/external/data' ;Loaded data into table
LOAD DATA LOCAL INPATH
'/home/cloudera/Desktop/HiveTraining/Dataset/patient_details' INTO TABLE Patient_external;Describe the table
describe formatted Patient_external;
col_name data_type comment
**patientid** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormatChange the column name from PatientID to Patient_ID
Alter Table Patient_external change PatientID Patient_ID Int;
Now describe the table
describe formatted Patient_external;
col_name data_type comment
**patient_id** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
add a comment |
You can change column name as below.
Syntax:
ALTER TABLE name CHANGE column_name col_spec ..
Example:
I have created table as below.
CREATE EXTERNAL Table IF NOT EXISTS Patient_external(
PatientID int, Name String, City String, Number String )
COMMENT 'Data about patient from Apollo Hospital'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS PARQUET
LOCATION '/user/training/external/data' ;Loaded data into table
LOAD DATA LOCAL INPATH
'/home/cloudera/Desktop/HiveTraining/Dataset/patient_details' INTO TABLE Patient_external;Describe the table
describe formatted Patient_external;
col_name data_type comment
**patientid** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormatChange the column name from PatientID to Patient_ID
Alter Table Patient_external change PatientID Patient_ID Int;
Now describe the table
describe formatted Patient_external;
col_name data_type comment
**patient_id** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
add a comment |
You can change column name as below.
Syntax:
ALTER TABLE name CHANGE column_name col_spec ..
Example:
I have created table as below.
CREATE EXTERNAL Table IF NOT EXISTS Patient_external(
PatientID int, Name String, City String, Number String )
COMMENT 'Data about patient from Apollo Hospital'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS PARQUET
LOCATION '/user/training/external/data' ;Loaded data into table
LOAD DATA LOCAL INPATH
'/home/cloudera/Desktop/HiveTraining/Dataset/patient_details' INTO TABLE Patient_external;Describe the table
describe formatted Patient_external;
col_name data_type comment
**patientid** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormatChange the column name from PatientID to Patient_ID
Alter Table Patient_external change PatientID Patient_ID Int;
Now describe the table
describe formatted Patient_external;
col_name data_type comment
**patient_id** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
You can change column name as below.
Syntax:
ALTER TABLE name CHANGE column_name col_spec ..
Example:
I have created table as below.
CREATE EXTERNAL Table IF NOT EXISTS Patient_external(
PatientID int, Name String, City String, Number String )
COMMENT 'Data about patient from Apollo Hospital'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
STORED AS PARQUET
LOCATION '/user/training/external/data' ;Loaded data into table
LOAD DATA LOCAL INPATH
'/home/cloudera/Desktop/HiveTraining/Dataset/patient_details' INTO TABLE Patient_external;Describe the table
describe formatted Patient_external;
col_name data_type comment
**patientid** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormatChange the column name from PatientID to Patient_ID
Alter Table Patient_external change PatientID Patient_ID Int;
Now describe the table
describe formatted Patient_external;
col_name data_type comment
**patient_id** int
name string
city string
number string
Detailed Table Information
Database: default
Owner: cloudera
CreateTime: Mon Mar 25 10:57:23 PDT 2019
LastAccessTime: UNKNOWN
Protect Mode: None
Retention: 0
Location:
hdfs://quickstart.cloudera:8020/user/training/external/data
Table Type: EXTERNAL_TABLE
Table Parameters:
COLUMN_STATS_ACCURATE false
EXTERNAL TRUE
comment Data about patient from Apollo Hospital
numFiles 0
numRows -1
rawDataSize -1
totalSize 0
transient_lastDdlTime 1553536643
Storage Information
SerDe Library:
org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe
InputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat
OutputFormat:
org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat
edited Mar 25 at 18:09
answered Mar 25 at 18:02
KZapagolKZapagol
58118
58118
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55330633%2fchanging-column-name-in-a-hive-external-table-that-contains-data%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown