You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@carbondata.apache.org by xubo245 <gi...@git.apache.org> on 2018/04/18 09:36:45 UTC

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

GitHub user xubo245 opened a pull request:

    https://github.com/apache/carbondata/pull/2181

    [CARBONDATA-2355] Support run SQL on carbondata files directly

        This is for carbonfile generated by SDK
    
    Be sure to do all of the following checklist to help us incorporate 
    your contribution quickly and easily:
    
     - [ ] Any interfaces changed?
     
     - [ ] Any backward compatibility impacted?
     
     - [ ] Document update required?
    
     - [ ] Testing done
            Please provide details on 
            - Whether new unit test cases have been added or why no new tests are required?
            - How it is tested? Please attach test report.
            - Is it a performance related change? Please attach the performance test report.
            - Any additional information to help reviewers in testing this change.
           
     - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA. 
    


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

    $ git pull https://github.com/xubo245/carbondata CARBONDATA-2355-directlySQL

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

    https://github.com/apache/carbondata/pull/2181.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 #2181
    
----
commit e40f68ff555b90bcdd8e5dd69967d64b629b9d93
Author: xubo245 <60...@...>
Date:   2018-04-18T09:34:12Z

    [CARBONDATA-2355] Support run SQL on carbondata files directly
    
        This is for carbonfile generated by SDK

----


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r192337901
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,100 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbon files directly
    + * No need to create table first
    + * TODO: support more than one carbon file
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    --- End diff --
    
    please optimize the comment.


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5471/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4169/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4819/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4051/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/6037/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4183/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/6185/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5448/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3934/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xuchuanyin <gi...@git.apache.org>.
Github user xuchuanyin commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    @xubo245 This PR is only an example, not the function implementation, right?


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5466/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5219/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r183268192
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableUsingSparkCarbonFileFormat.scala ---
    @@ -153,6 +153,34 @@ class TestCreateTableUsingSparkCarbonFileFormat extends QueryTest with BeforeAnd
         cleanTestData()
       }
     
    +  test("Running SQL directly and read carbondata files (sdk Writer Output) using the SparkCarbonFileFormat ") {
    +    buildTestData(false)
    +    assert(new File(filePath).exists())
    +    sql("DROP TABLE IF EXISTS sdkOutputTable")
    +
    +    //data source file format
    +    if (sqlContext.sparkContext.version.startsWith("2.1")) {
    +      //data source file format
    +      sql(s"""CREATE TABLE sdkOutputTable USING carbonfile OPTIONS (PATH '$filePath') """)
    --- End diff --
    
    It's one of fileformat.


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4077/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4878/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/5067/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by chenliang613 <gi...@git.apache.org>.
Github user chenliang613 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    LGTM


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184398152
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis)
    +            .buildWriterForCSVInput()
    +        } else {
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis).withBlockSize(2)
    +            .buildWriterForCSVInput()
    +        }
    +      var i = 0
    +      var row = num
    +      while (i < row) {
    +        writer.write(Array[String]("robot" + i, String.valueOf(i), String.valueOf(i.toDouble / 2)))
    +        i += 1
    +      }
    +      writer.close()
    +    } catch {
    +      case ex: Exception => None
    +      case e => None
    +    }
    +  }
    +
    +  def cleanTestData(path: String): Unit = {
    +    FileUtils.deleteDirectory(new File(path))
    +  }
    +
    +  // scalastyle:off
    +  def main(args: Array[String]) {
    +    val cc = ExampleUtils.createCarbonSession("DirectSQLExample")
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +      + "../../../..").getCanonicalPath
    +    System.setProperty("path.target", s"$rootPath/examples/spark2/target")
    +    val path = s"$rootPath/examples/spark2/target/carbonFile/"
    +
    +    import cc._
    +    // 1. generate data file
    +    cleanTestData(path)
    +    buildTestData(path, 100)
    +    val readPath = path + "Fact/Part0/Segment_null"
    +
    +    println("Running SQL on carbon files directly")
    +    try {
    +      // 2. run queries
    +      // 2.1 read data
    +      sql("drop table if exists t1")
    +      sql(s"""CREATE TABLE t1 USING carbonfile OPTIONS (PATH '$readPath') """)
    +      println("Reading data by SDK:")
    --- End diff --
    
    This print seems not correct


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184656789
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter
    +        .builder()
    +        .withSchema(new Schema(fields))
    +        .outputPath(writerPath)
    +        .isTransactionalTable(true)
    +        .uniqueIdentifier(System.currentTimeMillis)
    +      val writer =
    +        if (persistSchema) {
    --- End diff --
    
    ok,done


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/6030/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    @jackylk Please review it.


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5977/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5126/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184398265
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis)
    +            .buildWriterForCSVInput()
    +        } else {
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis).withBlockSize(2)
    +            .buildWriterForCSVInput()
    +        }
    +      var i = 0
    +      var row = num
    +      while (i < row) {
    +        writer.write(Array[String]("robot" + i, String.valueOf(i), String.valueOf(i.toDouble / 2)))
    +        i += 1
    +      }
    +      writer.close()
    +    } catch {
    +      case ex: Exception => None
    +      case e => None
    +    }
    +  }
    +
    +  def cleanTestData(path: String): Unit = {
    +    FileUtils.deleteDirectory(new File(path))
    +  }
    +
    +  // scalastyle:off
    +  def main(args: Array[String]) {
    +    val cc = ExampleUtils.createCarbonSession("DirectSQLExample")
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +      + "../../../..").getCanonicalPath
    +    System.setProperty("path.target", s"$rootPath/examples/spark2/target")
    +    val path = s"$rootPath/examples/spark2/target/carbonFile/"
    +
    +    import cc._
    +    // 1. generate data file
    +    cleanTestData(path)
    +    buildTestData(path, 100)
    +    val readPath = path + "Fact/Part0/Segment_null"
    +
    +    println("Running SQL on carbon files directly")
    +    try {
    +      // 2. run queries
    +      // 2.1 read data
    +      sql("drop table if exists t1")
    +      sql(s"""CREATE TABLE t1 USING carbonfile OPTIONS (PATH '$readPath') """)
    +      println("Reading data by SDK:")
    +      sql("select count(*) from t1").show();
    +
    +      // 2.1 direct sql
    +      //TODO:  support more than one carbonfile
    +      sql(s"""select * FROM  carbonfile.`$readPath` limit 10""".stripMargin).show()
    +      sql(s"""select count(*) FROM  carbonfile.`$readPath` """.stripMargin).show()
    +    } catch {
    +      case e: Exception => println(e.getMessage)
    --- End diff --
    
    e should be thrown


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    SDV Build Fail , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/5044/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r192343540
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,100 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbon files directly
    + * No need to create table first
    + * TODO: support more than one carbon file
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    --- End diff --
    
    ok, done. and optimize all place in the project


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest sdv please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    It's function implementation.


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184649184
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter
    +        .builder()
    +        .withSchema(new Schema(fields))
    +        .outputPath(writerPath)
    +        .isTransactionalTable(true)
    +        .uniqueIdentifier(System.currentTimeMillis)
    +      val writer =
    +        if (persistSchema) {
    --- End diff --
    
    I mean you can add 
    ```
    if (persistSchema) {
              builder.persistSchemaFile(true)
    }
    ```
    separately


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r192340086
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableUsingSparkCarbonFileFormat.scala ---
    @@ -153,6 +153,34 @@ class TestCreateTableUsingSparkCarbonFileFormat extends QueryTest with BeforeAnd
         cleanTestData()
       }
     
    +  test("Running SQL directly and read carbondata files (sdk Writer Output) using the SparkCarbonFileFormat ") {
    +    buildTestData(false)
    +    assert(new File(filePath).exists())
    +    sql("DROP TABLE IF EXISTS sdkOutputTable")
    +
    +    //data source file format
    +    if (sqlContext.sparkContext.version.startsWith("2.1")) {
    +      //data source file format
    +      sql(s"""CREATE TABLE sdkOutputTable USING carbonfile OPTIONS (PATH '$filePath') """)
    --- End diff --
    
    if this is a key work,  should use 'carbonfile'


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/3906/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5984/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4157/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184577602
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    --- End diff --
    
    ok,done


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4285/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r183261488
  
    --- Diff: integration/spark-common-test/src/test/scala/org/apache/carbondata/spark/testsuite/createTable/TestCreateTableUsingSparkCarbonFileFormat.scala ---
    @@ -153,6 +153,34 @@ class TestCreateTableUsingSparkCarbonFileFormat extends QueryTest with BeforeAnd
         cleanTestData()
       }
     
    +  test("Running SQL directly and read carbondata files (sdk Writer Output) using the SparkCarbonFileFormat ") {
    +    buildTestData(false)
    +    assert(new File(filePath).exists())
    +    sql("DROP TABLE IF EXISTS sdkOutputTable")
    +
    +    //data source file format
    +    if (sqlContext.sparkContext.version.startsWith("2.1")) {
    +      //data source file format
    +      sql(s"""CREATE TABLE sdkOutputTable USING carbonfile OPTIONS (PATH '$filePath') """)
    --- End diff --
    
    Is `carbonfile` a reserved key word?


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/6229/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    @jackylk CI pass, please check it again.


---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184577744
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis)
    +            .buildWriterForCSVInput()
    +        } else {
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis).withBlockSize(2)
    +            .buildWriterForCSVInput()
    +        }
    +      var i = 0
    +      var row = num
    +      while (i < row) {
    +        writer.write(Array[String]("robot" + i, String.valueOf(i), String.valueOf(i.toDouble / 2)))
    +        i += 1
    +      }
    +      writer.close()
    +    } catch {
    +      case ex: Exception => None
    +      case e => None
    +    }
    +  }
    +
    +  def cleanTestData(path: String): Unit = {
    +    FileUtils.deleteDirectory(new File(path))
    +  }
    +
    +  // scalastyle:off
    +  def main(args: Array[String]) {
    +    val cc = ExampleUtils.createCarbonSession("DirectSQLExample")
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +      + "../../../..").getCanonicalPath
    +    System.setProperty("path.target", s"$rootPath/examples/spark2/target")
    +    val path = s"$rootPath/examples/spark2/target/carbonFile/"
    +
    +    import cc._
    +    // 1. generate data file
    +    cleanTestData(path)
    +    buildTestData(path, 100)
    +    val readPath = path + "Fact/Part0/Segment_null"
    +
    +    println("Running SQL on carbon files directly")
    +    try {
    +      // 2. run queries
    +      // 2.1 read data
    +      sql("drop table if exists t1")
    +      sql(s"""CREATE TABLE t1 USING carbonfile OPTIONS (PATH '$readPath') """)
    +      println("Reading data by SDK:")
    --- End diff --
    
    ok, fixed


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4826/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4056/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5338/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184397650
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    --- End diff --
    
    move the common logic out of the if block


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/5000/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/5159/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5457/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4871/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    @chenliang613 rebase this PR, and CI pass, please review it. 


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    retest this please


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5488/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4282/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/5024/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4322/



---

[GitHub] carbondata pull request #2181: [CARBONDATA-2355] Support run SQL on carbonda...

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

    https://github.com/apache/carbondata/pull/2181#discussion_r184578212
  
    --- Diff: examples/spark2/src/main/scala/org/apache/carbondata/examples/DirectSQLExample.scala ---
    @@ -0,0 +1,114 @@
    +/*
    + * 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.examples
    +
    +import java.io.File
    +
    +import org.apache.commons.io.FileUtils
    +
    +import org.apache.carbondata.core.metadata.datatype.DataTypes
    +import org.apache.carbondata.examples.util.ExampleUtils
    +import org.apache.carbondata.sdk.file.{CarbonWriter, Field, Schema}
    +
    +/**
    + * Running SQL on carbondata files directly
    + */
    +object DirectSQLExample {
    +
    +  // prepare SDK writer output
    +  def buildTestData(
    +      path: String,
    +      num: Int = 3,
    +      persistSchema: Boolean = false): Any = {
    +
    +    // getCanonicalPath gives path with \, so code expects /. Need to handle in code ?
    +    val writerPath = path.replace("\\", "/");
    +
    +    val fields: Array[Field] = new Array[Field](3)
    +    fields(0) = new Field("name", DataTypes.STRING)
    +    fields(1) = new Field("age", DataTypes.INT)
    +    fields(2) = new Field("height", DataTypes.DOUBLE)
    +
    +    try {
    +      val builder = CarbonWriter.builder()
    +      val writer =
    +        if (persistSchema) {
    +          builder.persistSchemaFile(true)
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis)
    +            .buildWriterForCSVInput()
    +        } else {
    +          builder.withSchema(new Schema(fields)).outputPath(writerPath).isTransactionalTable(true)
    +            .uniqueIdentifier(
    +              System.currentTimeMillis).withBlockSize(2)
    +            .buildWriterForCSVInput()
    +        }
    +      var i = 0
    +      var row = num
    +      while (i < row) {
    +        writer.write(Array[String]("robot" + i, String.valueOf(i), String.valueOf(i.toDouble / 2)))
    +        i += 1
    +      }
    +      writer.close()
    +    } catch {
    +      case ex: Exception => None
    +      case e => None
    +    }
    +  }
    +
    +  def cleanTestData(path: String): Unit = {
    +    FileUtils.deleteDirectory(new File(path))
    +  }
    +
    +  // scalastyle:off
    +  def main(args: Array[String]) {
    +    val cc = ExampleUtils.createCarbonSession("DirectSQLExample")
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +      + "../../../..").getCanonicalPath
    +    System.setProperty("path.target", s"$rootPath/examples/spark2/target")
    +    val path = s"$rootPath/examples/spark2/target/carbonFile/"
    +
    +    import cc._
    +    // 1. generate data file
    +    cleanTestData(path)
    +    buildTestData(path, 100)
    +    val readPath = path + "Fact/Part0/Segment_null"
    +
    +    println("Running SQL on carbon files directly")
    +    try {
    +      // 2. run queries
    +      // 2.1 read data
    +      sql("drop table if exists t1")
    +      sql(s"""CREATE TABLE t1 USING carbonfile OPTIONS (PATH '$readPath') """)
    +      println("Reading data by SDK:")
    +      sql("select count(*) from t1").show();
    +
    +      // 2.1 direct sql
    +      //TODO:  support more than one carbonfile
    +      sql(s"""select * FROM  carbonfile.`$readPath` limit 10""".stripMargin).show()
    +      sql(s"""select count(*) FROM  carbonfile.`$readPath` """.stripMargin).show()
    +    } catch {
    +      case e: Exception => println(e.getMessage)
    --- End diff --
    
    ok, done


---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed  with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5244/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4304/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by ravipesala <gi...@git.apache.org>.
Github user ravipesala commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    SDV Build Success , Please check CI http://144.76.159.231:8080/job/ApacheSDVTests/5201/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5258/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Success with Spark 2.1.0, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder1/5358/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by CarbonDataQA <gi...@git.apache.org>.
Github user CarbonDataQA commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    Build Failed with Spark 2.2.1, Please check CI http://88.99.58.216:8080/job/ApacheCarbonPRBuilder/4292/



---

[GitHub] carbondata issue #2181: [CARBONDATA-2355] Support run SQL on carbondata file...

Posted by xubo245 <gi...@git.apache.org>.
Github user xubo245 commented on the issue:

    https://github.com/apache/carbondata/pull/2181
  
    @jackylk  Please review it


---