GitHub user HyukjinKwon opened a pull request:

    https://github.com/apache/spark/pull/18365

    [SPARK-21147][SS] Throws an analysis exception when a user-specified schema 
is given in socket source

    ## What changes were proposed in this pull request?
    
    This PR proposes to throw an exception if a schema is provided by user to 
socket source as below:
    
    ```scala
    import org.apache.spark.sql.types._
    
    val userSpecifiedSchema = StructType(
      StructField("name", StringType) ::
      StructField("area", StringType) :: Nil)
    val df = spark.readStream.format("socket").option("host", 
"localhost").option("port", 9999).schema(userSpecifiedSchema).load
    df.printSchema
    ```
    
    **Before**
    
    ```
    root
     |-- value: string (nullable = true)
    ```
    
    **After**
    
    ```
    org.apache.spark.sql.AnalysisException: The socket source does not support 
a user-specified schema.;
      at 
org.apache.spark.sql.execution.streaming.TextSocketSourceProvider.sourceSchema(socket.scala:199)
      at 
org.apache.spark.sql.execution.datasources.DataSource.sourceSchema(DataSource.scala:192)
      at 
org.apache.spark.sql.execution.datasources.DataSource.sourceInfo$lzycompute(DataSource.scala:87)
      at 
org.apache.spark.sql.execution.datasources.DataSource.sourceInfo(DataSource.scala:87)
      at 
org.apache.spark.sql.execution.streaming.StreamingRelation$.apply(StreamingRelation.scala:30)
      at 
org.apache.spark.sql.streaming.DataStreamReader.load(DataStreamReader.scala:150)
      ... 50 elided
    ```
    
    ## How was this patch tested?
    
    Unit test in `TextSocketStreamSuite`.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/HyukjinKwon/spark SPARK-21147

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/18365.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #18365
    
----
commit 92d07c0e0179a819ddacc63d3841fb7821fef1e0
Author: hyukjinkwon <[email protected]>
Date:   2017-06-20T16:02:20Z

    Throws an analysis exception when a user-specified schema is given in 
socket source

----


---
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