QuestionQ161
VerifiedTroubleshooting and Tuning Apache Spark DataFrame API Applications.A data engineer is addressing complaints that a feature-engineering job has been declining in performance over time. After discussing the feature table with the data science team, it was decided that replacing the percentile() Spark function with approx_percentile() Spark function is acceptable to trade some accuracy for performance.
features_df = raw_df \
.select(F.approx_percentile("price", percentage=[0.25, 0.5, 0.75], accuracy=1000).alias("price_perc"))
The initial code change provides a greater-than-expected improvement in job runtime; however, the data scientists find that the returned percentiles are now drifting too far from the correct values.
Which change should the data engineer make to resolve the issue?
Community Discussion