You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@carbondata.apache.org by jackylk <gi...@git.apache.org> on 2016/09/05 16:40:39 UTC

[GitHub] incubator-carbondata pull request #126: [CARBONDATA-212] Use SQLContext to r...

GitHub user jackylk opened a pull request:

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

    [CARBONDATA-212] Use SQLContext to read CarbonData files

    In this PR, user can use SQLContext instead of CarbonContext to read CarbonData files.
    See DatasourceExample.scala

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

    $ git pull https://github.com/jackylk/incubator-carbondata ds1

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

    https://github.com/apache/incubator-carbondata/pull/126.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 #126
    
----
commit 9293e1b5c0c6c14b5f3d8f7aec89a812d785a452
Author: jackylk <ja...@huawei.com>
Date:   2016-09-05T15:36:04Z

    use SqlContext for read

commit f0f7a4a2f0144dc1088ba2e8c6d4a606dc50a36a
Author: jackylk <ja...@huawei.com>
Date:   2016-09-05T15:43:30Z

    revert CarbonScan

commit cc6c749115c35effed493d9064d982438c11cb59
Author: jackylk <ja...@huawei.com>
Date:   2016-09-05T15:45:33Z

    add class

commit c53b2ef268b487f602350d4c93bc3cdda70e8c39
Author: jackylk <ja...@huawei.com>
Date:   2016-09-05T16:36:13Z

    fix stylecheck

----


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

[GitHub] incubator-carbondata pull request #126: [CARBONDATA-212] Use SQLContext to r...

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

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


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

[GitHub] incubator-carbondata pull request #126: [CARBONDATA-212] Use SQLContext to r...

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

    https://github.com/apache/incubator-carbondata/pull/126#discussion_r77605228
  
    --- Diff: integration/spark/src/main/scala/org/apache/spark/sql/CarbonDatasourceRelation.scala ---
    @@ -123,24 +120,24 @@ class CarbonSource
           dataSchema: Option[StructType],
           partitionColumns: Option[StructType],
           parameters: Map[String, String]): HadoopFsRelation = {
    -    CarbonDatasourceHadoopRelation(sqlContext, paths, parameters)
    +    CarbonDatasourceHadoopRelation(sqlContext, paths, parameters, dataSchema)
    --- End diff --
    
    You can validate the parameters here.


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

[GitHub] incubator-carbondata pull request #126: [CARBONDATA-212] Use SQLContext to r...

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

    https://github.com/apache/incubator-carbondata/pull/126#discussion_r77598344
  
    --- Diff: examples/src/main/scala/org/apache/carbondata/examples/DatasourceExample.scala ---
    @@ -0,0 +1,55 @@
    +/*
    + * 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 org.apache.spark.sql.{SaveMode, SQLContext}
    +
    +import org.apache.carbondata.examples.util.InitForExamples
    +
    +object DatasourceExample {
    +
    +  def main(args: Array[String]) {
    +    // use CarbonContext to write CarbonData files
    +    val cc = InitForExamples.createCarbonContext("DatasourceExample")
    +    import cc.implicits._
    +    val sc = cc.sparkContext
    +    // create a dataframe, it can be from parquet or hive table
    +    val df = sc.parallelize(1 to 1000)
    +               .map(x => ("a", "b", x))
    +               .toDF("c1", "c2", "c3")
    +
    +    // save dataframe to CarbonData files
    +    df.write
    +      .format("carbondata")
    +      .option("tableName", "carbon1")
    +      .mode(SaveMode.Overwrite)
    +      .save()
    +
    +    // use SQLContext to read CarbonData files
    +    val sqlContext = new SQLContext(sc)
    +    sqlContext.sql(
    +      """
    +        | CREATE TEMPORARY TABLE source
    +        | (c1 string, c2 string, c3 long)
    +        | USING org.apache.spark.sql.CarbonSource
    +        | OPTIONS (path './examples/target/store',
    --- End diff --
    
    please change path to './target/store'


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