【发布时间】:2018-10-24 18:02:07
【问题描述】:
我在 hbase 中有一个包含 2 个列族 (cf1,cf2) 的表(测试),现在我想从 spark shell 向 hbase 中的现有表添加一个列族。我尝试使用以下语句,但它说该表已经存在
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.{HBaseAdmin,HTable,Put,Get}
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.{HBaseConfiguration, HTableDescriptor}
import org.apache.hadoop.hbase.client.HBaseAdmin
import org.apache.hadoop.hbase.mapreduce.TableInputFormat
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HColumnDescriptor
import org.apache.hadoop.hbase.util.Bytes
import org.apache.hadoop.hbase.client.Put
import org.apache.hadoop.hbase.client.HTable
val conf = HBaseConfiguration.create()
val admin = new HBaseAdmin(conf)
conf.set("hbase.rootdir","hdfs://")
conf.set("hbase.zookeeper.quorum","")
conf.setInt("hbase.zookeeper.property.clientPort", )
val tableName = "test"
val tableDesc = new HTableDescriptor(tableName)
tableDesc.addFamily(new HColumnDescriptor("cf3"))
admin.createTable(tableDesc)
有没有办法使用 scala 从 spark shell 向 hbase 中的现有测试表添加列族(cf3)?
提前致谢。
【问题讨论】:
标签: scala apache-spark hbase