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

    https://github.com/apache/spark/pull/2241#discussion_r18429781
  
    --- Diff: 
sql/hive/v0.13.1/src/main/scala/org/apache/spark/sql/hive/Shim.scala ---
    @@ -0,0 +1,158 @@
    +/*
    + * 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.spark.sql.hive
    +
    +import java.util.Properties
    +import org.apache.hadoop.conf.Configuration
    +import org.apache.hadoop.fs.Path
    +import org.apache.hadoop.hive.common.StatsSetupConst
    +import org.apache.hadoop.hive.common.`type`.{HiveDecimal}
    +import org.apache.hadoop.hive.conf.HiveConf
    +import org.apache.hadoop.hive.ql.Context
    +import org.apache.hadoop.hive.ql.metadata.{Table, Hive, Partition}
    +import org.apache.hadoop.hive.ql.plan.{FileSinkDesc, TableDesc}
    +import org.apache.hadoop.hive.ql.processors.CommandProcessorFactory
    +import org.apache.hadoop.hive.serde2.{ColumnProjectionUtils, Deserializer}
    +import org.apache.hadoop.mapred.InputFormat
    +import org.apache.spark.Logging
    +import org.apache.hadoop.{io => hadoopIo}
    +import scala.collection.JavaConversions._
    +import scala.language.implicitConversions
    +
    +/**
    + * A compatibility layer for interacting with Hive version 0.13.1.
    + */
    +private[hive] object HiveShim {
    +  val version = "0.13.1"
    +  /*
    +   * TODO: hive-0.13 support DECIMAL(precision, scale), DECIMAL in 
hive-0.12 is actually DECIMAL(10,0)
    +   * Full support of new decimal feature need to be fixed in seperate PR.
    +   */
    +  val metastoreDecimal = "decimal(10,0)"
    +
    +  def getTableDesc(
    +    serdeClass: Class[_ <: Deserializer],
    +    inputFormatClass: Class[_ <: InputFormat[_, _]],
    +    outputFormatClass: Class[_],
    +    properties: Properties) = {
    +    new TableDesc(inputFormatClass, outputFormatClass, properties)
    +  }
    +
    +  def getStatsSetupConstTotalSize = StatsSetupConst.TOTAL_SIZE
    +
    +  def createDefaultDBIfNeeded(context: HiveContext) ={
    +    context.runSqlHive("CREATE DATABASE default")
    +    context.runSqlHive("USE default")
    +  }
    +
    +  /** The string used to denote an empty comments field in the schema. */
    +  def getEmptyCommentsFieldValue = ""
    +
    +  def getCommandProcessor(cmd: Array[String], conf: HiveConf) =  {
    +    CommandProcessorFactory.get(cmd, conf)
    +  }
    +
    +  def createDecimal(bd: java.math.BigDecimal): HiveDecimal = {
    +    HiveDecimal.create(bd)
    +  }
    +
    +  /*
    +   * This function in hive-0.13 become private, but we have to do this to 
walkaround hive bug
    +   */
    +  private def appendReadColumnNames(conf: Configuration, cols: 
Seq[String]) {
    +    val old: String = 
conf.get(ColumnProjectionUtils.READ_COLUMN_NAMES_CONF_STR, "")
    +    val result: StringBuilder = new StringBuilder(old)
    +    var first: Boolean = old.isEmpty
    +
    +    for (col <- cols) {
    +      if (first) {
    +        first = false
    +      }
    +      else {
    --- End diff --
    
    ```
    if () {
      ...
    } else {
      ...
    }
    ```


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to