Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-18570

use hbase-spark without HBaseContext runs into NPE

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Minor
    • Resolution: Unresolved
    • 1.2.0
    • None
    • None
    • None

    Description

      I recently run into the same issue as described in stackoverflow :

      https://stackoverflow.com/questions/38865558/sparksql-dataframes-does-not-work-in-spark-shell-and-application#

      If we don't explicitly initialize a HBaseContext and don't set hbase.use.hbase.context option to false, it will run into NPE at:

          val wrappedConf = new SerializableConfiguration(hbaseContext.config)
      

      https://github.com/apache/hbase/blob/master/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/DefaultSource.scala#L140

      Should we safe guard with a NULL validation on hbaseContext?

      Something like:

          //create or get latest HBaseContext
        val hbaseContext:HBaseContext = if (useHBaseContext && null != LatestHBaseContextCache.latest) {
          LatestHBaseContextCache.latest
        } else {
          val config = HBaseConfiguration.create()
          configResources.split(",").foreach( r => config.addResource(r))
          new HBaseContext(sqlContext.sparkContext, config)
        }
      

      Or maybe it's better to make sure the HBaseContext is instantiated properly.

      Attachments

        Issue Links

          Activity

            People

              junegunn Junegunn Choi
              yxzhang Yuexin Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: