You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by WeichenXu123 <gi...@git.apache.org> on 2016/05/08 11:30:51 UTC

[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

GitHub user WeichenXu123 opened a pull request:

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

    [spark-15212][SQL]CSV file reader when read file with first line schema do not filter blank in schema column name

    ## What changes were proposed in this pull request?
    
    When load csv file with schema, add schema column name string trim to avoid blank problem.
    
    ## How was this patch tested?
    
    construct csv data file contains schema definition with column blank such as:
    
    csv data file contains:
    ----------------------------------------------------------
    col1, col2,col3,col4,col5
    1997,Ford,E350,"ac, abs, moon",3000.00
    ....
    ------------------------------------------------------------
    notice there is a blank before col2,
    test command:
    val sqlContext = new org.apache.spark.sql.SQLContext(sc);
    var reader = sqlContext.read
    reader.option("header", true)
    var df = reader.csv("path/to/csvfile")
    df.select("col2");//check if OK
    df.registerTempTable("tab1");
    sqlContext.sql("select col2 from tab1"); //check if OK.
    
    


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

    $ git pull https://github.com/WeichenXu123/spark bugfix-15212

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

    https://github.com/apache/spark/pull/12987.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 #12987
    
----
commit 56cc34f37c712d172df6fbc27b2823a571160cda
Author: WeichenXu <we...@outlook.com>
Date:   2016-05-08T12:52:09Z

    fix bug: spark-15212

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12987#issuecomment-217710660
  
    Can one of the admins verify this patch?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12987#discussion_r62441323
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/csv/DefaultSource.scala ---
    @@ -61,7 +61,7 @@ class DefaultSource extends FileFormat with DataSourceRegister {
         val firstRow = new LineCsvReader(csvOptions).parseLine(firstLine)
     
         val header = if (csvOptions.headerFlag) {
    -      firstRow
    +      firstRow.map{_.trim}
    --- End diff --
    
    (Style nit)
    ```scala
    firstRow.map(_.trim)
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the pull request:

    https://github.com/apache/spark/pull/12987#issuecomment-218958088
  
    @WeichenXu123 I tried that with `ignoreLeadingWhiteSpace` and `ignoreTrailingWhiteSpace` and it seems working fine. I am careful of saying this because I am not a committer but personally I would suggest close this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #12987: [spark-15212][SQL]CSV file reader when read file ...

Posted by WeichenXu123 <gi...@git.apache.org>.
Github user WeichenXu123 closed the pull request at:

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


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the pull request:

    https://github.com/apache/spark/pull/12987#issuecomment-217755229
  
    I think this option should be associated with `ignoreLeadingWhiteSpace` and `ignoreTrailingWhiteSpace` options.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: [spark-15212][SQL]CSV file reader when read fi...

Posted by HyukjinKwon <gi...@git.apache.org>.
Github user HyukjinKwon commented on the pull request:

    https://github.com/apache/spark/pull/12987#issuecomment-217754950
  
    Also, the JIRA in the title, `spark-15212` might better be `SPARK-15212` (See https://cwiki.apache.org/confluence/display/SPARK/Contributing+to+Spark)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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