Last active
January 18, 2017 09:18
-
-
Save chetkhatri/954451b630ee4fcbc4df2c33f3dc78fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/spark-shell --driver-class-path /home/chetan/Documents/hortonworks-shc/shc/core/target/s-1.0.2-2.0-s_2.11-SNAPSHOT.jar | |
import org.apache.spark.sql.{SQLContext, _} | |
import org.apache.spark.sql.execution.datasources.hbase._ | |
import org.apache.spark.{SparkConf, SparkContext} | |
val sqlContext = new org.apache.spark.sql.SQLContext(sc) | |
import sqlContext.implicits._ | |
def catalog =s"""{ | |
| |"table":{"namespace":"default", "name":"shcExampleTable"}, | |
| |"rowkey":"key", | |
| |"columns":{ | |
| |"col0":{"cf":"rowkey", "col":"key", "type":"string"}, | |
| |"col1":{"cf":"cf1", "col":"col1", "type":"int"}, | |
| |"col2":{"cf":"cf2", "col":"col2", "type":"string"} | |
| |} | |
| |}""".stripMargin | |
case class HBaseRecord(col0: String, col1: Int, col2: String) | |
val data = (0 to 1).map(i => (i.toString, i+1, "Hello")) | |
var HIVE_WAREHOUSE: String = null | |
HIVE_WAREHOUSE = "/usr/local/hive/warehouse" | |
val spark = SparkSession.builder().appName("Spark Hive Example").config("spark.sql.warehouse.dir", HIVE_WAREHOUSE).enableHiveSupport().getOrCreate() | |
import spark.implicits._ | |
import spark.sql | |
sc.parallelize(data).toDF.write.options(Map(HBaseTableCatalog.tableCatalog -> catalog, HBaseTableCatalog.newTable -> "2")).format("org.apache.spark.sql.execution.datasources.hbase").save() | |
// Error | |
scala> sc.parallelize(data).toDF.write.options(Map(HBaseTableCatalog.tableCatalog -> catalog, HBaseTableCatalog.newTable -> "2")).format("org.apache.spark.sql.execution.datasources.hbase").save() | |
java.lang.NoClassDefFoundError: org/apache/hadoop/hbase/HBaseConfiguration | |
at org.apache.spark.sql.execution.datasources.hbase.HBaseRelation.<init>(HBaseRelation.scala:87) | |
at org.apache.spark.sql.execution.datasources.hbase.DefaultSource.createRelation(HBaseRelation.scala:57) | |
at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:457) | |
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:211) | |
... 56 elided | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment