@@ -629,15 +629,17 @@ def list_catalogs(self, *, like: str | None = None) -> list[str]:
629
629
A collection of `database` is referred to as a `catalog`.
630
630
631
631
These terms are mapped onto the corresponding features in each
632
- backend (where available), regardless of whether the backend itself
633
- uses the same terminology.
632
+ backend (where available), regardless of the terminology the backend uses.
633
+
634
+ See the
635
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
636
+ for more info.
634
637
:::
635
638
636
639
Parameters
637
640
----------
638
641
like
639
- A pattern in Python's regex format to filter returned database
640
- names.
642
+ A pattern in Python's regex format to filter returned catalog names.
641
643
642
644
Returns
643
645
-------
@@ -659,8 +661,11 @@ def create_catalog(self, name: str, /, *, force: bool = False) -> None:
659
661
A collection of `database` is referred to as a `catalog`.
660
662
661
663
These terms are mapped onto the corresponding features in each
662
- backend (where available), regardless of whether the backend itself
663
- uses the same terminology.
664
+ backend (where available), regardless of the terminology the backend uses.
665
+
666
+ See the
667
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
668
+ for more info.
664
669
:::
665
670
666
671
Parameters
@@ -682,8 +687,11 @@ def drop_catalog(self, name: str, /, *, force: bool = False) -> None:
682
687
A collection of `database` is referred to as a `catalog`.
683
688
684
689
These terms are mapped onto the corresponding features in each
685
- backend (where available), regardless of whether the backend itself
686
- uses the same terminology.
690
+ backend (where available), regardless of the terminology the backend uses.
691
+
692
+ See the
693
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
694
+ for more info.
687
695
:::
688
696
689
697
Parameters
@@ -709,8 +717,11 @@ def list_databases(
709
717
A collection of `database` is referred to as a `catalog`.
710
718
711
719
These terms are mapped onto the corresponding features in each
712
- backend (where available), regardless of whether the backend itself
713
- uses the same terminology.
720
+ backend (where available), regardless of the terminology the backend uses.
721
+
722
+ See the
723
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
724
+ for more info.
714
725
:::
715
726
716
727
Parameters
@@ -737,6 +748,20 @@ def create_database(
737
748
) -> None :
738
749
"""Create a database named `name` in `catalog`.
739
750
751
+ ::: {.callout-note}
752
+ ## Ibis does not use the word `schema` to refer to database hierarchy.
753
+
754
+ A collection of `table` is referred to as a `database`.
755
+ A collection of `database` is referred to as a `catalog`.
756
+
757
+ These terms are mapped onto the corresponding features in each
758
+ backend (where available), regardless of the terminology the backend uses.
759
+
760
+ See the
761
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
762
+ for more info.
763
+ :::
764
+
740
765
Parameters
741
766
----------
742
767
name
@@ -755,13 +780,27 @@ def drop_database(
755
780
) -> None :
756
781
"""Drop the database with `name` in `catalog`.
757
782
783
+ ::: {.callout-note}
784
+ ## Ibis does not use the word `schema` to refer to database hierarchy.
785
+
786
+ A collection of `table` is referred to as a `database`.
787
+ A collection of `database` is referred to as a `catalog`.
788
+
789
+ These terms are mapped onto the corresponding features in each
790
+ backend (where available), regardless of the terminology the backend uses.
791
+
792
+ See the
793
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
794
+ for more info.
795
+ :::
796
+
758
797
Parameters
759
798
----------
760
799
name
761
800
Name of the schema to drop.
762
801
catalog
763
- Name of the catalog to drop the database from. If `None`, the
764
- current catalog is used.
802
+ Name of the catalog to drop the database from.
803
+ If `None`, the current catalog is used.
765
804
force
766
805
If `False`, an exception is raised if the database does not exist.
767
806
@@ -981,73 +1020,105 @@ def _filter_with_like(values: Iterable[str], like: str | None = None) -> list[st
981
1020
def list_tables (
982
1021
self , * , like : str | None = None , database : tuple [str , str ] | str | None = None
983
1022
) -> list [str ]:
984
- """Return the list of table names in the current database.
1023
+ """The table names that match `like` in the given ` database` .
985
1024
986
1025
For some backends, the tables may be files in a directory,
987
1026
or other equivalent entities in a SQL database.
988
1027
989
- ::: {.callout-note}
990
- ## Ibis does not use the word `schema` to refer to database hierarchy.
991
-
992
- A collection of tables is referred to as a `database`.
993
- A collection of `database` is referred to as a `catalog`.
994
-
995
- These terms are mapped onto the corresponding features in each
996
- backend (where available), regardless of whether the backend itself
997
- uses the same terminology.
998
- :::
999
-
1000
1028
Parameters
1001
1029
----------
1002
1030
like
1003
1031
A pattern in Python's regex format.
1004
1032
database
1005
- The database from which to list tables.
1006
- If not provided, the current database is used.
1033
+ The database, or (catalog, database) from which to list tables.
1034
+
1035
+ For backends that support a single-level table hierarchy,
1036
+ you can pass in a string like `"bar"`.
1007
1037
For backends that support multi-level table hierarchies, you can
1008
1038
pass in a dotted string path like `"catalog.database"` or a tuple of
1009
1039
strings like `("catalog", "database")`.
1040
+ If not provided, the current database
1041
+ (and catalog, if applicable for this backend) is used.
1042
+
1043
+ See the
1044
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
1045
+ for more info.
1010
1046
1011
1047
Returns
1012
1048
-------
1013
1049
list[str]
1014
1050
The list of the table names that match the pattern `like`.
1015
1051
1052
+ Examples
1053
+ --------
1054
+ >>> import ibis
1055
+ >>> con = ibis.duckdb.connect()
1056
+ >>> foo = con.create_table("foo", schema=ibis.schema(dict(a="int")))
1057
+ >>> con.list_tables()
1058
+ ['foo']
1059
+ >>> bar = con.create_view("bar", foo)
1060
+ >>> con.list_tables()
1061
+ ['bar', 'foo']
1062
+ >>> con.create_database("my_database")
1063
+ >>> con.list_tables(database="my_database")
1064
+ []
1065
+ >>> con.raw_sql("CREATE TABLE my_database.baz (a INTEGER)") # doctest: +ELLIPSIS
1066
+ <duckdb.duckdb.DuckDBPyConnection object at 0x...>
1067
+ >>> con.list_tables(database="my_database")
1068
+ ['baz']
1016
1069
"""
1017
1070
1018
1071
@abc .abstractmethod
1019
1072
def table (
1020
1073
self , name : str , / , * , database : tuple [str , str ] | str | None = None
1021
1074
) -> ir .Table :
1022
- """Construct a table expression.
1023
-
1024
- ::: {.callout-note}
1025
- ## Ibis does not use the word `schema` to refer to database hierarchy.
1026
-
1027
- A collection of tables is referred to as a `database`.
1028
- A collection of `database` is referred to as a `catalog`.
1029
-
1030
- These terms are mapped onto the corresponding features in each
1031
- backend (where available), regardless of whether the backend itself
1032
- uses the same terminology.
1033
- :::
1075
+ """Construct a table expression from the corresponding table in the backend.
1034
1076
1035
1077
Parameters
1036
1078
----------
1037
1079
name
1038
1080
Table name
1039
1081
database
1040
- Database name
1041
- If not provided, the current database is used.
1082
+ The database, or (catalog, database) from which to get the table.
1083
+
1084
+ For backends that support a single-level table hierarchy,
1085
+ you can pass in a string like `"bar"`.
1042
1086
For backends that support multi-level table hierarchies, you can
1043
1087
pass in a dotted string path like `"catalog.database"` or a tuple of
1044
1088
strings like `("catalog", "database")`.
1089
+ If not provided, the current database
1090
+ (and catalog, if applicable for this backend) is used.
1091
+
1092
+ See the
1093
+ [Table Hierarchy Concepts Guide](/concepts/backend-table-hierarchy.qmd)
1094
+ for more info.
1045
1095
1046
1096
Returns
1047
1097
-------
1048
1098
Table
1049
1099
Table expression
1050
1100
1101
+ Examples
1102
+ --------
1103
+ >>> import ibis
1104
+ >>> backend = ibis.duckdb.connect()
1105
+
1106
+ Get the "foo" table from the current database
1107
+ (and catalog, if applicable for this backend):
1108
+
1109
+ >>> backend.table("foo") # doctest: +SKIP
1110
+
1111
+ Get the "foo" table from the "bar" database
1112
+ (in DuckDB's language they would say the "bar" schema,
1113
+ in SQL this would be `"bar"."foo"`)
1114
+
1115
+ >>> backend.table("foo", database="bar") # doctest: +SKIP
1116
+
1117
+ Get the "foo" table from the "bar" database, within the "baz" catalog
1118
+ (in DuckDB's language they would say the "bar" schema, and "baz" database,
1119
+ in SQL this would be `"baz"."bar"."foo"`)
1120
+
1121
+ >>> backend.table("foo", database=("baz", "bar")) # doctest: +SKIP
1051
1122
"""
1052
1123
1053
1124
@property
0 commit comments