【发布时间】:2019-06-22 03:38:47
【问题描述】:
我在 hbase 上有 hive 外部表。我在 parquet 上的 hive 表中看到我们需要刷新表以获取可用的最新数据。我们是否也需要在 hbase 上的 hive 中进行相同的操作?
【问题讨论】:
标签: apache-spark hive apache-spark-sql hbase apache-spark-dataset
我在 hbase 上有 hive 外部表。我在 parquet 上的 hive 表中看到我们需要刷新表以获取可用的最新数据。我们是否也需要在 hbase 上的 hive 中进行相同的操作?
【问题讨论】:
标签: apache-spark hive apache-spark-sql hbase apache-spark-dataset
验证相同,我们不需要为具有底层 hbase 表的外部 hive 表调用 REFRESH TABLE
HBASE
create 'ns_schema:table3', 'col_fam1'
put 'ns_schema:table3', 'row1', 'col_fam1:c11', 'first record'
HIVE 外部表
create external table ns_schema.table3(
key string,
col1 string
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties (
"hbase.columns.mapping" = "ns_schema:key,col_fam1:c11"
) tblproperties(
"hbase.table.name" = "ns_schema:table3"
);
SPARK2 外壳
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
val spark2=SparkSession.builder().master("local").enableHiveSupport().getOrCreate()
import sqlContext.implicits._
spark2.sql("select * from ns_schema.table3").show(false)
+----+------------+
|key |col1 |
+----+------------+
|row1|first record|
+----+------------+
现在在 HBASE Shell 中再添加一行
put 'ns_gwm_idr_rz:table3', 'row2', 'col_fam1:c11', 'second record'
查询 SPARK2 shell
spark2.sql("select * from db_gwm_idr_rz.table3").show(false)
+----+-------------+
|key |col1 |
+----+-------------+
|row1|first record |
|row2|second record|
+----+-------------+
【讨论】: