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

    https://github.com/apache/carbondata/pull/1193#discussion_r129566524
  
    --- Diff: 
examples/spark2/src/main/scala/org/apache/carbondata/examples/CarbonSortColumnsExample.scala
 ---
    @@ -0,0 +1,126 @@
    +/*
    + * 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.core.constants.CarbonCommonConstants
    +import org.apache.carbondata.core.util.CarbonProperties
    +
    +object CarbonSortColumnsExample {
    +
    +  def main(args: Array[String]) {
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +                            + "../../../..").getCanonicalPath
    +    val storeLocation = s"$rootPath/examples/spark2/target/store"
    +    val warehouse = s"$rootPath/examples/spark2/target/warehouse"
    +    val metastoredb = s"$rootPath/examples/spark2/target"
    +
    +    CarbonProperties.getInstance()
    +      .addProperty(CarbonCommonConstants.CARBON_TIMESTAMP_FORMAT, 
"yyyy/MM/dd HH:mm:ss")
    +      .addProperty(CarbonCommonConstants.CARBON_DATE_FORMAT, "yyyy/MM/dd")
    +      
.addProperty(CarbonCommonConstants.ENABLE_UNSAFE_COLUMN_PAGE_LOADING, "true")
    +
    +    import org.apache.spark.sql.CarbonSession._
    +    val spark = SparkSession
    +      .builder()
    +      .master("local")
    +      .appName("CarbonSortColumnsExample")
    +      .config("spark.sql.warehouse.dir", warehouse)
    +      .config("spark.driver.host", "localhost")
    +      .getOrCreateCarbonSession(storeLocation, metastoredb)
    +
    +    spark.sparkContext.setLogLevel("WARN")
    +
    +    spark.sql("DROP TABLE IF EXISTS sort_columns_table")
    +
    +    // Create table with no sort columns
    +    spark.sql(
    +      s"""
    +         | CREATE TABLE no_sort_columns_table(
    +         | shortField SHORT,
    +         | intField INT,
    +         | bigintField LONG,
    +         | doubleField DOUBLE,
    +         | stringField STRING,
    +         | timestampField TIMESTAMP,
    +         | decimalField DECIMAL(18,2),
    +         | dateField DATE,
    +         | charField CHAR(5),
    +         | floatField FLOAT,
    +         | complexData ARRAY<STRING>
    +         | )
    +         | STORED BY 'carbondata'
    +         | TBLPROPERTIES('SORT_COLUMNS'='')
    +       """.stripMargin)
    +
    +    // Create table with sort columns
    +    spark.sql(
    +      s"""
    +         | CREATE TABLE sort_columns_table(
    +         | shortField SHORT,
    +         | intField INT,
    +         | bigintField LONG,
    +         | doubleField DOUBLE,
    +         | stringField STRING,
    +         | timestampField TIMESTAMP,
    +         | decimalField DECIMAL(18,2),
    +         | dateField DATE,
    +         | charField CHAR(5),
    +         | floatField FLOAT,
    +         | complexData ARRAY<STRING>
    +         | )
    +         | STORED BY 'carbondata'
    +         | TBLPROPERTIES('SORT_COLUMNS'='intField, stringField, charField')
    +       """.stripMargin)
    +
    +    val path = s"$rootPath/examples/spark2/src/main/resources/data.csv"
    +
    +    // scalastyle:off
    +    spark.sql(
    +      s"""
    +         | LOAD DATA LOCAL INPATH '$path'
    +         | INTO TABLE no_sort_columns_table
    +         | 
OPTIONS('FILEHEADER'='shortField,intField,bigintField,doubleField,stringField,timestampField,decimalField,dateField,charField,floatField,complexData',
    +         | 'COMPLEX_DELIMITER_LEVEL_1'='#')
    --- End diff --
    
    added comments in line 74 and line 75


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to