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

Convert current TruncateOperator into a DropTableOperator #554

Closed
3 tasks
dimberman opened this issue Jul 18, 2022 · 0 comments · Fixed by #556
Closed
3 tasks

Convert current TruncateOperator into a DropTableOperator #554

dimberman opened this issue Jul 18, 2022 · 0 comments · Fixed by #556
Assignees
Milestone

Comments

@dimberman
Copy link
Collaborator

The current TruncateOperator is implemented to drop tables instead of truncating them. This could cause critical issues with users who expect tables to exist after truncation. While not the correct action, there IS use for a DropTableOperator.

Acceptance criteria:

  • Create an operator that given a table will drop said table.
  • If the user does not have proper permissions to drop the table, give proper warning in the form of an error
  • create a corresponding AQL function

Example:

@pytest.mark.integration
@pytest.mark.parametrize(
    "database_table_fixture",
    [
        {
            "database": Database.SQLITE,
            "file": File(DEFAULT_FILEPATH),
        },
        {
            "database": Database.POSTGRES,
            "file": File(DEFAULT_FILEPATH),
        },
        {
            "database": Database.BIGQUERY,
            "file": File(DEFAULT_FILEPATH),
        },
        {
            "database": Database.SNOWFLAKE,
            "file": File(DEFAULT_FILEPATH),
        },
    ],
    indirect=True,
    ids=["sqlite", "postgres", "bigquery", "snowflake"],
)
def test_truncate_with_table_metadata(database_table_fixture, sample_dag):
    """Test truncate operator for all databases."""
    database, test_table = database_table_fixture
    assert database.table_exists(test_table)

    with sample_dag:
        aql.drop_table(
            table=test_table,
        )
    test_utils.run_dag(sample_dag)

    assert not database.table_exists(test_table)
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 a pull request may close this issue.

3 participants