iceberg连接
beeline -u jdbc:hive2://IP:10000 -n hdfs
--SET iceberg.engine.hive.enabled=true;
SET spark.sql.catalog.spark_iceberg_hive=org.apache.iceberg.spark.SparkCatalog;
SET spark.sql.catalog.spark_iceberg_hive.type=hive;
SET spark.sql.catalog.spark_iceberg_hive.uri=thrift://IP:8080,thrift://IP:8080;
use spark_iceberg_hive;
SET spark.sql.catalog.spark_iceberg_hadoop=org.apache.iceberg.spark.SparkCatalog;
SET spark.sql.catalog.spark_iceberg_hadoop.type=hadoop;
SET spark.sql.catalog.spark_iceberg_hadoop.warehouse=hdfs://clusterHA/user/hive/iceberg_hadoop;
use spark_iceberg_hadoop;
表创建
创建表
create table T (
id int not null comment '主键id',
name string, age int, m decimal(12,5))
using iceberg comment '测试表2';
创建表
create table T(id int)
using iceberg
stored by 'org.apache.iceberg.mr.hive.HiveIcebergStorageHandler';
创建分区表
create table T (
id int comment '主键id',
name string,
age int,
regist_ts timestamp)
using iceberg partitioned by (bucket(16, id), days(regist_ts), name)
comment '表注释'
tblproperties ('current-snapshot-id' = 'none','format' = 'iceberg/parquet','format-version' = '1');
显示表结构
desc formatted T;
表编辑
alter table T rename to T2;
alter table T set tblproperties('comment'='表注释2');
alter table T set tblproperties('format-version'='2');
alter table T unset tblproperties('format','format-version');
alter table T drop partition field bucket(16, id);
alter table T drop partition field id;
alter table T add partition field bucket(16,id2);
alter table T add partition field id3;
alter table T replace partition field days(regist_ts) with days(ts);
alter table T add column id bigint after id2 comment '注释';
alter table T drop column id;
alter table T alter column id type long comment '字段注释id';
alter table T alter column id comment '注释';
alter table T alter column id first;
alter table T alter column id after id2;
alter table T alter column id set not null;
alter table T alter column id drop not null;
表索引
create index idx1 on T(id);