HBASE-21038 SAXParseException when hbase.spark.use.hbasecontext=false (Ajith S)
This commit is contained in:
parent
953e5aa88c
commit
067fbaa5b5
|
@ -105,7 +105,7 @@ case class HBaseRelation (
|
|||
|
||||
val catalog = HBaseTableCatalog(parameters)
|
||||
def tableName = catalog.name
|
||||
val configResources = parameters.getOrElse(HBaseSparkConf.HBASE_CONFIG_LOCATION, "")
|
||||
val configResources = parameters.get(HBaseSparkConf.HBASE_CONFIG_LOCATION)
|
||||
val useHBaseContext = parameters.get(HBaseSparkConf.USE_HBASECONTEXT).map(_.toBoolean).getOrElse(HBaseSparkConf.DEFAULT_USE_HBASECONTEXT)
|
||||
val usePushDownColumnFilter = parameters.get(HBaseSparkConf.PUSHDOWN_COLUMN_FILTER)
|
||||
.map(_.toBoolean).getOrElse(HBaseSparkConf.DEFAULT_PUSHDOWN_COLUMN_FILTER)
|
||||
|
@ -132,7 +132,7 @@ case class HBaseRelation (
|
|||
LatestHBaseContextCache.latest
|
||||
} else {
|
||||
val config = HBaseConfiguration.create()
|
||||
configResources.split(",").foreach( r => config.addResource(r))
|
||||
configResources.map(resource => resource.split(",").foreach(r => config.addResource(r)))
|
||||
new HBaseContext(sqlContext.sparkContext, config)
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.spark.sql.functions._
|
|||
import org.apache.spark.sql.{DataFrame, SQLContext}
|
||||
import org.apache.spark.{SparkConf, SparkContext}
|
||||
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, FunSuite}
|
||||
import org.xml.sax.SAXParseException
|
||||
|
||||
case class HBaseRecord(
|
||||
col0: String,
|
||||
|
@ -1038,4 +1039,26 @@ BeforeAndAfterEach with BeforeAndAfterAll with Logging {
|
|||
s.show()
|
||||
assert(s.count() == 7)
|
||||
}
|
||||
|
||||
test("test create HBaseRelation with new context throws SAXParseException") {
|
||||
val catalog = s"""{
|
||||
|"table":{"namespace":"default", "name":"t1NotThere"},
|
||||
|"rowkey":"key",
|
||||
|"columns":{
|
||||
|"KEY_FIELD":{"cf":"rowkey", "col":"key", "type":"string"},
|
||||
|"A_FIELD":{"cf":"c", "col":"a", "type":"string"},
|
||||
|"B_FIELD":{"cf":"c", "col":"c", "type":"string"}
|
||||
|}
|
||||
|}""".stripMargin
|
||||
try {
|
||||
HBaseRelation(Map(HBaseTableCatalog.tableCatalog -> catalog,
|
||||
HBaseSparkConf.USE_HBASECONTEXT -> "false"), None)(sqlContext)
|
||||
} catch {
|
||||
case e: Throwable => if(e.getCause.isInstanceOf[SAXParseException]) {
|
||||
fail("SAXParseException due to configuration loading empty resource")
|
||||
} else {
|
||||
println("Failed due to some other exception, ignore " + e.getMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue