Github user lw-lin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/13575#discussion_r66465201
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSource.scala
 ---
    @@ -246,7 +247,12 @@ case class DataSource(
           case s: StreamSinkProvider =>
             s.createSink(sparkSession.sqlContext, options, partitionColumns, 
outputMode)
     
    -      case parquet: parquet.ParquetFileFormat =>
    +      // TODO: Remove the `isInstanceOf` check when other formats have 
been ported
    +      case fileFormat: FileFormat
    +        if (fileFormat.isInstanceOf[CSVFileFormat]
    +          || fileFormat.isInstanceOf[JsonFileFormat]
    --- End diff --
    
    @ScrapCodes , thanks! But I'm afraid that syntax would raise a compilation 
error:
    ```
    [ERROR] .../datasources/DataSource.scala:250: illegal variable in pattern 
alternative
    [ERROR]   case fileFormat: CSVFileFormat | JsonFileFormat | 
ParquetFileFormat | TextFileFormat =>
    [ERROR]        ^
    ```
    A work-around can be the following, but I found it somewhat less intuitive:
    ```scala
    case fileFormat@(_: CSVFileFormat |
                     _: JsonFileFormat |
                     _: ParquetFileFormat |
                     _: TextFileFormat) =>
      // other code
      ... fileFormat.asInstanceOf[FileFormat] ...
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to