EXPORT

Description

  1. This statement is used to export data from a specified table to a specified location.
  2. This function is implemented by broker process. For different purpose storage systems, different brokers need to be deployed. Deployed brokers can be viewed through SHOW BROKER.
  3. This is an asynchronous operation, which returns if the task is submitted successfully. After execution, you can use the SHOW EXPORT command to view progress.
  4. Grammar:
  5. EXPORT TABLE table_name
  6. [PARTITION (p1 [,p2]]
  7. [WHERE [expr]]
  8. TO export_path
  9. [opt_properties]
  10. [brokerS3];
  11. 1. table_name
  12. The table names to be exported currently support the export of tables with engine as OLAP and mysql.
  13. 2. partition
  14. You can export only certain specified partitions of the specified table
  15. 3. expr
  16. Export rows that meet the where condition, optional. If you leave it blank, all rows are exported by default.
  17. 4. export_path
  18. The exported path needs to be a directory. At present, it can't be exported to local, so it needs to be exported to broker.
  19. 5. opt_properties
  20. Used to specify some special parameters.
  21. Grammar:
  22. [PROPERTIES ("key"="value", ...)]
  23. The following parameters can be specified:
  24. label: The identifier of this export job. You can use this identifier to view the job status later.
  25. column_separator: Specifies the exported column separator, defaulting to t. Supports invisible characters, such as'\x07'.
  26. column: Specify the columns to be exported, separated by commas. If you do not fill in this parameter, the default is to export all the columns of the table.
  27. line_delimiter: Specifies the exported line separator, defaulting to\n. Supports invisible characters, such as'\x07'.
  28. exec_mem_limit: Exports the upper limit of memory usage for a single BE node, defaulting to 2GB in bytes.
  29. timeout: The time-out for importing jobs is 1 day by default, in seconds.
  30. tablet_num_per_task: The maximum number of tablets that each subtask can allocate.
  31. 6. broker|S3
  32. Specify to use broker export or export through S3 protocol
  33. Grammar:
  34. WITH [BROKER broker_name| S3] ("key"="value"[,...])
  35. Here you need to specify the specific broker name and the required broker attributes, If you use the S3 protocol, you do not need to specify the broker name
  36. For brokers corresponding to different storage systems, the input parameters are different. Specific parameters can be referred to: `help broker load', broker required properties.
  37. When exporting to local, you do not need to fill in this part.

example

  1. 1. Export all data from the testTbl table to HDFS
  2. EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" WITH BROKER "broker_name" ("username"="xxx", "password"="yyy");
  3. 2. Export partitions P1 and P2 from the testTbl table to HDFS
  4. EXPORT TABLE testTbl PARTITION (p1,p2) TO "hdfs://hdfs_host:port/a/b/c" WITH BROKER "broker_name" ("username"="xxx", "password"="yyy");
  5. 3. Export all data in the testTbl table to hdfs, using "," as column separator, and specify label
  6. EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" PROPERTIES ("label" = "mylabel", "column_separator"=",") WITH BROKER "broker_name" ("username"="xxx", "password"="yyy");
  7. 4. Export the row meet condition k1 = 1 in the testTbl table to hdfs.
  8. EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" WHERE k1=1 WITH BROKER "broker_name" ("username"="xxx", "password"="yyy");
  9. 5. Export all data in the testTbl table to the local.
  10. EXPORT TABLE testTbl TO "file:///home/data/a";
  11. 6. Export all data in the testTbl table to hdfs, using the invisible character "\x07" as the column and row separator.
  12. EXPORT TABLE testTbl TO "hdfs://hdfs_host:port/a/b/c" PROPERTIES ("column_separator"="\\x07", "line_delimiter" = "\\x07") WITH BROKER "broker_name" ("username"="xxx", "password"="yyy")
  13. 7. Export column k1, v1 from the testTbl to the local.
  14. EXPORT TABLE testTbl TO "file:///home/data/a" PROPERTIES ("columns" = "k1,v1");

keyword

  1. EXPORT