Rahul Sharma
Rahul Sharma

Reputation: 147

Can we alter a table in Glue?

If i am using Glue as a metastore, is it possible to alter any existing table (Like adding a new column or changing the data type of column) in it ? The only way I could find was deleting the existing table and then creating a new table with the changed schema. Please help if there is a way to modify existing table itself.

Edit - I mean to ask to update the schema via Glue API and not via AWS Glue UI as I could only find API to Create or Drop the table but not alter the table.

Upvotes: 1

Views: 2820

Answers (1)

Rahul Sharma
Rahul Sharma

Reputation: 147

Update: I was able to do this by using AWS Java SDK. First create a AWS Glue Client based on your configuration. Given an example here - https://www.edureka.co/community/1490/how-do-i-get-my-aws-glue-client-in-java

After we have created the AWS Glue client,we can invoke updateTable() method on it to update an existing Table. Below is the signature of same -

UpdateTableResult updateTable(UpdateTableRequest updateTableRequest);

Here UpdateTableRequest is nothing but an AmazonWebServiceRequest which is created using some basic parameters like Table Name, Catalog Id, Input schema etc. You can check out this url to get sample example - https://github.com/aws-samples/aws-glue-data-catalog-replication-utility/blob/master/src/main/java/com/amazonaws/gdcreplication/util/GlueUtil.java

Upvotes: 2

Related Questions