[
https://issues.apache.org/jira/browse/SPARK-61745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Narendra Singh updated SPARK-61745:
-----------------------------------
Description:
In Spark Connect, createDataFrame raises CANNOT_INFER_EMPTY_SCHEMA for an empty
NumPy ndarray or an empty PyArrow Table when no schema is passed. Classic
PySpark accepts both, because the input already carries its column types.
{code:python}
import numpy as np
import pyarrow as pa
spark.createDataFrame(np.empty((0, 2))).dtypes
spark.createDataFrame(pa.table({"a": pa.array([], pa.int64())})).dtypes
{code}
Classic:
{code}
[('_1', 'double'), ('_2', 'double')]
[('a', 'bigint')]
{code}
Connect:
{code}
PySparkValueError: [CANNOT_INFER_EMPTY_SCHEMA] Can not infer schema from an
empty dataset.
{code}
The Connect client checks len(data) == 0 before it reaches the ndarray and
Arrow Table branches. The check should only apply to inputs whose schema has to
be inferred from rows.
was:
In Spark Connect, createDataFrame raises CANNOT_INFER_EMPTY_SCHEMA for an empty
NumPy ndarray or an empty PyArrow Table when no schema is passed. Classic
PySpark accepts both, because the input already carries its column types.
{code:python}
import numpy as np
import pyarrow as pa
spark.createDataFrame(np.empty((0, 2))).dtypes
spark.createDataFrame(pa.table({"a": pa.array([], pa.int64())})).dtypes
{code}
Classic:
{code}
[('_1', 'double'), ('_2', 'double')]
[('a', 'bigint')]
{code}
Connect:
{code}
PySparkValueError: [CANNOT_INFER_EMPTY_SCHEMA] Can not infer schema from an
empty dataset.
> Spark Connect createDataFrame fails on empty NumPy ndarray and empty PyArrow
> Table
> ----------------------------------------------------------------------------------
>
> Key: SPARK-61745
> URL: https://issues.apache.org/jira/browse/SPARK-61745
> Project: Spark
> Issue Type: Bug
> Components: Connect, PySpark
> Affects Versions: 4.3.0
> Reporter: Narendra Singh
> Priority: Major
> Labels: pull-request-available
>
> In Spark Connect, createDataFrame raises CANNOT_INFER_EMPTY_SCHEMA for an
> empty NumPy ndarray or an empty PyArrow Table when no schema is passed.
> Classic PySpark accepts both, because the input already carries its column
> types.
> {code:python}
> import numpy as np
> import pyarrow as pa
> spark.createDataFrame(np.empty((0, 2))).dtypes
> spark.createDataFrame(pa.table({"a": pa.array([], pa.int64())})).dtypes
> {code}
> Classic:
> {code}
> [('_1', 'double'), ('_2', 'double')]
> [('a', 'bigint')]
> {code}
> Connect:
> {code}
> PySparkValueError: [CANNOT_INFER_EMPTY_SCHEMA] Can not infer schema from an
> empty dataset.
> {code}
> The Connect client checks len(data) == 0 before it reaches the ndarray and
> Arrow Table branches. The check should only apply to inputs whose schema has
> to be inferred from rows.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]