CREATE DATABASE if not EXISTS online_database; USE online_database; CREATE TABLE table1 ( siteid INT DEFAULT '10', citycode SMALLINT, username VARCHAR(32) DEFAULT '', pv BIGINT SUM DEFAULT '0' ) AGGREGATE KEY(siteid, citycode, username) DISTRIBUTED BY HASH(siteid) BUCKETS 10;
warning
When configuring a resource queue, you must enable the features related to network configuration, and the VPC network used by this queue must be exactly the same as the VPC network used by the Doris instance. This is the only way to ensure network compatibility and connectivity between the queue and the Doris instance, allowing tasks using this queue to successfully access the Doris instance.
tip
It is recommended to disable the global cross VPC routing feature, and only add the set serverless.cross.vpc.access.enabled=true; parameter to tasks that need to access Doris to enable network connectivity.
CREATE DATABASE IF NOT EXISTS ss_wr2sr; command to create the database ss_wr2sr.CREATE TABLE if not exists ss_wr2sr.ss_table1( `siteid` int, `citycode` SMALLINT, `username` string, `pv` BIGINT ); CREATE TABLE if not exists ss_wr2sr.ss_table2( `siteid` int, `citycode` SMALLINT, `username` string, `pv` BIGINT );
Read and write Doris data tables using Serverless Spark.
Go to the EMR Serverless job editing page, enter the Spark SQL statements from the example SQL code block below, and click the Job editing page's lower left Run button to execute the SQL job.
-- Fill in the TOS address of the JAR dependency package set las.spark.jar.depend.jars = [{"fileName":"{dependency jar address}"}]; -- Optional parameter: set the default directory for Spark SQL. set spark.sql.catalog.{your_catalog_name}=org.apache.doris.spark.catalog.DorisTableCatalog; set spark.sql.catalog.{your_catalog_name}.doris.fenodes={fe_ip:fe_http_port}; set spark.sql.catalog.{your_catalog_name}.doris.query.port=9030; set spark.sql.catalog.{your_catalog_name}.doris.user={user name}; set spark.sql.catalog.{your_catalog_name}.doris.password={user password}; show databases; SELECT * FROM {your_catalog_name}.online_database.table1; INSERT INTO {your_catalog_name}.online_database.table1 select * from db.table;
Read Doris data tables and write Hive data tables using Serverless Spark.
Log in to the EMR Serverless job editing page, enter the Spark SQL statements from the example SQL code block below, and click the lower left Run button in the job editing box to execute the SQL job.
-- Fill in the TOS address of the JAR dependency package set las.spark.jar.depend.jars = [{"fileName":"{dependency jar address}"}]; set spark.sql.catalog.{your_catalog_name}=org.apache.doris.spark.catalog.DorisTableCatalog; set spark.sql.catalog.{your_catalog_name}.doris.fenodes={fe_ip:fe_http_port}; set spark.sql.catalog.{your_catalog_name}.doris.query.port=9030; set spark.sql.catalog.{your_catalog_name}.doris.user={user name}; set spark.sql.catalog.{your_catalog_name}.doris.password={user password}; INSERT into ss_wr2sr.ss_table1 SELECT * FROM {your_catalog_name}.online_database.table1;
Read Hive data tables and write Doris data tables using Serverless Spark.
Log in to the EMR Serverless job editing page, enter the Spark SQL statements from the example SQL code block below, and click the lower left Run button in the job editing box to execute the SQL job.
-- Fill in the TOS address of the JAR dependency package set las.spark.jar.depend.jars = [{"fileName":"{dependency jar address}"}]; set spark.sql.catalog.{your_catalog_name}=org.apache.doris.spark.catalog.DorisTableCatalog; set spark.sql.catalog.{your_catalog_name}.doris.fenodes={fe_ip:fe_http_port}; set spark.sql.catalog.{your_catalog_name}.doris.query.port=9030; set spark.sql.catalog.{your_catalog_name}.doris.user={user name}; set spark.sql.catalog.{your_catalog_name}.doris.password={user password}; INSERT into {your_catalog_name}.online_database.table1 SELECT * FROM ss_wr2sr.ss_table2;
For more examples and parameters, refer to the Doris community documentation.
Download the required spark-doris-connector package from the Doris community documentation and upload it to the corresponding Volcano TOS path.