Github user Jay357089 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/107#discussion_r76949708
  
    --- Diff: 
integration/spark/src/test/scala/org/apache/carbondata/integration/spark/testsuite/dataload/TestLoadDataWithSingleQuotechar.scala
 ---
    @@ -0,0 +1,60 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +
    +package org.apache.carbondata.integration.spark.testsuite.dataload
    +
    +import org.apache.spark.sql.{DataFrame, Row}
    +import org.apache.spark.sql.common.util.CarbonHiveContext._
    +import org.apache.spark.sql.common.util.QueryTest
    +import org.scalatest.BeforeAndAfterAll
    +
    +/**
    + * Test Class for data loading when there is single quote in fact data
    + *
    + */
    +class TestLoadDataWithSingleQuotechar extends QueryTest with 
BeforeAndAfterAll {
    +  override def beforeAll {
    +    sql("DROP TABLE IF EXISTS carbontable")
    +    sql(
    +      "CREATE TABLE carbontable (id Int, name String) STORED BY 
'carbondata'")
    +  }
    +
    +  test("test data loading with single quote char") {
    +    try {
    +      sql(
    +        "LOAD DATA LOCAL INPATH 
'./src/test/resources/dataWithSingleQuote.csv' INTO TABLE " +
    +          "carbontable OPTIONS('DELIMITER'= ',')")
    +      checkAnswer(
    +        sql("SELECT * from carbontable"),
    +        Seq(Row("Tom",1),
    +          Row("Tony\n3,Lily",2),
    +          Row("Games\"",4),
    +          Row("prival\"\n6,\"hello\"",5)
    +        )
    --- End diff --
    
    ## i create hive hive table and load, just like below.
    
    CREATE TABLE hiveTable(id int, name string)
    ROW FORMAT
    SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
    WITH SERDEPROPERTIES (
       "separatorChar" = ",",
       "quoteChar"     = "\"",
       "escapeChar"    = "\\"
    )  
    STORED AS TEXTFILE;
    
    ## and find that when data is like below, 
    1,Tom
    2,"Lily"
    ##  that query can get the correct result,
     +-----+-------+--+
    | id  | name  |
    +-----+-------+--+
    | 1   | Tom   |
    | 2   | Lily  |
    +-----+-------+--+
    ## but if data is like below
    1,Tom
    2,"Tony
    3,Lily"
    ## query result is like below
    +-----+-------+--+
    | id  | name  |
    +-----+-------+--+
    | 1   | Tom   |
    | 2   | NULL  |
    | 3   | NULL  |
    +-----+-------+--+
    ## while carbon query is like below
    +--------------+-----+--+
    |     name     | id  |
    +--------------+-----+--+
    | Tom          | 1   |
    | Tony
    3,Lily  | 2   |
    +--------------+-----+--+
    
    so, now we can see that, hive can support quote char, but can not support 
multiline, while carbon can support both, this is the difference, and i think 
that carbon's query result is right, no need to keep same with hive.
    ## so, what we should only concern about is what i raise in 
[CARBONDATA-191].
    @gvramana @manishgupta88 what is ur opionion?


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

Reply via email to