subhramit commented on code in PR #58226:
URL: https://github.com/apache/spark/pull/58226#discussion_r3967048702


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/csv/CSVOptions.scala:
##########
@@ -124,7 +124,7 @@ class CSVOptions(
 
   val extension = {
     val ext = parameters.getOrElse(EXTENSION, "csv")
-    if (ext.size != 3 && !ext.forall(_.isLetter)) {
+    if (ext.size != 3 || !ext.forall(_.isLetter)) {

Review Comment:
   *Just so that I understand - are you proposing we should keep allowing 
`.abcd`, `.ab1`, `.a`, `.a/b` as valid csv extensions, as long as the contents 
of the file are comma-separated? 
   Or maybe only just reject the second and last case by validating if they 
there are an arbitrary number of letters?
   That can be a separate discussion, and requires a different change - we can 
do:
   ```scala
   if (ext.isEmpty || !ext.forall(_.isLetter)) {
     throw QueryExecutionErrors.invalidFileExtensionError("csv", ext)
   }
   ```
   but IMO that seems odd with regards to how extensions are supposed to work.
   It is fine if the extension is missing, hence `getOrElse(EXTENSION, "csv")` 
will put `.csv`
   
   Regardless, my question would still be, why should `.abcdef` or `.123` or 
`.a/b` be treated as acceptable?
   
   This was also raised by @LuciferYang in 
https://github.com/apache/spark/pull/58225#discussion_r3890228247 so I assume 
they too are aligned, but correct me if I am misinterpreting your point.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to