Skip to content

Instantly share code, notes, and snippets.

@Lydon-01
Forked from dan-hook/rename_table.py
Created February 21, 2019 05:12
Show Gist options
  • Save Lydon-01/86988eb5f248817c531ad02efea8c356 to your computer and use it in GitHub Desktop.
Save Lydon-01/86988eb5f248817c531ad02efea8c356 to your computer and use it in GitHub Desktop.
"Rename" an AWS Glue table by creating a new table
import boto3
database_name = "databse"
table_name = "prefix-dir_name"
new_table_name = "more_awesome_name"
client = boto3.client("glue")
response = client.get_table(DatabaseName=database_name, Name=table_name)
table_input = response["Table"]
table_input["Name"] = new_table_name
# Delete keys that cause create_table to fail
table_input.pop("CreatedBy")
table_input.pop("CreateTime")
table_input.pop("UpdateTime")
create_response = client.create_table(DatabaseName=database_name, TableInput=table_input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment