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

    https://github.com/apache/spark/pull/6627#discussion_r32282458
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala ---
    @@ -0,0 +1,267 @@
    +/*
    + * 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.client
    +
    +import java.lang.{Boolean => JBoolean, Integer => JInteger}
    +import java.lang.reflect.{Method, Modifier}
    +import java.net.URI
    +import java.util.{ArrayList => JArrayList, List => JList, Map => JMap, Set 
=> JSet}
    +
    +import scala.collection.JavaConversions._
    +
    +import org.apache.hadoop.fs.Path
    +import org.apache.hadoop.hive.conf.HiveConf
    +import org.apache.hadoop.hive.ql.Driver
    +import org.apache.hadoop.hive.ql.metadata.{Hive, Partition, Table}
    +import org.apache.hadoop.hive.ql.processors.{CommandProcessor, 
CommandProcessorFactory}
    +import org.apache.hadoop.hive.ql.session.SessionState
    +
    +/**
    + * A shim that defines the interface between ClientWrapper and the 
underlying Hive library used to
    + * talk to the metastore. Each Hive version has its own implementation of 
this class, defining
    + * version-specific version of needed functions.
    + *
    + * The guideline for writing shims is:
    + * - always extend from the previous version unless really not possible
    + * - initialize methods in lazy vals, both for quicker access for multiple 
invocations, and to
    + *   avoid runtime errors due to the above guideline.
    + */
    +private[client] sealed abstract class Shim {
    +
    +  def setCurrentSessionState(state: SessionState): Unit
    +
    +  /**
    +   * This shim is necessary because the return type is different on 
different versions of Hive.
    +   * All parameters are the same, though.
    +   */
    +  def getDataLocation(table: Table): Option[String]
    +
    +  def setDataLocation(table: Table, loc: String): Unit
    +
    +  def getAllPartitions(hive: Hive, table: Table): Seq[Partition]
    +
    +  def getCommandProcessor(token: String, conf: HiveConf): CommandProcessor
    +
    +  def getDriverResults(driver: Driver): Seq[String]
    +
    +  def loadPartition(
    +      hive: Hive,
    +      loadPath: Path,
    +      tableName: String,
    +      partSpec: JMap[String, String],
    +      replace: Boolean,
    +      holdDDLTime: Boolean,
    +      inheritTableSpecs: Boolean,
    +      isSkewedStoreAsSubdir: Boolean): Unit
    +
    +  def loadTable(
    +      hive: Hive,
    +      loadPath: Path,
    +      tableName: String,
    +      replace: Boolean,
    +      holdDDLTime: Boolean): Unit
    +
    +  def loadDynamicPartitions(
    +      hive: Hive,
    +      loadPath: Path,
    +      tableName: String,
    +      partSpec: JMap[String, String],
    +      replace: Boolean,
    +      numDP: Int,
    +      holdDDLTime: Boolean,
    +      listBucketingEnabled: Boolean): Unit
    +
    +  protected def findStaticMethod(klass: Class[_], name: String, args: 
Class[_]*): Method = {
    +    val method = findMethod(klass, name, args: _*)
    +    require(Modifier.isStatic(method.getModifiers()),
    +      s"Method $name of class $klass is not static.")
    +    method
    +  }
    +
    +  protected def findMethod(klass: Class[_], name: String, args: 
Class[_]*): Method = {
    +    klass.getMethod(name, args: _*)
    +  }
    +
    +}
    +
    +private[client] class Shim_v0_12 extends Shim {
    +
    +  private lazy val startMethod = findStaticMethod(classOf[SessionState], 
"start",
    --- End diff --
    
    Yes, because otherwise you can't have the shim for the next version extend 
this one. I mention this in the scaladoc for the `Shim` class.


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