Skip to content

Commit d7555e7

Browse files
timsaucerclaude
andcommitted
Add examples to docstrings for new register/read methods
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4a2d7ba commit d7555e7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

python/datafusion/context.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,11 @@ def register_batch(self, name: str, batch: pa.RecordBatch) -> None:
900900
Args:
901901
name: Name of the resultant table.
902902
batch: Record batch to register as a table.
903+
904+
Examples:
905+
>>> batch = pa.RecordBatch.from_pydict({"a": [1, 2, 3]})
906+
>>> ctx.register_batch("my_table", batch)
907+
>>> ctx.sql("SELECT * FROM my_table").show()
903908
"""
904909
self.ctx.register_batch(name, batch)
905910

@@ -1120,6 +1125,10 @@ def register_arrow(
11201125
schema: The data source schema.
11211126
file_extension: File extension to select.
11221127
table_partition_cols: Partition columns.
1128+
1129+
Examples:
1130+
>>> ctx.register_arrow("my_table", "data.arrow")
1131+
>>> ctx.sql("SELECT * FROM my_table").show()
11231132
"""
11241133
if table_partition_cols is None:
11251134
table_partition_cols = []
@@ -1381,6 +1390,10 @@ def read_arrow(
13811390
13821391
Returns:
13831392
DataFrame representation of the read Arrow IPC file.
1393+
1394+
Examples:
1395+
>>> df = ctx.read_arrow("data.arrow")
1396+
>>> df.show()
13841397
"""
13851398
if file_partition_cols is None:
13861399
file_partition_cols = []
@@ -1396,6 +1409,11 @@ def read_empty(self) -> DataFrame:
13961409
13971410
Returns:
13981411
An empty DataFrame.
1412+
1413+
Examples:
1414+
>>> df = ctx.read_empty()
1415+
>>> df.collect()
1416+
[pyarrow.RecordBatch]
13991417
"""
14001418
return self.empty_table()
14011419

0 commit comments

Comments
 (0)