Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions python/raydp/spark/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,22 @@ def get_locations(blocks):
]

def ray_dataset_to_spark_dataframe(spark: sql.SparkSession,
arrow_schema,
dataset_schema,
blocks: List[ObjectRef],
locations = None) -> DataFrame:
locations = get_locations(blocks)
if not isinstance(arrow_schema, pa.lib.Schema):
if hasattr(arrow_schema, "base_schema") and \
not isinstance(arrow_schema.base_schema, pa.lib.Schema):
raise RuntimeError(f"Schema is {type(arrow_schema)}, required pyarrow.lib.Schema. \n" \
arrow_schema = dataset_schema
if not isinstance(dataset_schema, pa.lib.Schema):
if hasattr(dataset_schema, "base_schema"):
if isinstance(dataset_schema.base_schema, pa.lib.Schema):
arrow_schema = dataset_schema.base_schema
else:
raise RuntimeError(f"Schema is {type(dataset_schema.base_schema)}, " \
f"required pyarrow.lib.Schema. \n" \
f"to_spark does not support converting non-arrow ray datasets.")
else:
raise RuntimeError(f"Schema is {type(dataset_schema)}, " \
f"required pyarrow.lib.Schema. \n" \
f"to_spark does not support converting non-arrow ray datasets.")
schema = StructType()
for field in arrow_schema:
Expand Down