-
Notifications
You must be signed in to change notification settings - Fork 421
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
Way to check if Delta table exists at specified path #2662
Comments
Hey @jorritsandbrink, so there's a function called
from deltalake.writer import try_get_deltatable
dt = try_get_deltatable("path_to_table_that_may_not_exist_yet")
if dt is not None:
dt.merge(...)
else:
write_deltalake(...) And yes I agree with you, since this is a very common use case, we can consider abstracting it to something more meaningful like Until then, I suppose we should also consider adding the |
@omkar-foss thanks! I'll use |
Feel free to open a PR for a static method is_deltatable() |
take |
This commit adds a static method `is_deltatable(path, opts)` to the `DeltaTable` class, which returns `True` if delta-rs is able to load a `DeltaTable` instance from the specified `path` and `False` otherwise.
This adds a static method is_deltatable(path, opts) to the DeltaTable class, which returns True if delta-rs is able to load a DeltaTable instance from the specified path and False otherwise. Additionally, this also adds documentation of the usage with examples for the DeltaTable.is_deltatable() method.
Hey @ion-elgreco @jorritsandbrink hope you both are doing great. I've opened PR #2715, please have a look whenever you get a chance. Thanks! |
This adds a static method `is_deltatable(path, opts)` to the `DeltaTable` Python class, which returns `True` if able to locate a delta table at specified `path` and `False` otherwise. It does so by reusing the Rust internal `is_delta_table_location()` via the `DeltaTableBuilder`. Additionally, this also adds documentation of the usage with examples for the `DeltaTable.is_deltatable()` method.
This adds a static method `is_deltatable(path, opts)` to the `DeltaTable` Python class, which returns `True` if able to locate a delta table at specified `path` and `False` otherwise. It does so by reusing the Rust internal `is_delta_table_location()` via the `DeltaTableBuilder`. Additionally, this also adds documentation of the usage with examples for the `DeltaTable.is_deltatable()` method.
Description
It would be nice to have a way to check if a Delta table exists at a given path.
Delta Spark has the
DeltaTable.isDeltaTable()
method: https://docs.delta.io/latest/api/python/spark/index.html#delta.tables.DeltaTable.isDeltaTableUse Case
When merging into a Delta table, you first define a
DeltaTable
object before callingmerge
on it:This fails with a
TableNotFoundError
if the table does not exist.Having the
isDeltaTable
method (or similar) would enable this flow:The above requires two path lookups, which adds unnecessary latency.
Alternatively, something like this could be nice:
The text was updated successfully, but these errors were encountered: