本文整理汇总了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)
}
}
}
开发者ID:katezer,项目名称:spark-calculation-engine,代码行数:29,代码来源:Job.scala
示例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
}
}
}
开发者ID:katezer,项目名称:spark-calculation-engine,代码行数:38,代码来源:MultipleUtils.scala
注:本文中的org.apache.spark.sql.execution.QueryExecutionException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论