viirya commented on a change in pull request #30972:
URL: https://github.com/apache/spark/pull/30972#discussion_r550017618
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/CsvOutputWriter.scala
##########
@@ -47,3 +50,15 @@ class CsvOutputWriter(
override def close(): Unit = gen.close()
}
+
+object CsvOutputWriter {
+
+ def createUnivocityGenerator(
+ maxLength: Int,
+ writer: OutputStreamWriter,
+ dataSchema: StructType,
+ params: CSVOptions): UnivocityGenerator = this.synchronized {
+ NormalizedString.getCache.setMaxStringLength(maxLength)
+ new UnivocityGenerator(dataSchema, writer, params)
Review comment:
Is the max string length a global setting? If it is, it means
`maxColumnNameLength` at different queries can conflict each others?
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/csv/CSVSuite.scala
##########
@@ -2448,8 +2448,27 @@ abstract class CSVSuite
.option("header", "true")
.option("unescapedQuoteHandling", "STOP_AT_CLOSING_QUOTE")
.csv(dataPath).collect()
- val exceptResults = Array(row1, row2)
- assert(result.sameElements(exceptResults))
+ val expectedResults = Array(row1, row2)
+ assert(result.sameElements(expectedResults))
+ }
+ }
+
+ test("write csv data correctly with the configurable max column name
length") {
Review comment:
Please add `SPARK-33940` before test name, e.g., "SPARK-33940: write csv
data ..."
----------------------------------------------------------------
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]