Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Spark Read/Write Hudi Development Specifications

Updated on 2024-08-30 GMT+08:00

Specifications of the parameters in various write modes for the Spark write Hudi

Type

Description

Enable parameter

Scenario Selection

Features

upsert

update + insert

Hudi default write type, which has the update capability.

This parameter is set by default and does not need to be set to Enabled.

  • SparkSQL:
    set hoodie.datasource.write.operation=upsert;
  • DataSource Api:
    df.write
    .format("hudi")
    .options(xxx)
    .option("hoodie.datasource.write.operation", "upsert")
    .mode("append")
    .save("/tmp/tablePath")

The default value is selected.

Pros:

  • Small files can be merged.
  • Updates are supported.

Disadvantages:

  • Write speed go by the rules to the letter.

append

Directly write data without updates

  • Spark: Spark does not have the pure append mode. You can use the bulk insert mode instead.
  • SparkSQL:
    set hoodie.datasource.write.operation = bulk_insert;
    set hoodie.datasource.write.row.writer.enable = true;
  • DataSource Api:
    df.write
    .format("hudi")
    .options(xxx)
    .option("hoodie.datasource.write.operation", "bulk_insert")
    .option("hoodie.datasource.write.row.writer.enable", "true")
    .mode("append")
    .save("/tmp/tablePath")

High throughput and no data update scenario.

Pros:

  • Fastest write speed.

Disadvantages:

  • Small files cannot be merged.
  • No update capability.
  • Clustering is required to merge small files.

delete

Delete operation

No parameter is required. You can directly use the delete syntax.

delete from tableName where primaryKey='id1';

The SQL statement deletes data.

Same as the upsert type.

Insert overwrite

Override partition

No parameter is required. Use the insert overwrite syntax directly.

insert overwrite table tableName partition (dt = '2021-01-04')
select * from srcTable;

Partition level again.

Overwrite the partition.

Insert overwrite table

Override the entire table

No parameter is required. Use the insert overwrite syntax directly.

insert overwrite table tableName
select * from srcTable;

Rewrite it all.

Overwrite the entire table.

Bulk_insert

Batch Import

  • SparkSQL:
    set hoodie.datasource.write.operation = bulk_insert;
    set hoodie.datasource.write.row.writer.enable = true;
  • DataSource Api:
    df.write
    .format("hudi")
    .options(xxx)
    .option("hoodie.datasource.write.operation", "bulk_insert")
    .option("hoodie.datasource.write.row.writer.enable", "true")
    .mode("append")
    .save("/tmp/tablePath")

You are advised to use this tool during table initialization and migration.

The mode is the same as the append mode.

Specifications for Spark to read Hudi parameters in incremental mode

Type

Description

Enable parameter

Scenario Selection

Features

snapshot

Real-time data reading.

Default value. No parameter is required to enable this function.

SparkSQL:

set hoodie.datasource.query.type=snapshot;

DataSource Api:

val df = spark.read
.format("hudi")
.option("hoodie.datasource.query.type", "snapshot")
.load("tablePath")

Default selection

Each read data is the latest, and the data is visible immediately after being written.

incremental

Incremental query. Only the data between two commit operations is queried.

  • SparkSQL:
    set hoodie.tableName.consume.mode=INCREMENTAL;// The current table must be read in incremental mode.
    set hoodie.tableName.consume.start.timestamp=20201227153030;// Specify the initial incremental pull. commit
    set hoodie.tableName.consume.end.timestamp=20210308212318; // specifies the end of the incremental pull. If the end of the commit operation is not specified, the latest commit operation is used.
    select * from tableName where `_hoodie_commit_time`>' 20201227153030'and `_hoodie_commit_time`<=' 20210308212318'; //The results must be filtered by start.timestamp and end.timestamp. If end.timestamp is not specified, the results are filtered by start.timestamp.
    set hoodie.tableName.consume.mode=SNAPSHOT; // After using the incremental mode, the query mode must be reset.
  • DataSource Api:
    val df = spark.read
    .format("hudi")
    .option("hoodie.tableName.consume.mode", "INCREMENTAL")
    .option("hoodie.tableName.consume.start.timestamp", "20201227153030")
    .option("hoodie.tableName.consume.end.timestamp", "20210308212318")
    .load("tablePath")
    .where ("`_hoodie_commit_time`>' 20201227153030' and `_hoodie_commit_time`<=' 20210308212318 '")

In the streaming processing scenario, only incremental data is obtained each time.

Reads only the data between two commit operations. It is not a full table scan, which is much more efficient than obtaining the data before the commit operation by using the where condition.

read_optimized

Read-optimized view.

Only the data in the parquet file in the table is read. For the mor table, new data is written to the log. Therefore, the data read in this mode is not the latest.

  • SparkSQL:

    When the Mor table is synchronized to Hive, three tables are generated: primary table, ro table, and rt table. The ro table is the read optimization table. You can directly read the ro table.

    select * from tableName_ro;
  • DataSource Api:
    val df = spark.read
    .format("hudi")
    .option("hoodie.datasource.query.type", "read_optimized")
    .load("tablePath")

The query performance is required, but the data delay is acceptable.

For the mor table, the performance of this read mode is much faster than that of the real-time table. In this mode, log data is not read and can be read only after data is compacted. Therefore, data reading in this mode has a certain data latency.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback