rangareddy commented on issue #10770:
URL: https://github.com/apache/hudi/issues/10770#issuecomment-2578014935
Hi @Cpandey43
Below is the PySpark code to ingest Array[bytes] data.
```python
from pyspark.sql.types import StructType, StructField, ArrayType,
BinaryType, StringType
data = [
("1", [b"byte1", b"byte2"]),
("2", [b"byte3", b"byte4"]),
]
schema = StructType([
StructField("id", StringType(), True),
StructField("byte_array_column", ArrayType(BinaryType()), True),
])
df = spark.createDataFrame(data, schema)
df.show(truncate=False)
table_name = "hudi_array_byte_table"
output_path = f"s3a://warehouse/{table_name}"
hudi_options = {
"hoodie.table.name": table_name,
"hoodie.datasource.write.recordkey.field": "id",
"hoodie.datasource.write.partitionpath.field": "",
"hoodie.datasource.write.table.type": "COPY_ON_WRITE",
"hoodie.datasource.write.precombine.field": "id",
}
df.write.format("hudi") \
.options(**hudi_options) \
.mode("overwrite") \
.save(output_path)
hudi_df = spark.read.format("hudi").load(output_path)
hudi_df.show(truncate=False)
```
--
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]