carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anubhav100 <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #751: [CARBONDATA-816] Added Example for H...
Date Sun, 09 Apr 2017 16:49:01 GMT
Github user anubhav100 commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/751#discussion_r110546718
  
    --- Diff: integration/hive/src/main/scala/org/apache/carbondata/hiveexample/HiveExample.scala
---
    @@ -0,0 +1,166 @@
    +/*
    + * 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.hiveexample
    +
    +import java.io.File
    +import java.sql.{DriverManager, ResultSet, SQLException, Statement}
    +
    +import org.apache.spark.sql.SparkSession
    +
    +import org.apache.carbondata.common.logging.LogServiceFactory
    +import org.apache.carbondata.hive.server.HiveEmbeddedServer2
    +
    +object HiveExample {
    +
    +  private val driverName: String = "org.apache.hive.jdbc.HiveDriver"
    +
    +  /**
    +   * @param args
    +   * @throws SQLException
    +   */
    +  @throws[SQLException]
    +  def main(args: Array[String]) {
    +    val rootPath = new File(this.getClass.getResource("/").getPath
    +                            + "../../../..").getCanonicalPath
    +    val store = s"$rootPath/integration/hive/target/store"
    +    val warehouse = s"$rootPath/integration/hive/target/warehouse"
    +    val metaStore_Db = s"$rootPath/integration/hive/target/carbon_metaStore_db"
    +    val logger = LogServiceFactory.getLogService(this.getClass.getCanonicalName)
    +
    +    import org.apache.spark.sql.CarbonSession._
    +
    +    System.setProperty("hadoop.home.dir", "/")
    +
    +    val carbon = SparkSession
    +      .builder()
    +      .master("local")
    +      .appName("HiveExample")
    +      .config("carbon.sql.warehouse.dir", warehouse).enableHiveSupport()
    +      .getOrCreateCarbonSession(
    +        store, metaStore_Db)
    +
    +    val carbonJarPath = s"$rootPath/assembly/target/scala-2.11/carbondata_2.11-1.1" +
    +                        s".0-incubating-SNAPSHOT-shade-hadoop2.7.2.jar"
    --- End diff --
    
    @chenliang613  Wildcards are not supported in both hive.aux.jars.path and add jar.
    
    i solved this problem by specifying both version of hadoop
    
    val carbonHadoopJarPath = s"$rootPath/assembly/target/scala-2.11/carbondata_2.11-1.1"
+
                                  ".0-incubating-SNAPSHOT-shade-hadoop2.7.2.jar"
    
        val carbon_DefaultHadoopVersion_JarPath =
          s"$rootPath/assembly/target/scala-2.11/carbondata_2.11-1.1" +
          ".0-incubating-SNAPSHOT-shade-hadoop2.2.0.jar"
    
    first i tried to add jar with 2.7.2 version if it fails then i tried with hadoop 2.2.0
version
    
     try {
          stmt
            .execute(s"ADD JAR $carbonHadoopJarPath")
        }
        catch {
          case exception: Exception =>
            logger.warn(s"Jar Not Found $carbonHadoopJarPath"+"Looking For hadoop 2.2.0 version
jar")
            try {
              stmt
                .execute(s"ADD JAR $carbon_DefaultHadoopVersion_JarPath")
            }
            catch {
              case exception: Exception => logger
                .error(s"Exception Occurs:Neither One of Jar is Found $carbon_DefaultHadoopVersion_JarPath,$carbonHadoopJarPath"+"Atleast
One Should Be Build")
                hiveEmbeddedServer2.stop()
            }
        }


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

Mime
View raw message