Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21574#discussion_r195632412
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Relation.scala
 ---
    @@ -105,117 +105,57 @@ case class StreamingDataSourceV2Relation(
     }
     
     object DataSourceV2Relation {
    +
       private implicit class SourceHelpers(source: DataSourceV2) {
    -    def asReadSupport: ReadSupport = {
    -      source match {
    -        case support: ReadSupport =>
    -          support
    -        case _: ReadSupportWithSchema =>
    -          // this method is only called if there is no user-supplied 
schema. if there is no
    -          // user-supplied schema and ReadSupport was not implemented, 
throw a helpful exception.
    -          throw new AnalysisException(s"Data source requires a 
user-supplied schema: $name")
    -        case _ =>
    -          throw new AnalysisException(s"Data source is not readable: 
$name")
    -      }
    -    }
     
    -    def asReadSupportWithSchema: ReadSupportWithSchema = {
    -      source match {
    -        case support: ReadSupportWithSchema =>
    -          support
    -        case _: ReadSupport =>
    -          throw new AnalysisException(
    -            s"Data source does not support user-supplied schema: $name")
    -        case _ =>
    -          throw new AnalysisException(s"Data source is not readable: 
$name")
    -      }
    +    private def asReadSupport: ReadSupport = source match {
    --- End diff --
    
    strip one indentation level to shorten the code.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to