Configuring the Spark Client to Integrate with Hudi, Iceberg, and Paimon
Scenarios
Use the Spark SQL to migrate data from Hudi tables to Iceberg tables once the Spark client is integrated with Hudi, Iceberg, and Paimon.
Prerequisites
- You have downloaded and installed the Hudi client. Currently, Hudi, Iceberg, and Paimon are all integrated in Spark. You only need to download the Spark client on MRS Manager. For example, the client installation directory is /opt/client.
- You have created a user and added the user to user groups hadoop (primary group) and hive on MRS Manager.
Notes and Constraints
- This section applies only to MRS 3.6.0-LTS.1 and later.
- Load data lake table format components in the specific sequence defined in the spark.sql.extensions configuration to avoid syntax conflicts. The sequence is as follows.
Load the Hudi, Iceberg, and Paimon data lake table formats
spark.sql.extensions=org.apache.spark.sql.hive.SparkSessionExtension,org.apache.spark.sql.hudi.HoodieSparkSessionExtension,org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,org.apache.paimon.spark.extensions.PaimonSparkSessionExtensions
- Use the three-part format catalog.database.table to uniquely identify an Iceberg or Paimon table when performing operations on the table using the client.
Using Spark SQL to Connect to Hudi, Iceberg, and Paimon
- Log in to the Spark client node as the client installation user and switch to the client installation directory.
cd Client installation directory
Load the environment variables.
source bigdata_env
Load the component environment variables.
source Spark/component_env source Hudi/component_env
For clusters in security mode, additionally run the following command:
kinit Component service user
Enter the password for authentication. (Change the password upon your first login.)
- Run the following commands to integrate Spark SQL with the Hudi, Iceberg, and Paimon data lake table formats:
spark-sql \ --master yarn \ --jars {Client installation path}/Spark/spark/jars/paimon/{Complete name of the paimon-spark package},{Client installation path}/Spark/spark/jars/paimon/{Complete name of the paimon-hive-connector-common package} \ --driver-class-path {Client installation path}/Spark/spark/jars/paimon/{Complete name of the paimon-spark package}:{Client installation path}/Spark/spark/jars/paimon/{Complete name of the paimon-hive-connector-common package} \ --conf spark.sql.catalog.{paimon_catalog_name}=org.apache.paimon.spark.SparkCatalog \ --conf spark.sql.catalog.{paimon_catalog_name}.warehouse=${HIVE_METASTORE_WAREHOUSE_DIR} \ --conf spark.sql.catalog.{paimon_catalog_name}.metastore=hive \ --conf spark.sql.catalog.{iceberg_catalog_name}=org.apache.iceberg.spark.SparkCatalog \ --conf spark.sql.catalog.{iceberg_catalog_name}.warehouse=${HIVE_METASTORE_WAREHOUSE_DIR} \ --conf spark.sql.catalog.{iceberg_catalog_name}.type=hive \ --conf spark.sql.storeAssignmentPolicy=ANSI \ --conf spark.sql.extensions=org.apache.spark.sql.hive.SparkSessionExtension,org.apache.spark.sql.hudi.HoodieSparkSessionExtension,org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,org.apache.paimon.spark.extensions.PaimonSparkSessionExtensions
- When using Spark to write and Hive to read Paimon data, you must use the TIMESTAMP_NTZ type to ensure cross-engine compatibility. Before creating a table in Spark, set the spark.sql.timestampType parameter to TIMESTAMP_NTZ.
- If Spark needs to read Timestamp fields in Iceberg or Paimon tables written by other engines, set spark.sql.session.timeZone to match the writer engine's time zone. Otherwise, data results may be inconsistent. If the writer engine uses the TIMESTAMP_NTZ type, set spark.sql.timestampType to TIMESTAMP_NTZ.
- When the spark.sql.session.timeZone parameter is configured, you must explicitly specify the data type when writing data to Iceberg tables.
- Note that the separators for --jars and --driver-class-path differ. Use commas (,) for jars and colons (:) for the driver class path.
- To obtain the value of ${HIVE_METASTORE_WAREHOUSE_DIR}, log in to MRS Manager, choose Cluster > Services > Hive, click Configurations and then All Configurations, choose MetaStore(Role), and search for hive.metastore.warehouse.dir.
- To obtain the value of ${HIVE_METASTORE_URI_DEFAULT}, log in to MRS Manager, choose Cluster > Services > Hive, click Configurations and then All Configurations, choose MetaStore(Role), and search for HIVE_METASTORE_URI_DEFAULT.
- Create an Iceberg table with the same data structure as the Hudi table. Example statement:
spark-sql> CREATE TABLE iceberg.default.iceberg_table (id bigint, data string, category string, ts timestamp) USING iceberg PARTITIONED BY (data);
- Migrate data from the Hudi table to the new Iceberg table. Example statement:
spark-sql> insert into iceberg.default.iceberg_table select * from hudi_table;
Using Spark Beeline to Connect to Hudi, Iceberg, and Paimon
- Upload {Client installation path}/Spark/spark/jars/paimon/paimon-spark-3.5*.jar and {Client installation path}/Spark/spark/jars/paimon/paimon-hive-connector-common*.jar on the client to the unified archive path in HDFS or OBS.
- Log in to MRS Manager, choose Cluster > Services > Spark, click Configurations and then All Configurations, choose JDBCServer(Role), add the configuration items listed in Table 1 to custom, modify the configuration items based on Table 2, and restart JDBCServer.
Table 1 Configuration items to be added to custom Parameter
Value
spark.jars
{Unified archive path in HDFS or OBS}/paimon-spark-3.5*.jar,{Unified archive path in HDFS or OBS}/paimon-hive-connector-common*.jar
spark.sql.catalog.{paimon_catalog_name}
org.apache.paimon.spark.SparkCatalog
spark.sql.catalog.{paimon_catalog_name}.warehouse
${HIVE_METASTORE_WAREHOUSE_DIR}
spark.sql.catalog.{paimon_catalog_name}.metastore
hive
spark.sql.catalog.{paimon_catalog_name}.uri
${HIVE_METASTORE_URI_DEFAULT}
spark.sql.catalog.{iceberg_catalog_name}
org.apache.iceberg.spark.SparkCatalog
spark.sql.catalog.{iceberg_catalog_name}.warehouse
${HIVE_METASTORE_WAREHOUSE_DIR}
spark.sql.catalog.{iceberg_catalog_name}.type
hive
spark.sql.catalog.{iceberg_catalog_name}.uri
${HIVE_METASTORE_URI_DEFAULT}
Table 2 Modified configuration items Parameter
Default Value
New Value
spark.sql.extensions
org.apache.spark.sql.hive.SparkSessionExtension,org.apache.spark.sql.hudi.HoodieSparkSessionExtension
org.apache.spark.sql.hive.SparkSessionExtension,org.apache.spark.sql.hudi.HoodieSparkSessionExtension,org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions,org.apache.paimon.spark.extensions.PaimonSparkSessionExtensions
spark.sql.storeAssignmentPolicy
LEGACY
ANSI
- Log in to the Spark client node as the client installation user and switch to the client installation directory.
cd Client installation directory
Load the environment variables.
source bigdata_env
Load the component environment variables.
source Spark/component_env source Hudi/component_env
For clusters in security mode, additionally run the following command:
kinit Component service user
Enter the password for authentication. (Change the password upon your first login.)
- Connect to Spark JDBCServer.
spark-beeline
- Create a table. The data migration procedure is identical to 3 and 4 in the Spark SQL mode.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot