You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/26 21:51:11 UTC
[GitHub] [spark] viirya commented on a change in pull request #32332: [SPARK-35211][PYTHON] verify inferred schema for _create_dataframe
viirya commented on a change in pull request #32332:
URL: https://github.com/apache/spark/pull/32332#discussion_r676968916
##########
File path: python/pyspark/sql/session.py
##########
@@ -697,12 +712,19 @@ def prepare(obj):
verify_func(obj)
return obj,
else:
+ no_need_to_prepare = True
prepare = lambda obj: obj
- if isinstance(data, RDD):
- rdd, schema = self._createFromRDD(data.map(prepare), schema, samplingRatio)
+ if isinstance(data, RDD) and no_need_to_prepare:
+ rdd, schema = self._createFromRDD(
+ data, schema, verifySchema, samplingRatio)
+ elif isinstance(data, RDD) and (not no_need_to_prepare):
+ rdd, schema = self._createFromRDD(
+ data.map(prepare), schema, verifySchema, samplingRatio)
Review comment:
I feel adding another `if` against `no_need_to_prepare` under `if isinstance(data, RDD)` looks more readable, e.g.:
```python
if isinstance(data, RDD):
if no_need_to_prepare:
rdd, schema = self._createFromRDD(
data, schema, verifySchema, samplingRatio)
else:
rdd, schema = self._createFromRDD(
data.map(prepare), schema, verifySchema, samplingRatio)
else:
if no_need_to_prepare:
...
```
or
```python
if isinstance(data, RDD):
rdd, schema = self._createFromRDD(
data if no_need_to_prepare else data.map(prepare), schema, verifySchema, samplingRatio)
else:
...
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org