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

Add table_exists method to the Catalog #507

Closed
Fokko opened this issue Mar 9, 2024 · 9 comments · Fixed by #512
Closed

Add table_exists method to the Catalog #507

Fokko opened this issue Mar 9, 2024 · 9 comments · Fixed by #512
Assignees

Comments

@Fokko
Copy link
Contributor

Fokko commented Mar 9, 2024

Feature Request / Improvement

Prolonging the discussion in #406

I think having this method on the Catalog would be a great addition. On top of this, we can also leverage the table-exists implementation of the REST catalog by overriding this method in the REST catalog.

@jayceslesar
Copy link
Contributor

jayceslesar commented Mar 10, 2024

could be similar to the mkdirs api? With exists_ok or some param?

https://docs.python.org/3/library/os.html#os.makedirs

@Fokko
Copy link
Contributor Author

Fokko commented Mar 11, 2024

@jayceslesar I would keep it simple by just returning a bool.

@djouallah
Copy link

@kevinjqliu is this supported ?

AttributeError: 'SqlCatalog' object has no attribute 'table_exists'

@Fokko
Copy link
Contributor Author

Fokko commented Apr 30, 2024

@djouallah No that's not expected. If it doesn't supported the specialized table_exists call, then it should do a load_table and catch the exception. Let's get this fixed 🚀

@Fokko Fokko reopened this Apr 30, 2024
@MehulBatra
Copy link
Contributor

If it's open to work, I can take a shot at it!

@Fokko
Copy link
Contributor Author

Fokko commented Apr 30, 2024

@MehulBatra That would be great 👍

The main this is that we need to implement this method:

@abstractmethod
def table_exists(self, identifier: Union[str, Identifier]) -> bool:
"""Check if a table exists.
Args:
identifier (str | Identifier): Table identifier.
Returns:
bool: True if the table exists, False otherwise.
"""

@MehulBatra
Copy link
Contributor

PR: #678

@HonahX
Copy link
Contributor

HonahX commented May 1, 2024

Hi everyone, I think we've had the implementation. The only "issue" is that this feature hasn't been released yet. I'll add this one to 0.7.0 milestone.

@MehulBatra Thanks for the PR btw. It is good to have more tests for this feature

@HonahX HonahX added this to the PyIceberg 0.7.0 release milestone May 1, 2024
@Fokko
Copy link
Contributor Author

Fokko commented May 13, 2024

Thanks @HonahX Let me close it for now 👍

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.

5 participants