Skip to main content
SPARK LOAD preprocesses the imported data through external spark resources, improves the import performance of a large amount of data, and saves the computing resources of cluster. It is mainly used in the scenario of initial migration and large amount of data import into the database. Spark load is an asynchronous import method. Users need to create Spark type import tasks through MySQL protocol and view the import results throughSHOW LOAD.
NOTICE
  • You can load data into tables only as a user who has the INSERT privilege on those tables. If you do not have the INSERT privilege, follow the instructions provided in GRANT to grant the INSERT privilege to the user that you use to connect to your cluster.
  • When Spark Load is used to load data into a table, the bucketing column of the table cannot be of DATE, DATETIME, or DECIMAL type.
Syntax
1.load_label Label of the currently imported batch. Unique within a database. Syntax:
2.data_desc Used to describe a batch of imported data. Syntax:
Note
text
3.resource_name The name of the spark resource used can be viewed through SHOW RESOURCES command. 4.resource_properties When you have a temporary need, such as modifying the Spark and HDFS configurations, you can set the parameters here, which takes effect only in this specific spark loading job and not to affect the existing configurations in the cluster. 5.opt_properties Used to specify some special parameters. Syntax:
You can specify the following parameters: timeout: specifies the timeout of the import operation. The default timeout is 4 hours. In seconds. max_filter_ratio:the maximum allowable data proportion that can be filtered (for reasons such as non-standard data). The default is zero tolerance. strict mode: whether to strictly restrict the data. The default is false. timezone: specifies the time zone of some functions affected by the time zone, such as strftime / alignment_timestamp/from_unixtime, etc. Please refer to the [time zone] document for details. If not specified, the “Asia / Shanghai” time zone is used. 6.Import data format example int (TINYINT/SMALLINT/INT/BIGINT/LARGEINT): 1, 1000, 1234 float (FLOAT/DOUBLE/DECIMAL): 1.1, 0.23, .356 date (DATE/DATETIME) :2017-10-03, 2017-06-13 12:34:03. (Note: for other date formats, you can use strftime or time_format function to convert in the Import command) string class (CHAR/VARCHAR): “I am a student”, “a” NULL value: \ N

Examples

  1. Import a batch of data from HDFS, and specify the timeout time and filtering ratio. Use the name my_ spark resources for spark.
    Where hdfs_host is the host of namenode, hdfs_port is fs.defaultfs port (default 9000)
  2. Import a batch of “negative” data from HDFS, specify the separator as comma, use the wildcard * to specify all files in the directory, and specify the temporary parameters of spark resources.
  3. Import a batch of data from HDFS, specify the partition, and do some conversion on the columns of the imported file, as follows:
    text
  4. Extract the partition field in the file path If necessary, the partitioned fields in the file path will be resolved according to the field types defined in the table, similar to the function of Partition Discovery in Spark
    hdfs://hdfs_host:hdfs_port/user/starRocks/data/input/dir/city=beijing The directory includes the following files: [hdfs://hdfs_host:hdfs_port/user/starRocks/data/input/dir/city=beijing/utc_date=2019-06-26/0000.csv, hdfs://hdfs_host:hdfs_port/user/starRocks/data/input/dir/city=beijing/utc_date=2019-06-26/0001.csv, ...] The city and utc_date field in the file path are extracted
  5. Filter the data to be imported. Only columns with k1 value greater than 10 can be imported.
  6. Import from the hive external table and convert the uuid column in the source table to the bitmap type through the global dictionary.