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

    https://github.com/apache/carbondata/pull/2614#discussion_r214526743
  
    --- Diff: 
examples/spark2/src/main/scala/org/apache/carbondata/examples/MVDataMapExample.scala
 ---
    @@ -0,0 +1,125 @@
    +/*
    + * 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.spark.sql.SparkSession
    +
    +import org.apache.carbondata.examples.util.ExampleUtils
    +
    +/**
    + * This example is for pre-aggregate tables.
    + */
    +
    +object MVDataMapExample {
    +
    +  def main(args: Array[String]) {
    +    val spark = ExampleUtils.createCarbonSession("MVDataMapExample")
    +    exampleBody(spark)
    +    spark.close()
    +  }
    +
    +  def exampleBody(spark: SparkSession): Unit = {
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +                            + "../../../..").getCanonicalPath
    +    val testData = 
s"$rootPath/integration/spark-common-test/src/test/resources/sample.csv"
    +
    +    // 1. simple usage for Pre-aggregate tables creation and query
    +    spark.sql("DROP TABLE IF EXISTS mainTable")
    +    spark.sql("DROP TABLE IF EXISTS dimtable")
    +    spark.sql(
    +      """
    +        | CREATE TABLE mainTable
    +        | (id Int,
    +        | name String,
    +        | city String,
    +        | age Int)
    +        | STORED BY 'org.apache.carbondata.format'
    +      """.stripMargin)
    +
    +    spark.sql(
    +      """
    +        | CREATE TABLE dimtable
    +        | (name String,
    +        | address String)
    +        | STORED BY 'org.apache.carbondata.format'
    +      """.stripMargin)
    +
    +    spark.sql(s"""LOAD DATA LOCAL INPATH '$testData' into table 
mainTable""")
    +
    +    spark.sql(s"""insert into dimtable select name, concat(city, ' 
street1') as address from
    +           |mainTable group by name, address""".stripMargin)
    --- End diff --
    
    Why need to add "group by name ,address" ?


---

Reply via email to