-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add support for save_table(..., mode="overwrite")
to StatementExecutionBackend
#74
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 82.95% 84.58% +1.62%
==========================================
Files 7 7
Lines 534 532 -2
Branches 105 105
==========================================
+ Hits 443 450 +7
+ Misses 55 50 -5
+ Partials 36 32 -4 ☔ View full report in Codecov by Sentry. |
❌ 17/18 passed, 1 failed, 2 skipped, 11m29s total ❌ test_overwrite: databricks.sdk.errors.platform.BadRequest: [INSUFFICIENT_PERMISSIONS] Insufficient privileges: (2.587s)
Running from acceptance #46 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's take the risk
if mode == "overwrite": | ||
self.execute(f"TRUNCATE TABLE {full_name}") | ||
for i in range(0, len(rows), self._max_records_per_batch): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'd need to properly support overwrites in the raw sql shape to keep the same'ish semantics as Spark:
INSERT INTO {full_name}_tmp ...
CREATE OR REPLACE TABLE {full_name} AS SELECT * FROM {full_name}_tmp
DROP TABLE {full_name}_tmp
otherwise the failure of overwrite will leave the table in a corrupt state.
save_table(..., mode="overwrite")
to StatementExecutionBackend
* Added support for `save_table(..., mode="overwrite")` to `StatementExecutionBackend` ([#74](#74)). In this release, we've added support for overwriting a table when saving data using the `save_table` method in the `StatementExecutionBackend`. Previously, attempting to use the `overwrite` mode would raise a `NotImplementedError`. Now, when this mode is specified, the method first truncates the table before inserting the new rows. The truncation is done using the `execute` method to run a `TRUNCATE TABLE` SQL command. Additionally, we've added a new integration test, `test_overwrite`, to the `test_deployment.py` file to verify the new `overwrite` mode functionality. A new option, `mode="overwrite"`, has been added to the `save_table` method, allowing for the existing data in the table to be deleted and replaced with the new data being written. We've also added two new test cases, `test_statement_execution_backend_save_table_overwrite_empty_table` and `test_mock_backend_overwrite`, to verify the new functionality. It's important to note that the method signature has been updated to include a default value for the `mode` parameter, setting it to `append` by default. This change does not affect the functionality and only provides a more convenient default behavior for users of the method.
* Added support for `save_table(..., mode="overwrite")` to `StatementExecutionBackend` ([#74](#74)). In this release, we've added support for overwriting a table when saving data using the `save_table` method in the `StatementExecutionBackend`. Previously, attempting to use the `overwrite` mode would raise a `NotImplementedError`. Now, when this mode is specified, the method first truncates the table before inserting the new rows. The truncation is done using the `execute` method to run a `TRUNCATE TABLE` SQL command. Additionally, we've added a new integration test, `test_overwrite`, to the `test_deployment.py` file to verify the new `overwrite` mode functionality. A new option, `mode="overwrite"`, has been added to the `save_table` method, allowing for the existing data in the table to be deleted and replaced with the new data being written. We've also added two new test cases, `test_statement_execution_backend_save_table_overwrite_empty_table` and `test_mock_backend_overwrite`, to verify the new functionality. It's important to note that the method signature has been updated to include a default value for the `mode` parameter, setting it to `append` by default. This change does not affect the functionality and only provides a more convenient default behavior for users of the method.
No description provided.