MAPREDUCE服务 MRS-配置Hudi数据列默认值:示例

时间:2024-07-02 16:39:36

示例

SQL语法具体参考Hudi SQL语法参考章节。

示例:

  • 建表指定列默认值
    create table if not exists h3(
    id bigint,
    name string,
    price double default 12.34
    ) using hudi
    options (
    primaryKey = 'id',
    type = 'mor',
    preCombineField = 'name'
    );
  • 添加列指定列默认值
    alter table h3 add columns(col1 string default 'col1_value');
    alter table h3 add columns(col2 string default 'col2_value', col3 int default 1);
  • 修改列默认值
    alter table h3 alter column price set default 14.56;
  • 插入数据使用列默认值
    insert into h3(id, name) values(1, 'aaa');
    insert into h3(id, name, price) select 2, 'bbb', 12.5;
support.huaweicloud.com/cmpntguide-lts-mrs/mrs_01_248942.html