srowen commented on a change in pull request #29516:
URL: https://github.com/apache/spark/pull/29516#discussion_r475143227
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/CSVExprUtils.scala
##########
@@ -25,16 +25,23 @@ object CSVExprUtils {
* This is currently being used in CSV reading path and CSV schema inference.
*/
def filterCommentAndEmpty(iter: Iterator[String], options: CSVOptions):
Iterator[String] = {
- iter.filter { line =>
- line.trim.nonEmpty && !line.startsWith(options.comment.toString)
+ if (options.isCommentSet) {
+ val commentPrefix = options.comment.toString
+ iter.filter { line =>
+ val trimmed = line.trim
Review comment:
I just added this while here to avoid trimming twice
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/CSVOptions.scala
##########
@@ -220,7 +220,9 @@ class CSVOptions(
format.setQuote(quote)
format.setQuoteEscape(escape)
charToEscapeQuoteEscaping.foreach(format.setCharToEscapeQuoteEscaping)
- format.setComment(comment)
+ if (isCommentSet) {
Review comment:
Arguably we should rework the handling of 'optional' configs to not use
this default of `\u0000` to mean "none" but I avoided that here. One
consequence is that you cannot use `\u0000` as a comment char right now.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]