本文整理汇总了Scala中org.apache.spark.sql.execution.QueryExecutionException类的典型用法代码示例。如果您正苦于以下问题:Scala QueryExecutionException类的具体用法?Scala QueryExecutionException怎么用?Scala QueryExecutionException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QueryExecutionException类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: forceUseDatabaseExists
//设置package包名称以及导入依赖的类
package com.gmail.katezer.bigdata.jobs
import com.gmail.katezer.bigdata.utils.HasLogger
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException
import org.apache.hadoop.hive.ql.metadata.HiveException
import org.apache.spark.sql.execution.QueryExecutionException
import org.apache.spark.sql.hive.HiveContext
import org.apache.spark.{SparkConf, SparkContext}
import scala.reflect.ClassTag
def forceUseDatabaseExists(hc: HiveContext, dbName: String): Unit = {
try {
hc.sql("USE " + dbName)
} catch {
case e @ (_ : QueryExecutionException | _ : HiveException | _ : NoSuchObjectException) =>
info("Creating database: " + dbName)
hc.sql("CREATE DATABASE IF NOT EXISTS " + dbName)
case e: Exception =>
error("Exception not expected!")
throw e
} finally {
hc.sql("USE " + dbName)
}
}
}
示例2: MultipleUtils
//设置package包名称以及导入依赖的类
package com.gmail.katezer.bigdata.utils
import org.apache.hadoop.hive.metastore.api.NoSuchObjectException
import org.apache.hadoop.hive.ql.metadata.HiveException
import org.apache.spark.sql.execution.QueryExecutionException
import org.apache.spark.sql.hive.HiveContext
object MultipleUtils {
def getFirstArg(args: Array[String]): String = args.isEmpty match {
case true => throw new IllegalArgumentException("First argument on launching the job is required and must be the date of the file in YYYYMMDD format")
case false => args.head
}
def getSecondArg(args: Array[String]): Boolean = args.isEmpty match {
case true => throw new IllegalArgumentException("First argument on launching the job is required and must be the date of the file in YYYYMMDD format")
case false =>
args.tail.isEmpty match {
case true => false
case false => args.tail.head match {
case "local" => true
case _ => false
}
}
}
def executeAndIgnoreHiveError(hc: HiveContext, query: String): Unit = {
try {
hc.sql(query)
} catch {
case _ : QueryExecutionException | _ : HiveException | _: NoSuchObjectException => // expected, do nothing
case e: Exception => throw e
}
}
}