sqljob

package
v0.0.0-...-63319d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Maximum number of records to be written into a single file. If the value is zero or negative, there is no limit.
	ConfigSparkSqlFilesMaxRecordsPerFile = "spark.sql.files.maxRecordsPerFile"
	// Maximum size of the table that displays all working nodes when a connection is executed.
	// You can set this parameter to -1 to disable the display.
	// NOTE:
	// only the configuration unit metastore table that runs the ANALYZE TABLE COMPUTE statistics noscan command and
	// the file-based data source table that directly calculates statistics based on data files are supported.
	ConfigSparkSqlAutoBroadcastJoinThreshold = "spark.sql.autoBroadcastJoinThreshold"
	// Default number of partitions used to filter data for join or aggregation.
	ConfigSparkSqlShufflePartitions = "spark.sql.shuffle.partitions"
	// In dynamic mode, Spark does not delete the previous partitions and only overwrites the partitions without
	// data during execution.
	ConfigSparkSqlDynamicPartitionOverwriteEnabled = "spark.sql.dynamicPartitionOverwrite.enabled"
	// Maximum number of bytes to be packed into a single partition when a file is read.
	ConfigSparkSqlMaxPartitionBytes = "spark.sql.files.maxPartitionBytes"
	// Path of bad records.
	ConfigSparkSqlBadRecordsPath = "spark.sql.badRecordsPath"
	// Indicates whether DDL and DCL statements are executed asynchronously. The value true indicates that
	// asynchronous execution is enabled.
	ConfigDliSqlasyncEnabled = "dli.sql.sqlasync.enabled"
	// Sets the job running timeout interval. If the timeout interval expires, the job is canceled. Unit: ms.
	ConfigDliSqljobTimeout = "dli.sql.job.timeout"
)
View Source
const (
	JobTypeDDL           = "DDL"
	JobTypeDCL           = "DCL"
	JobTypeImport        = "IMPORT"
	JobTypeExport        = "EXPORT"
	JobTypeQuery         = "QUERY"
	JobTypeInsert        = "INSERT"
	JobTypeDataMigration = "DATA_MIGRATION"
	JobTypeUpdate        = "UPDATE"
	JobTypeDelete        = "DELETE"
	JobTypeRestartQueue  = "RESTART_QUEUE"
	JobTypeScaleQueue    = "SCALE_QUEUE"

	JobModeSync  = "synchronous"
	JobModeAsync = "asynchronous"

	JobStatusLaunching = "LAUNCHING"
	JobStatusRunning   = "RUNNING"
	JobStatusFinished  = "FINISHED"
	JobStatusFailed    = "FAILED"
	JobStatusCancelled = "CANCELLED"
)

Variables

View Source
var RequestOpts = golangsdk.RequestOpts{
	MoreHeaders: map[string]string{"Content-Type": "application/json", "X-Language": "en-us"},
}

Functions

This section is empty.

Types

type CheckSQLGramarOpts

type CheckSQLGramarOpts struct {
	// SQL statement that you want to execute.
	Sql string `json:"sql" required:"true"`
	// Database where the SQL statement is executed.
	// NOTE:
	// If the SQL statement contains db_name, for example, select * from db1.t1, you do not need to set this parameter.
	// If the SQL statement does not contain db_name, the semantics check will fail when you do not set this parameter
	// or set this parameter to an incorrect value.
	Currentdb string `json:"currentdb"`
}

type CheckSqlResult

type CheckSqlResult struct {
	IsSuccess bool   `json:"is_success"`
	Message   string `json:"message"`
	// Type of a job. Job types include the following: DDL, DCL, IMPORT, EXPORT, QUERY, and INSERT.
	JobType string `json:"job_type"`
}

func CheckSQLGramar

func CheckSQLGramar(c *golangsdk.ServiceClient, opts CheckSQLGramarOpts) (*CheckSqlResult, error)

type CommonResp

type CommonResp struct {
	IsSuccess bool   `json:"is_success"`
	Message   string `json:"message"`
}

func Cancel

func Cancel(c *golangsdk.ServiceClient, jobId string) (*CommonResp, error)

type ExportDataOpts

type ExportDataOpts struct {
	// Path for storing the exported data. Currently, data can be stored only on OBS.
	// If export_mode is set to errorifexists, the OBS path cannot contain the specified folder,
	// for example, the test folder in the example request.
	DataPath string `json:"data_path" required:"true"`
	// Type of data to be exported. Currently, only CSV and JSON are supported.
	DataType string `json:"data_type" required:"true"`
	// Name of the database where the table from which data is exported resides.
	DatabaseName string `json:"database_name" required:"true"`
	// Name of the table from which data is exported.
	TableName string `json:"table_name" required:"true"`
	// Compression mode for exported data. Currently, the compression modes gzip, bzip2, and deflate are supported. If you do not want to compress data, enter none.
	Compress string `json:"compress" required:"true"`
	// Name of the queue that is specified to execute a task. If no queue is specified, the default queue is used.
	QueueName string `json:"queue_name,omitempty"`
	// Export mode. The parameter value can be ErrorIfExists or Overwrite. If export_mode is not specified, this parameter is set to ErrorIfExists by default.
	// ErrorIfExists: Ensure that the specified export directory does not exist. If the specified export directory exists, an error is reported and the export operation cannot be performed.
	// Overwrite: If you add new files to a specific directory, existing files will be deleted.
	ExportMode string `json:"export_mode,omitempty"`
	// Whether to export column names when exporting CSV and JSON data.
	// If this parameter is set to true, the column names are exported.
	// If this parameter is set to false, the column names are not exported.
	// If this parameter is left blank, the default value false is used.
	WithColumnHeader *bool `json:"with_column_header,omitempty"`
}

type ExportQueryResultOpts

type ExportQueryResultOpts struct {
	// Path for storing the exported data. Currently, data can be stored only on OBS.
	// The OBS path cannot contain folders, for example, the path folder in the sample request.
	DataPath string `json:"data_path" required:"true"`
	// Compression format of exported data. Currently, gzip, bzip2, and deflate are supported.
	// The default value is none, indicating that data is not compressed.
	Compress string `json:"compress,omitempty"`
	// Storage format of exported data. Currently, only CSV and JSON are supported.
	DataType string `json:"data_type" required:"true"`
	// Name of the queue that is specified to execute a task. If no queue is specified, the default queue is used.
	QueueName string `json:"queue_name,omitempty"`
	// Export mode. The parameter value can be ErrorIfExists or Overwrite.
	// If export_mode is not specified, this parameter is set to ErrorIfExists by default.
	// ErrorIfExists: Ensure that the specified export directory does not exist.
	// If the specified export directory exists, an error is reported and the export operation cannot be performed.
	// Overwrite: If you add new files to a specific directory, existing files will be deleted.
	ExportMode string `json:"export_mode,omitempty"`
	// Whether to export column names when exporting CSV and JSON data.
	// If this parameter is set to true, the column names are exported.
	// If this parameter is set to false, the column names are not exported.
	// If this parameter is left blank, the default value false is used.
	WithColumnHeader *bool `json:"with_column_header,omitempty"`
	// Number of data records to be exported. The default value is 0, indicating that all data records are exported.
	LimitNum *int `json:"limit_num,omitempty"`
}

type ImportDataOpts

type ImportDataOpts struct {
	// Path to the data to be imported. Currently, only OBS data can be imported.
	DataPath string `json:"data_path" required:"true"`
	// Type of the data to be imported. Currently, data types of CSV, Parquet, ORC, JSON, and Avro are supported.
	// NOTE:
	// Data in Avro format generated by Hive tables cannot be imported.
	DataType string `json:"data_type" required:"true"`
	// Name of the database where the table to which data is imported resides.
	DatabaseName string `json:"database_name" required:"true"`
	// Name of the table to which data is imported.
	TableName string `json:"table_name" required:"true"`
	// Whether the first line of the imported data contains column names, that is, headers. The default value is false, indicating that column names are not contained. This parameter can be specified when CSV data is imported.
	WithColumnHeader *bool `json:"with_column_header,omitempty"`
	// User-defined data delimiter. The default value is a comma (,). This parameter can be specified when CSV data is imported.
	Delimiter string `json:"delimiter,omitempty"`
	// User-defined quotation character. The default value is double quotation marks ("). This parameter can be specified when CSV data is imported.
	QuoteChar string `json:"quote_char,omitempty"`
	// User-defined escape character. The default value is a backslash (\). This parameter can be specified when CSV data is imported.
	EscapeChar string `json:"escape_char,omitempty"`
	// Specified date format. The default value is yyyy-MM-dd. For details about the characters involved in the date format, see Table 3. This parameter can be specified when data in the CSV or JSON format is imported.
	DateFormat string `json:"date_format,omitempty"`
	// Bad records storage directory during job execution. After configuring this item, the bad records is not imported into the target table.
	BadRecordsPath string `json:"bad_records_path,omitempty"`
	// Specified time format. The default value is yyyy-MM-dd HH:mm:ss. For definitions about characters in the time format, see Table 3. This parameter can be specified when data in the CSV or JSON format is imported.
	TimestampFormat string `json:"timestamp_format,omitempty"`
	// Name of the queue that is specified to execute a task. If no queue is specified, the default queue is used.
	QueueName string `json:"queue_name,omitempty"`
	// Whether to overwrite data. The default value is false, indicating appending write. If the value is true, it indicates overwriting.
	Overwrite *bool `json:"overwrite,omitempty"`
	// Partition to which data is to be imported.
	// If this parameter is not set, the entire table data is dynamically imported. The imported data must contain the data in the partition column.
	// If this parameter is set and all partition information is configured during data import, data is imported to the specified partition. The imported data cannot contain data in the partition column.
	// If not all partition information is configured during data import, the imported data must contain all non-specified partition data. Otherwise, abnormal values such as null exist in the partition field column of non-specified data after data import.
	PartitionSpec map[string]string `json:"partition_spec,omitempty"`
	// User-defined parameter that applies to the job. Currently, dli.sql.dynamicPartitionOverwrite.enabled can be set to false by default. If it is set to true, data in a specified partition is overwritten. If it is set to false, data in the entire DataSource table is dynamically overwritten.
	// NOTE:
	// For dynamic overwrite of Hive partition tables, only the involved partition data can be overwritten. The entire table data cannot be overwritten.
	Conf []string `json:"conf,omitempty"`
}

type Job

type Job struct {
	// Job ID.
	JobId string `json:"job_id"`
	// Type of a job.
	JobType string `json:"job_type"`
	// Queue to which a job is submitted.
	QueueName string `json:"queue_name"`
	// User who submits a job.
	Owner string `json:"owner"`
	// Time when a job is started. The timestamp is expressed in milliseconds.
	StartTime int `json:"start_time"`
	// Job running duration (unit: millisecond).
	Duration int `json:"duration"`
	// Status of a job, including LAUNCHING, RUNNING, FINISHED, FAILED, and CANCELLED.
	Status string `json:"status"`
	// Number of records scanned during the Insert job execution.
	InputRowCount int `json:"input_row_count"`
	// Number of error records scanned during the Insert job execution.
	BadRowCount int `json:"bad_row_count"`
	// Size of scanned files during job execution.
	InputSize int `json:"input_size"`
	// Total number of records returned by the current job or total number of records inserted by the Insert job.
	ResultCount int `json:"result_count"`
	// Name of the database where the target table resides.
	// database_name is valid only for jobs of the Import and Export types.
	DatabaseName string `json:"database_name"`
	// Name of the target table. table_name is valid only for jobs of the Import and Export types.
	TableName string `json:"table_name"`
	// Import jobs, which record whether the imported data contains column names.
	WithColumnHeader bool `json:"with_column_header"`
	// JSON character string of related columns queried by using SQL statements.
	Detail string `json:"detail"`
	// SQL statements of a job.
	Statement string             `json:"statement"`
	Tags      []tags.ResourceTag `json:"tags"`
}

type JobDetail

type JobDetail struct {
	// Whether the request is successfully executed. Value true indicates that the request is successfully executed.
	IsSuccess bool `json:"is_success" required:"true"`
	// System prompt. If execution succeeds, the parameter setting may be left blank.
	Message string `json:"message" required:"true"`
	// Job ID.
	JobId string `json:"job_id" required:"true"`
	// User who submits a job.
	Owner string `json:"owner" required:"true"`
	// Time when a job is started. The timestamp is expressed in milliseconds.
	StartTime int `json:"start_time" required:"true"`
	// Duration for executing the job (unit: millisecond).
	Duration int `json:"duration" required:"true"`
	// Specified export mode during data export and query result saving.
	ExportMode string `json:"export_mode"`
	// Path to imported or exported files.
	DataPath string `json:"data_path" required:"true"`
	// Type of data to be imported or exported. Currently, only CSV and JSON are supported.
	DataType string `json:"data_type" required:"true"`
	// Name of the database where the table, where data is imported or exported, resides.
	DatabaseName string `json:"database_name" required:"true"`
	// Name of the table where data is imported or exported.
	TableName string `json:"table_name" required:"true"`
	// Whether the imported data contains the column name during the execution of an import job.
	WithColumnHeader bool `json:"with_column_header"`
	// User-defined data delimiter set when the import job is executed.
	Delimiter string `json:"delimiter"`
	// User-defined quotation character set when the import job is executed.
	QuoteChar string `json:"quote_char"`
	// User-defined escape character set when the import job is executed.
	EscapeChar string `json:"escape_char"`
	// Table date format specified when the import job is executed.
	DateFormat string `json:"date_format"`
	// Table time format specified when the import job is executed.
	TimestampFormat string `json:"timestamp_format"`
	// Compression mode specified when the export job is executed.
	Compress string `json:"compress"`
}

func Get

func Get(c *golangsdk.ServiceClient, jobId string) (*JobDetail, error)

type JobProgress

type JobProgress struct {
	IsSuccess bool   `json:"is_success"`
	Message   string `json:"message"`
	JobId     string `json:"job_id"`
	Status    string `json:"status"`
	// ID of a subjob that is running. If the subjob is not running or it is already finished,
	// the subjob ID may be empty.
	SubJobId int `json:"sub_job_id"`

	// If the job is just started or being submitted, the progress is displayed as 0. If the job execution is complete,
	//  the progress is displayed as 1. In this case, progress indicates the running progress of the entire job.
	//  Because no subjob is running, sub_job_id is not displayed.
	// If a subjob is running, the running progress of the subjob is displayed. The calculation method of progress is as
	//  follows: Number of completed tasks of the subjob/Total number of tasks of the subjob. In this case,
	//  progress indicates the running progress of the subjob, and sub_job_id indicates the subjob ID.
	Progress int `json:"progress"`
	// Details about a subjob of a running job. A job may contain multiple subjobs. For details
	SubJobs []SubJob `json:"sub_jobs"`
}

func Progress

func Progress(c *golangsdk.ServiceClient, jobId string) (*JobProgress, error)

type JobResp

type JobResp struct {
	IsSuccess bool   `json:"is_success" required:"true"`
	Message   string `json:"message" required:"true"`
	// ID of a job returned after a job is generated and submitted by using SQL statements.
	// The job ID can be used to query the job status and results.
	JobId string `json:"job_id"`
	// Job execution mode. The options are as follows:
	// async: asynchronous
	// sync: synchronous
	JobMode string `json:"job_mode"`
}

func ExportData

func ExportData(c *golangsdk.ServiceClient, opts ExportDataOpts) (*JobResp, error)

func ExportQueryResult

func ExportQueryResult(c *golangsdk.ServiceClient, jobId string, opts ExportQueryResultOpts) (*JobResp, error)

func ImportData

func ImportData(c *golangsdk.ServiceClient, opts ImportDataOpts) (*JobResp, error)

type JobStatus

type JobStatus struct {
	// Whether the request is successfully executed. Value true indicates that the request is successfully executed.
	IsSuccess bool `json:"is_success" required:"true"`
	// System prompt. If execution succeeds, the parameter setting may be left blank.
	Message string `json:"message" required:"true"`
	// Job ID.
	JobId string `json:"job_id" required:"true"`
	// Type of a job, Includes DDL, DCL, IMPORT, EXPORT, QUERY, INSERT, DATA_MIGRATION, UPDATE, DELETE, RESTART_QUEUE and SCALE_QUEUE.
	JobType string `json:"job_type" required:"true"`
	// Job execution mode. The options are as follows:
	// async: asynchronous
	// sync: synchronous
	JobMode string `json:"job_mode" required:"true"`
	// Name of the queue where the job is submitted.
	QueueName string `json:"queue_name" required:"true"`
	// User who submits a job.
	Owner string `json:"owner" required:"true"`
	// Time when a job is started. The timestamp is expressed in milliseconds.
	StartTime int `json:"start_time" required:"true"`
	// Job running duration (unit: millisecond).
	Duration int `json:"duration"`
	// Status of a job, including RUNNING, SCALING, LAUNCHING, FINISHED, FAILED, and CANCELLED.
	Status string `json:"status" required:"true"`
	// Number of records scanned during the Insert job execution.
	InputRowCount int `json:"input_row_count"`
	// Number of error records scanned during the Insert job execution.
	BadRowCount int `json:"bad_row_count"`
	// Size of scanned files during job execution (unit: byte).
	InputSize int `json:"input_size" required:"true"`
	// Total number of records returned by the current job or total number of records inserted by the Insert job.
	ResultCount int `json:"result_count" required:"true"`
	// Name of the database where the target table resides. database_name is valid only for jobs of the IMPORT EXPORT, and QUERY types.
	DatabaseName string `json:"database_name"`
	// Name of the target table. table_name is valid only for jobs of the IMPORT EXPORT, and QUERY types.
	TableName string `json:"table_name"`
	// JSON character string for information about related columns.
	Detail string `json:"detail" required:"true"`
	// SQL statements of a job.
	Statement string             `json:"statement" required:"true"`
	Tags      []tags.ResourceTag `json:"tags"`
}

func Status

func Status(c *golangsdk.ServiceClient, jobId string) (*JobStatus, error)

type ListJobsOpts

type ListJobsOpts struct {
	// Maximum number of jobs displayed on each page. The value range is as follows: [1, 100]. The default value is 50.
	PageSize *int `q:"page-size"`
	// Current page number. The default value is 1.
	CurrentPage *int `q:"current-page"`
	// Queries the jobs executed later than the time. The time is a UNIX timestamp in milliseconds.
	Start *int `q:"start"`
	// Queries the jobs executed earlier than the time. The time is a UNIX timestamp in milliseconds.
	End *int `q:"end"`
	// Type of a job to be queried. Job types include:DDL、DCL、IMPORT、EXPORT、QUERY、INSERT、DATA_MIGRATION、UPDATE、
	// DELETE、RESTART_QUEUE、SCALE_QUEUE, To query all types of jobs, enter ALL
	JobType   string `q:"job-type"`
	JobStatus string `q:"job-status"`
	JobId     string `q:"job-id"`
	DbName    string `q:"db_name"`
	TableName string `q:"table_name"`
	// Specifies queue_name as the filter to query jobs running on the specified queue.
	QueueName string `q:"queue_name"`
	// Specifies the SQL segment as the filter. It is case insensitive.
	SqlPattern string `q:"sql_pattern"`
	// Specifies the job sorting mode. The default value is start_time_desc (job submission time in descending order).
	// Four sorting modes are supported: duration_desc (job running duration in descending order),
	// duration_asc (job running duration in ascending order),
	// start_time_desc (job submission time in descending order),
	// and start_time_asc (job submission time in ascending order).
	Order      string `q:"order"`
	EngineType string `q:"engine-type"`
}

ListJobsOpts

type ListJobsResp

type ListJobsResp struct {
	IsSuccess bool   `json:"is_success"`
	Message   string `json:"message"`
	JobCount  int    `json:"job_count"`
	Jobs      []Job  `json:"jobs"`
}

func List

func List(c *golangsdk.ServiceClient, opts ListJobsOpts) (*ListJobsResp, error)

type SqlJobOpts

type SqlJobOpts struct {
	// SQL statement that you want to execute.
	Sql string `json:"sql" required:"true"`
	// Database where the SQL is executed. This parameter does not need to be configured during database creation.
	Currentdb string `json:"currentdb,omitempty"`
	QueueName string `json:"queue_name,omitempty"`
	// You can set the configuration parameters for the SQL job in the form of Key/Value
	Conf []string           `json:"conf,omitempty"`
	Tags []tags.ResourceTag `json:"tags,omitempty"`
}

type SubJob

type SubJob struct {
	// Subjob ID, corresponding to jobId of the open-source spark JobData.
	Id int `json:"id"`
	// Subjob name, corresponding to the name of the open-source spark JobData.
	Name string `json:"name"`
	// Description of a subjob, corresponding to the description of the open-source spark JobData.
	Description string `json:"description"`
	// Submission time of a subjob, corresponding to the submissionTime of open-source Spark JobData.
	SubmissionTime string `json:"submission_time"`
	// Completion time of a subjob, corresponding to the completionTime of the open-source Spark JobData.
	CompletionTime string `json:"completion_time"`
	// Stage ID of the subjob, corresponding to the stageIds of the open-source spark JobData.
	StageIds []int `json:"stage_ids"`
	// ID of a DLI job, corresponding to the jobGroup of open-source Spark JobData.
	JobGroup string `json:"job_group"`
	// Subjob status, corresponding to the status of open-source spark JobData.
	Status string `json:"status"`
	// Number of subjobs, corresponding to numTasks of the open-source Spark JobData.
	NumTasks int `json:"num_tasks"`
	// Number of running tasks in a subjob, corresponding to numActiveTasks of the open-source Spark JobData.
	NumActiveTasks int `json:"num_active_tasks"`
	// Number of tasks that have been completed in a subjob, corresponding to numCompletedTasks of open-source Spark JobData.
	NumCompletedTasks int `json:"num_completed_tasks"`
	// Number of tasks skipped in a subjob, corresponding to numSkippedTasks of open-source Spark JobData.
	NumSkippedTasks int `json:"num_skipped_tasks"`
	// Number of subtasks that fail to be skipped, corresponding to numFailedTasks of open-source Spark JobData.
	NumFailedTasks int `json:"num_failed_tasks"`
	// Number of tasks killed in the subjob, corresponding to numKilledTasks of the open-source Spark JobData.
	NumKilledTasks int `json:"num_killed_tasks"`
	// Subjob completion index, corresponding to the numCompletedIndices of the open-source Spark JobData.
	NumCompletedIndices int `json:"num_completed_indices"`
	// Number of stages that are running in the subjob, corresponding to numActiveStages of the open-source Spark JobData.
	NumActiveStages int `json:"num_active_stages"`
	// Number of stages that have been completed in the subjob, corresponding to numCompletedStages of the open-source Spark JobData.
	NumCompletedStages int `json:"num_completed_stages"`
	// Number of stages skipped in the subjob, corresponding to numSkippedStages of the open-source Spark JobData.
	NumSkippedStages int `json:"num_skipped_stages"`
	// Number of failed stages in a subjob, corresponding to numFailedStages of the open-source Spark JobData.
	NumFailedStages int `json:"num_failed_stages"`
	// Summary of the killed tasks in the subjob, corresponding to killedTasksSummary of open-source spark JobData.
	KilledTasksSummary map[string]int `json:"killed_tasks_summary"`
}

type SubmitJobResult

type SubmitJobResult struct {
	// Indicates whether the request is successfully sent. Value true indicates that the request is successfully sent.
	IsSuccess bool `json:"is_success"`
	// System prompt. If execution succeeds, the parameter setting may be left blank.
	Message string `json:"message"`
	// ID of a job returned after a job is generated and submitted by using SQL statements.
	// The job ID can be used to query the job status and results.
	JobId string `json:"job_id"`
	// Type of a job. Job types include the following:
	// DDL
	// DCL
	// IMPORT
	// EXPORT
	// QUERY
	// INSERT
	JobType string `json:"job_type"`
	// If the statement type is DDL, the column name and type of DDL are displayed.
	Schema []map[string]string `json:"schema"`
	// When the statement type is DDL, results of the DDL are displayed.
	Rows [][]string `json:"rows"`
	// Job execution mode. The options are as follows:
	// async: asynchronous
	// sync: synchronous
	JobMode string `json:"job_mode"`
}

func Submit

func Submit(c *golangsdk.ServiceClient, opts SqlJobOpts) (*SubmitJobResult, error)

Submit Job

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL