Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature delete table only #105

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Feature delete table only #105

wants to merge 4 commits into from

Conversation

mshodge
Copy link

@mshodge mshodge commented May 25, 2023

New function feature to mimic awswrangler.catalog.delete_table_if_exists - so we can delete the table only but keep the S3 data (similar to an SQL query of DROP TABLE IF EXISTS [TABLE_NAME]).

def delete_table(table: str, database: str, boto3_session=None):
    """
    Deletes a table from an Athena database.

    Args:
        table (str): The table name to drop.
        database (str): The database name.

    Returns:
        True if table exists and is deleted, False if table
        does not exist
    """

    if table in list(tables(database=database, limit=None)["Table"]):
        wr.catalog.delete_table_if_exists(
            database=database, table=table, boto3_session=boto3_session
        )
        return True
    else:
        return False

Have updated the README.md and CHANGELOG.md too.

@mshodge mshodge requested a review from mratford May 25, 2023 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant