Skip to content

Commit 87f8200

Browse files
deepyamancpcloud
authored andcommitted
feat(duckdb): allow table_name when reading xlsx
1 parent 0e843f4 commit 87f8200

1 file changed

Lines changed: 21 additions & 11 deletions

File tree

ibis/backends/duckdb/__init__.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ def read_json(
565565
paths
566566
File or list of files
567567
table_name
568-
Optional table name
568+
An optional name to use for the created table. This defaults to a
569+
sequentially generated name.
569570
columns
570571
Optional mapping from string column name to duckdb type string.
571572
**kwargs
@@ -637,13 +638,13 @@ def read_csv(
637638
types
638639
An optional mapping of a **subset** of column names to their types.
639640
**kwargs
640-
Additional keyword arguments passed to DuckDB loading function. See
641-
https://duckdb.org/docs/data/csv for more information.
641+
Additional keyword arguments passed to DuckDB loading function.
642+
See https://duckdb.org/docs/data/csv for more information.
642643
643644
Returns
644645
-------
645646
ir.Table
646-
The just-registered table
647+
The just-registered table.
647648
648649
Examples
649650
--------
@@ -766,7 +767,7 @@ def read_geo(
766767
Returns
767768
-------
768769
ir.Table
769-
The just-registered table
770+
The just-registered table.
770771
"""
771772

772773
if not table_name:
@@ -821,11 +822,12 @@ def read_parquet(
821822
Returns
822823
-------
823824
ir.Table
824-
The just-registered table
825+
The just-registered table.
825826
"""
826827
paths = util.normalize_filenames(paths)
827828

828-
table_name = table_name or util.gen_name("read_parquet")
829+
if not table_name:
830+
table_name = util.gen_name("read_parquet")
829831

830832
if any(path.startswith(("http://", "https://", "s3://")) for path in paths):
831833
self._load_extensions(["httpfs"])
@@ -865,7 +867,8 @@ def read_delta(
865867
if path.startswith(("http://", "https://", "s3://")):
866868
extensions.append("httpfs")
867869

868-
table_name = table_name or util.gen_name("read_delta")
870+
if not table_name:
871+
table_name = util.gen_name("read_delta")
869872

870873
options = [
871874
sg.to_identifier(key).eq(sge.convert(val)) for key, val in kwargs.items()
@@ -1057,6 +1060,7 @@ def read_xlsx(
10571060
path: str | Path,
10581061
/,
10591062
*,
1063+
table_name: str | None = None,
10601064
sheet: str | None = None,
10611065
range: str | None = None,
10621066
**kwargs,
@@ -1069,10 +1073,15 @@ def read_xlsx(
10691073
The path to the Excel file.
10701074
sheet
10711075
The name of the sheet to read, eg 'Sheet3'.
1076+
table_name
1077+
An optional name to use for the created table. This defaults to
1078+
a sequentially generated name.
10721079
range
10731080
The range of cells to read, eg 'A5:Z'.
1074-
kwargs
1075-
Additional args passed to the backend's read function.
1081+
**kwargs
1082+
Additional keyword arguments passed to DuckDB loading function.
1083+
See https://duckdb.org/docs/stable/core_extensions/excel#reading-xlsx-files
1084+
for more information.
10761085
10771086
Returns
10781087
-------
@@ -1095,7 +1104,8 @@ def read_xlsx(
10951104
>>> t.columns
10961105
('a', 'b')
10971106
"""
1098-
table_name = util.gen_name("read_xlsx")
1107+
if not table_name:
1108+
table_name = util.gen_name("read_xlsx")
10991109

11001110
if sheet:
11011111
kwargs["sheet"] = sheet

0 commit comments

Comments
 (0)