GitHub user MaxGekk opened a pull request: https://github.com/apache/spark/pull/23070
[SPARK-26099][SQL] Verification of the corrupt column in from_csv/from_json ## What changes were proposed in this pull request? The corrupt column specified via JSON/CSV option *columnNameOfCorruptRecord* must have the `string` type and be `nullable`. This has been already checked in `DataFrameReader`.`csv`/`json` and in `Json`/`CsvFileFormat` but not in `from_json`/`from_csv`. The PR adds such checks inside functions as well. ## How was this patch tested? Added tests to `Json`/`CsvExpressionSuite` for checking type of the corrupt column. They don't check the `nullable` property because `schema` is forcibly casted to nullable. You can merge this pull request into a Git repository by running: $ git pull https://github.com/MaxGekk/spark-1 verify-corrupt-column-csv-json Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/23070.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #23070 ---- commit 7af0df3cdf6df04e0df6eecb9e6ebd024bcc33c6 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:03:05Z Added a test for from_csv to check type of corrupt column commit af7cdd6b0512d1a2595d8803007e9f27c9ea9c30 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:40:39Z Verify corrupt column in from_csv commit 79a1df871da3f7e2aaa37169b567197630a8fc93 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:47:26Z Test refactoring commit 8bc9d26ba9105b52fb122bbecbb7a3bed99aa361 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:47:51Z Removing blank line commit a6e711a12df56da24db0575e63d36001771ba384 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:50:20Z Added a test for from_json commit f55e1277ed41606f8f4b1547dfdf1b171b93dbe8 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T10:52:40Z Checking corrupt column in from_json commit 10d5311e7b35f7c4e9aa11c7d822619d2c0dedfa Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T11:10:43Z Using verifyColumnNameOfCorruptRecord in JsonDatasource commit bd2debcc2237ad178ef00b762bcdc80b63d1ecb7 Author: Maxim Gekk <max.gekk@...> Date: 2018-11-17T11:15:14Z Using verifyColumnNameOfCorruptRecord in CSV datasource ---- --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org