zhengruifeng commented on code in PR #54180:
URL: https://github.com/apache/spark/pull/54180#discussion_r2787496027
##########
python/docs/source/tutorial/sql/python_data_source.rst:
##########
@@ -534,14 +535,14 @@ The following example demonstrates how to implement a
basic Data Source using Ar
class ArrowBatchDataSourceReader(DataSourceReader):
def __init__(self, schema, options):
self.schema: str = schema
+ self.arrow_schema = to_arrow_schema(self.schema)
self.options = options
def read(self, partition):
# Create Arrow Record Batch
keys = pa.array([1, 2, 3, 4, 5], type=pa.int32())
values = pa.array(["one", "two", "three", "four", "five"],
type=pa.string())
- schema = pa.schema([("key", pa.int32()), ("value", pa.string())])
- record_batch = pa.RecordBatch.from_arrays([keys, values],
schema=schema)
+ record_batch = pa.RecordBatch.from_arrays([keys, values],
schema=self.arrow_schema)
Review Comment:
it seems the `schema = pa.schema([("key", pa.int32()), ("value",
pa.string())])` is dropped, is this expected?
##########
python/docs/source/tutorial/sql/python_data_source.rst:
##########
@@ -534,14 +535,14 @@ The following example demonstrates how to implement a
basic Data Source using Ar
class ArrowBatchDataSourceReader(DataSourceReader):
def __init__(self, schema, options):
self.schema: str = schema
+ self.arrow_schema = to_arrow_schema(self.schema)
Review Comment:
I just noticed that this is an example.
Do this example really works?
the `self.schema: str` is a str, but the `to_arrow_schema` accept a Spark
StructType as input, not a `str`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]