hbase刷新表上的配置单元

rkttyhzu  于 2021-06-09  发布在  Hbase
关注(0)|答案(1)|浏览(372)

我在hbase上有配置单元外部表。我在parquet上的配置单元表中看到,我们需要刷新表以获取可用的最新数据。我们是否也需要在hbase上使用相同的配置单元?

jm81lzqq

jm81lzqq1#

验证了相同的,我们不需要调用刷新表为外部配置单元表与基础hbase表
数据库

create 'ns_schema:table3', 'col_fam1'

put  'ns_schema:table3', 'row1', 'col_fam1:c11', 'first record'

配置单元外部表

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|
+----+-------------+

相关问题