
# Spark场景
![](https://support.huaweicloud.com/devg-rule-mrs/public_sys-resources/note_3.0-zh-cn.png)
本章节适用于MRS 3.6.0.1及以后版本。
#### MOR表参数简化
```
create table hudi_mor(业务字段) using hudi options(
type="mor",
primaryKey="主键字段",
hoodie.bucket.index.num.buckets="20"
)
```
MOR表只需要上述3个参数，它会自动补充以下参数去设置preCombineField属性为主键字段（联合主键会取第一个作为preCombineField）、设置索引为BUCKET、设置写入方式为LSM、设置Parquet文件的压缩格式为zstd以及开启Log文件的Log Index，这些能力会提升读写性能和存储优化。**注意MOR表已经默认BUCKET索引，必须手动设置hoodie.bucket.index.num.buckets来指定桶数**。上述建表语句实现的效果等价于：
```
create table hudi_mor(业务字段) using hudi options(
type="mor",
primaryKey="主键字段",
preCombineField="主键字段",
hoodie.index.type="BUCKET",
hoodie.bucket.index.num.buckets="20",
hoodie.lsm.style="true",
hoodie.parquet.compression.codec="zstd",
hoodie.log.index.enable="true",
hoodie.datasource.write.hive_style_partitioning="true"
)
```
#### COW表参数简化
```
create table hudi_cow(业务字段) using hudi options(
primaryKey="主键字段"
)
```
COW表只需要上述1个参数，它自动补充以下参数去设置preCombineField属性为主键字段(联合主键会取第一个作为preCombineField)、设置索引为SIMPLE、设置Parquet文件的压缩格式为zstd。上述建表语句实现的效果等价于：
```
create table hudi_cow(业务字段) using hudi options(
type="cow",
primaryKey="主键字段",
preCombineField="主键字段",
hoodie.index.type="SIMPLE",
hoodie.parquet.compression.codec="zstd"
)
```
#### Bulk Insert（数据纯新增写入，不更新存量）
insert into和insert overwrite只需要在insert语句前set hoodie.datasource.write.operation=bulk_insert即可开启，效果等价于：
```
set hoodie.datasource.write.operation=bulk_insert;
set hoodie.bucket.support.bulk.insert=true;
set hoodie.combine.before.insert=true;
set hoodie.bulkinsert.sort.mode=NONE;
insert into ......
```
#### 表服务托管
如果MRS集群有LDMS服务，MOR表和COW表在建表时可以额外再添加**参数hoodie.managed.by.ldms="true"**，这些表的Compaction/Clean/Archive将由LDMS服务托管。请注意MOR表需要控制写入任务仅产生Compaction计划并关闭Clean和Archive，COW需要写入任务关闭Clean和Archive。
