[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730]added decimal type i...

classic Classic list List threaded Threaded
37 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105967481
 
    --- Diff: integration/spark/src/test/scala/org/apache/carbondata/integration/spark/testsuite/dataframe/Decimal_DataFrameTest.scala ---
    @@ -0,0 +1,62 @@
    +/*
    + * 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.dataframe
    +
    +import java.math.BigDecimal
    +
    +import org.apache.spark.sql.common.util.DataFrameUtils
    +import org.apache.spark.sql.types.{DecimalType, DoubleType, StringType, StructField, StructType}
    +import org.apache.spark.sql.{Row, SaveMode}
    +import org.scalatest.FunSuiteLike
    +
    +class Decimal_DataFrameTest extends FunSuiteLike {
    +
    +  val carbonContext = DataFrameUtils.createCarbonContext("Decimal_DataFrameTest")
    +
    +  carbonContext.sql("DROP TABLE IF EXISTS carbon3")
    +
    +  val rdd = carbonContext.sc.parallelize(
    +    Row(52.23, BigDecimal.valueOf(1234.4440), "Warsaw") ::
    +    Row(42.30, BigDecimal.valueOf(9999.9990), "Corte") :: Nil)
    +
    +  val schema = StructType(
    +    StructField("double", DoubleType, nullable = false) ::
    +    StructField("decimal", DecimalType(9, 2), nullable = false) ::
    +    StructField("string", StringType, nullable = false) :: Nil)
    +
    +  val dataFrame = carbonContext.createDataFrame(rdd, schema)
    +
    +  dataFrame.printSchema()
    +
    +  dataFrame.write
    +    .format("carbondata")
    +    .option("tableName", "carbon3")
    +    .option("compress", "true")
    +    .mode(SaveMode.Overwrite)
    +    .save()
    +
    +  test("select salary from table") {
    +    val actualDataFrame = carbonContext.sql("SELECT decimal FROM carbon3")
    +    actualDataFrame.show()
    +    val actualResult = actualDataFrame.collect().toList
    +    val expectedResult = List(Row(10000.00) :: Nil, Row(1234.44) :: Nil)
    +    assert((actualResult diff expectedResult).isEmpty)
    --- End diff --
   
    use `checkAnswer` like in the `TestLoadDataFrame`


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105967586
 
    --- Diff: integration/spark/src/test/scala/org/apache/carbondata/integration/spark/testsuite/dataframe/Decimal_DataFrameTest.scala ---
    @@ -0,0 +1,62 @@
    +/*
    + * 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.dataframe
    +
    +import java.math.BigDecimal
    +
    +import org.apache.spark.sql.common.util.DataFrameUtils
    +import org.apache.spark.sql.types.{DecimalType, DoubleType, StringType, StructField, StructType}
    +import org.apache.spark.sql.{Row, SaveMode}
    +import org.scalatest.FunSuiteLike
    +
    +class Decimal_DataFrameTest extends FunSuiteLike {
    +
    +  val carbonContext = DataFrameUtils.createCarbonContext("Decimal_DataFrameTest")
    +
    +  carbonContext.sql("DROP TABLE IF EXISTS carbon3")
    +
    +  val rdd = carbonContext.sc.parallelize(
    +    Row(52.23, BigDecimal.valueOf(1234.4440), "Warsaw") ::
    +    Row(42.30, BigDecimal.valueOf(9999.9990), "Corte") :: Nil)
    +
    +  val schema = StructType(
    +    StructField("double", DoubleType, nullable = false) ::
    +    StructField("decimal", DecimalType(9, 2), nullable = false) ::
    +    StructField("string", StringType, nullable = false) :: Nil)
    +
    +  val dataFrame = carbonContext.createDataFrame(rdd, schema)
    +
    +  dataFrame.printSchema()
    +
    +  dataFrame.write
    +    .format("carbondata")
    +    .option("tableName", "carbon3")
    +    .option("compress", "true")
    +    .mode(SaveMode.Overwrite)
    +    .save()
    +
    +  test("select salary from table") {
    +    val actualDataFrame = carbonContext.sql("SELECT decimal FROM carbon3")
    +    actualDataFrame.show()
    +    val actualResult = actualDataFrame.collect().toList
    +    val expectedResult = List(Row(10000.00) :: Nil, Row(1234.44) :: Nil)
    +    assert((actualResult diff expectedResult).isEmpty)
    +
    --- End diff --
   
    drop the table created by dataframe.write also


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105967718
 
    --- Diff: integration/spark/src/test/scala/org/apache/spark/sql/common/util/DataFrameUtils.scala ---
    @@ -0,0 +1,43 @@
    +package org.apache.spark.sql.common.util
    +
    +import java.io.File
    +
    +import org.apache.spark.sql.CarbonContext
    +import org.apache.spark.{SparkConf, SparkContext}
    +
    +import org.apache.carbondata.core.util.CarbonProperties
    +
    +
    +object DataFrameUtils {
    --- End diff --
   
    I think this is not required, if you reuse `TestLoadDataFrame`


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105968216
 
    --- Diff: integration/spark2/src/test/scala/org/apache/spark/carbondata/dataframe/Decimal_DataFrameTest.scala ---
    @@ -0,0 +1,59 @@
    +/*
    + * 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.spark.carbondata.dataframe
    +
    +import org.apache.spark.sql.types.{DecimalType, DoubleType, StringType, StructField, StructType}
    +import org.apache.spark.sql.{Row, SaveMode}
    +import org.apache.spark.util.DataFrameUtils
    +import org.scalatest.FunSuiteLike
    +
    +class Decimal_DataFrameTest extends FunSuiteLike {
    --- End diff --
   
    This is not required, resuse `TestLoadDataFrame` in spark-common-test module


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105968595
 
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/CarbonDataFrameWriter.scala ---
    @@ -34,12 +34,37 @@ class CarbonDataFrameWriter(sqlContext: SQLContext, val dataFrame: DataFrame) {
       def saveAsCarbonFile(parameters: Map[String, String] = Map()): Unit = {
         // create a new table using dataframe's schema and write its content into the table
         sqlContext.sparkSession.sql(makeCreateTableString(dataFrame.schema,
    -    new CarbonOption(parameters)))
    +      new CarbonOption(parameters)))
         writeToCarbonFile(parameters)
       }
     
    -  def appendToCarbonFile(parameters: Map[String, String] = Map()): Unit = {
    -    writeToCarbonFile(parameters)
    +  private def makeCreateTableString(schema: StructType, options: CarbonOption): String = {
    --- End diff --
   
    It seems this function is moved from line 144 to here? It is better not to move it so that it is easier to review


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/630#discussion_r105968680
 
    --- Diff: integration/spark2/src/main/scala/org/apache/spark/sql/CarbonDataFrameWriter.scala ---
    @@ -34,12 +34,37 @@ class CarbonDataFrameWriter(sqlContext: SQLContext, val dataFrame: DataFrame) {
       def saveAsCarbonFile(parameters: Map[String, String] = Map()): Unit = {
         // create a new table using dataframe's schema and write its content into the table
         sqlContext.sparkSession.sql(makeCreateTableString(dataFrame.schema,
    -    new CarbonOption(parameters)))
    +      new CarbonOption(parameters)))
         writeToCarbonFile(parameters)
       }
     
    -  def appendToCarbonFile(parameters: Map[String, String] = Map()): Unit = {
    -    writeToCarbonFile(parameters)
    +  private def makeCreateTableString(schema: StructType, options: CarbonOption): String = {
    +    val carbonSchema = schema.map { field =>
    +      s"${ field.name } ${ convertToCarbonType(field.dataType) }"
    +    }
    +    s"""
    +          CREATE TABLE IF NOT EXISTS ${ options.dbName }.${ options.tableName }
    +          (${ carbonSchema.mkString(", ") })
    +          using org.apache.spark.sql.CarbonSource
    +          OPTIONS('dbName'='${ options.dbName }', 'tableName'='${ options.tableName }')
    +      """
    +  }
    +
    +  private def convertToCarbonType(sparkType: DataType): String = {
    --- End diff --
   
    It seems this function is moved from line 144 to here? It is better not to move it so that it is easier to review


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1142/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1143/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1145/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1148/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1149/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Failed  with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1150/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/1151/



---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user anubhav100 commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    @jackylk all changes done can you review please?


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user jackylk commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    LGTM
    please fix CI failing


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata issue #630: [CARBONDATA-730] added decimal type in carb...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user anubhav100 commented on the issue:

    https://github.com/apache/incubator-carbondata/pull/630
 
    @jackylk i think the ci  issue is resolved that was because of test case failure in spark package


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
Reply | Threaded
Open this post in threaded view
|

[GitHub] incubator-carbondata pull request #630: [CARBONDATA-730] added decimal type ...

qiuchenjian-2
In reply to this post by qiuchenjian-2
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-carbondata/pull/630


---
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 [hidden email] or file a JIRA ticket
with INFRA.
---
12