ibis icon indicating copy to clipboard operation
ibis copied to clipboard

refactor: standardize list_tables signature

Open datapythonista opened this issue 4 years ago • 1 comments

All backends seem to provide list_tables, but with a variety of signatures.

I propose to standardize all them to the same, so things are simpler and clearer, and code can be reused from one backend to another easier. My preferred signature would be:

def list_tables(self, like: str = None) -> List[str]:

We can add a FutureWarning for Ibis 2.0, if other parameters are used. I'll add **kwargs, and if not empty, a warning will be shown, and in 3.0 we can remove 3.0. I'll also deprecate list_tables in Database, in favor of the Client one.

Let me know if anyone disagrees, or any comment.

The list of current signatures is next:

ibis/backends/clickhouse/client.py:    def list_tables(self, like=None, database=None):
ibis/backends/mysql/client.py:    def list_tables(self, like=None, database=None, schema=None):
ibis/backends/csv/__init__.py:    def list_tables(self, path=None):
ibis/backends/parquet/__init__.py:    def list_tables(self, path=None):
ibis/backends/dask/client.py:    def list_tables(self, like: str = None) -> List[str]:
ibis/backends/hdf5/__init__.py:    def list_tables(self, path=None):
ibis/backends/spark/client.py:    def list_tables(self, like=None, database=None):
ibis/backends/postgres/client.py:    def list_tables(self, like=None, database=None, schema=None):
ibis/backends/impala/kudu_support.py:    def list_tables(self, filter=''):
ibis/backends/impala/client.py:    def list_tables(self, like=None, database=None):
ibis/backends/sqlite/client.py:    def list_tables(self, like=None, database=None, schema=None):
ibis/backends/base/file/__init__.py:    def list_tables(self, path=None):
ibis/backends/base/file/__init__.py:    def list_tables(self, path=None):
ibis/backends/base/sql/alchemy/client.py:    def list_tables(
ibis/backends/base/sql/alchemy/database.py:    def list_tables(self, like=None):
ibis/backends/base/sql/alchemy/database.py:    def list_tables(self, like=None, schema=None):
ibis/backends/base/client.py:    def list_tables(self, like: str = None) -> list:
ibis/backends/pandas/client.py:    def list_tables(self, like=None):

datapythonista avatar Jul 24 '21 03:07 datapythonista

I think it's a good idea to deprecate Database.list_tables and keep only Client.list_tables. It seems like backends want the ability to expose their own filtering mechanisms, and like may be either unsupported or insufficient; so we should add an abstract method which takes **kwargs instead of any guaranteed arguments. Then we can leave the existing Client.list_tables() as they are.

saulpw avatar Jan 13 '22 22:01 saulpw