A task execution method, apparatus, system, server, and storage medium
By analyzing the type and context of SQL statements, an execution cluster is constructed and connected to the target engine, solving the problem of independent connection of each SQL statement in existing technologies, and achieving more efficient and flexible SQL task execution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-25
- Publication Date
- 2026-03-13
AI Technical Summary
In existing technologies, users need to establish a connection for each SQL statement when using different data engines, which leads to a lack of flexibility and increases engine load, affecting performance and SQL task submission efficiency.
By determining the target statement type of the SQL statement, and when the type does not affect the environment state, determining the context and execution cluster, only a connection to the target engine is established to execute the SQL task, avoiding the need to establish a separate connection for each SQL statement.
It reduces the load on the engine side, improves the flexibility and efficiency of task execution, and optimizes the execution process of SQL tasks.
Smart Images

Figure CN117149807B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a task execution method, apparatus, system, server, and storage medium. Background Technology
[0002] To help users reduce the switching costs when using different data engines and avoid reinventing the wheel, a unified engine entry point is typically built on top of the OLAP (Online Analytical Processing) engine. This entry point connects to the OLAP engine via JDBC (Java Database Connectivity) and provides a client SDK (Software Development Kit) to allow users to submit SQL (Structured Query Language) tasks via JDBC. Currently, for a user to successfully execute an SQL task submitted through the client, a connection needs to be established between each SQL statement in the SQL task and the corresponding engine in the QLAP engine. However, this method lacks flexibility because it requires establishing a connection for each SQL statement, and it increases the engine's load, severely impacting engine performance and the submission of subsequent SQL tasks. Summary of the Invention
[0003] In view of this, in order to solve the above-mentioned technical problems or some of the technical problems, the embodiments of the present invention provide a task execution method, apparatus, system, server and storage medium.
[0004] Firstly, this application provides a task execution method applied to a server, the method comprising:
[0005] When the SQL statement corresponding to the target SQL task is obtained, the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement are determined.
[0006] When the target statement type is a first statement type, the context information of the SQL statement is determined, whereby the first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state.
[0007] Based on the SQL statement and the information above, determine the target execution cluster corresponding to the SQL statement;
[0008] A connection is established between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0009] In an optional implementation, determining the target statement type corresponding to the SQL statement includes:
[0010] Convert the SQL statement into an abstract syntax tree;
[0011] Based on the abstract syntax tree, determine the target node type corresponding to the SQL statement;
[0012] Based on the target node type, determine the target statement type corresponding to the SQL statement.
[0013] In an optional implementation, determining the target statement type corresponding to the SQL statement based on the target node type includes:
[0014] Obtain the pre-established mapping relationship, which stores multiple sets of correspondences between node types and statement types;
[0015] A query operation is performed on the mapping relationship based on the target node type to obtain the target statement type corresponding to the target node type.
[0016] In an optional implementation, after performing the steps of determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement, the method further includes:
[0017] When the target statement type is the second statement type, the SQL statement is cached in the target memory. The second statement type is used to indicate that the SQL statement is a statement that affects the environment state.
[0018] Determining the context information of the SQL statement includes:
[0019] Determine the target execution relationship corresponding to the SQL statement, wherein the target execution relationship is used to characterize the execution order between the SQL statement of the first statement type and the SQL statement of the second statement type;
[0020] Based on the target execution relationship, determine from the target memory all SQL statements of the second statement type corresponding to the SQL statement of the first statement type;
[0021] All SQL statements of the second statement type are identified as context information of SQL statements of the first statement type.
[0022] In an optional implementation, the target engine obtains the target execution result corresponding to the target SQL task by executing the target execution cluster in the following manner:
[0023] Determine the target execution relationship between the various SQL statements in the target execution cluster;
[0024] According to the target execution relationship, each of the SQL statements in the target execution cluster is executed to obtain the target execution result corresponding to the target SQL task.
[0025] In an optional implementation, before executing the steps of determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement when the SQL statement corresponding to the target SQL task is obtained, the method further includes:
[0026] Receive a target request sent by a client, the target request being used to instruct the execution of the target SQL task, the target request carrying a target token generated by an authentication server;
[0027] The target token is verified to obtain the verification result corresponding to the target token;
[0028] When the verification result indicates that the target token has been verified, the steps of determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement are executed when the SQL statement corresponding to the target SQL task is obtained.
[0029] Secondly, this application provides a task processing apparatus, comprising:
[0030] The determination module is used to determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement when the SQL statement corresponding to the target SQL task is obtained;
[0031] The determining module is further configured to determine the context information of the SQL statement when the target statement type is a first statement type, wherein the first statement type is used to indicate that the SQL statement is a statement that does not affect the environmental state.
[0032] The determining module is further configured to determine the execution cluster corresponding to the SQL statement based on the SQL statement and its preceding information;
[0033] The execution module is used to establish a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0034] Thirdly, this application provides a task execution system, including a client and a server;
[0035] The client is used to send the SQL statement corresponding to the target SQL task to the server.
[0036] The server is used to determine the context information of the SQL statement when the target statement type is a first statement type, wherein the first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state.
[0037] Based on the SQL statement and the information above, determine the execution cluster corresponding to the SQL statement;
[0038] A connection is established between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0039] Fourthly, this application provides a server, including a processor and a memory, wherein the processor is used to execute a task processing program stored in the memory to implement the task processing method described above.
[0040] Fifthly, this application also provides a storage medium storing one or more programs that can be executed by one or more processors to implement the task processing method described above.
[0041] Compared with the prior art, the technical solution provided in this application has the following advantages: The method provided in this application includes, when obtaining the SQL statement corresponding to the target SQL task, determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement; when the target statement type is a first statement type, determining the context information of the SQL statement, wherein the first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state; determining the target execution cluster corresponding to the SQL statement based on the SQL statement and its context information; and establishing a connection between the target execution cluster and the target engine so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task. Through the above method, this application analyzes the target statement type of the SQL statement corresponding to the submitted SQL task, so that when the target statement type is a type that does not affect the environment state, the SQL statement and its context information are processed into an execution cluster, and a connection is established between the execution cluster and the engine, thereby realizing the execution of the SQL task. This avoids establishing a connection between each SQL statement in the SQL task and the engine, reducing the load on the engine side and improving flexibility. Attached Figure Description
[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0045] Figure 1 A flowchart illustrating a task execution method provided in an embodiment of this application;
[0046] Figure 2 A flowchart illustrating another task execution method provided in an embodiment of this application;
[0047] Figure 3 This is a schematic diagram of the structure of a task execution device provided in an embodiment of this application;
[0048] Figure 4 This is a schematic diagram of the structure of a task execution system provided in an embodiment of this application;
[0049] Figure 5 This is a schematic diagram of the structure of a server provided in an embodiment of this application;
[0050] In the attached diagrams above:
[0051] 10. Determine the module; 20. Execute the module;
[0052] 100, server-side; 200, client-side;
[0053] 500. Server; 501. Processor; 502. Memory; 5021. Operating system; 5022. Application program; 503. User interface; 504. Network interface; 505. Bus system. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0055] The following disclosure provides numerous different embodiments or examples for implementing various structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of the invention. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0056] refer to Figure 1 , Figure 1 This is a flowchart illustrating a task execution method provided in an embodiment of this application. The task execution method provided in this application includes the following steps:
[0057] S101: When the SQL statement corresponding to the target SQL task is obtained, determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement.
[0058] In this embodiment, the execution entity is the server. Specifically, the execution entity of the task execution method is the engine entry point deployed on the server, and this engine entry point is located above the OLAP engine. OLAP engines include multiple engines such as Hive, Presto, Druid, Clickhouse, Kylin, SparkSQL, and Greeplum. The target engine is one of the multiple engines included in the OLAP engine. The aforementioned target SQL task can be developed by relevant personnel based on the client. The target SQL task consists of a set of SQL statements, which includes multiple SQL statements. After the relevant personnel complete the development of the target SQL task based on the client, the client establishes a connection with the engine entry point via JDBC. After establishing the connection, the client submits multiple SQL statements in the SQL statement set corresponding to the target task serially to the engine entry point according to the execution relationship between the SQL statements. The submitted target task also carries the target engine corresponding to the execution of the target task, so that the engine entry point submits the received SQL to the target engine in sequence, and the target engine executes the SQL statements to obtain the target execution result corresponding to the target SQL task.
[0059] More specifically, the traditional task execution method establishes a connection with the target engine for each received SQL statement when it is serially submitted by the client at the engine entry point. However, this method increases the load on the engine side and reduces flexibility. In reality, SQL statements can affect the environment state or they can affect computation (i.e., not the environment state). Typically, there is a contextual dependency between SQL statements affecting computation and those affecting the environment state. When executing a computation-affecting SQL statement, the computation-affecting SQL statement is usually executed only after the associated environment-affecting SQL statement has finished. Therefore, in this embodiment, when the engine entry point receives an SQL statement submitted by the client, it does not immediately establish a connection with the target engine for that SQL statement. Instead, by determining the target statement type corresponding to the SQL statement, a connection to the target engine is established based on the target statement type, thereby reducing the load on the engine side and improving flexibility.
[0060] In the above, the target statement type includes a first statement type and a second statement type. The first statement type indicates that the SQL statement does not affect the environment state, while the second statement type indicates that the SQL statement does affect the environment state. Statements that affect the environment state may include statements that set environment variables, load JAR files, create temporary functions, and switch database namespaces. Statements that affect computation (but not the environment state) may include query statements, update statements, delete statements, and insert statements.
[0061] S102: When the target statement type is the first statement type, determine the context information of the SQL statement.
[0062] S103: Determine the execution cluster corresponding to the SQL statement based on the SQL statement and its context.
[0063] Regarding steps S102 and S103, when the target statement type is the first statement type, since the execution of SQL statements of the first statement type depends on their context information, this embodiment, based on the above considerations, determines the method for establishing a connection between the SQL statement and the target engine to avoid establishing a connection with the target engine for each SQL statement. Therefore, when this embodiment determines that the target statement type is the first statement type, it determines the context information of the SQL statement to package the SQL statement and its context information, obtaining the target execution cluster corresponding to the SQL statement. A connection with the target engine is established through the target execution cluster, eliminating the need to establish a connection with the target engine for each SQL statement individually.
[0064] S104: Establish a connection between the target execution cluster and the target engine so that the target engine can execute the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0065] In this embodiment, after obtaining the target execution cluster, a connection can be established between the target execution cluster and the target engine. It is not necessary to establish a connection between each SQL statement in the target task and the target engine, significantly reducing the number of engine connections, decreasing the load on the engine side, and improving flexibility. Furthermore, after establishing a connection between the target execution cluster and the target engine, the target engine can execute the target execution cluster according to the execution relationships between the SQL statements within it. Since the target execution cluster is determined according to the execution relationships, after the target engine sequentially executes each execution cluster submitted by the service segment, the target execution result corresponding to the target SQL task can be obtained.
[0066] This embodiment provides a task execution method that analyzes the target statement type of the SQL statement corresponding to the submitted SQL task. When the target statement type is a non-environmentally affecting type, the SQL statement and its context information are processed into an execution cluster. A connection is established between the execution cluster and the engine to execute the SQL task. This avoids establishing a connection between each SQL statement in the SQL task and the engine, reduces the load on the engine side, and improves flexibility.
[0067] refer to Figure 2 , Figure 2 This is a flowchart illustrating a task execution method provided in an embodiment of this application. The task execution method provided in this application includes the following steps:
[0068] S201: When the SQL statement corresponding to the target SQL task is obtained, determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement.
[0069] In this embodiment, the method of obtaining the SQL statement corresponding to the target SQL task and determining the target engine corresponding to the target SQL task in step S201 is the same as in step S101. For details, please refer to the above description. In this embodiment, it will not be repeated here.
[0070] The above process of determining the target statement type corresponding to the SQL statement includes:
[0071] Convert SQL statements into abstract syntax trees.
[0072] Based on the abstract syntax tree, determine the target node type corresponding to the SQL statement.
[0073] Determine the target statement type corresponding to the SQL statement based on the target node type.
[0074] As described above, a parser can be used to convert the SQL statement into an abstract syntax tree (Abstract Syntax Tree). After obtaining the Abstract Syntax Tree, the target node type corresponding to the SQL statement can be determined based on the attributes of the root node. After obtaining the target node type, it can be determined whether the target statement type corresponding to the SQL statement is a first statement type or a second statement type.
[0075] In this embodiment, the target statement type corresponding to the SQL statement is determined based on the target node type, including:
[0076] Obtain the pre-established mapping relationship, which stores multiple sets of correspondences between node types and statement types;
[0077] Execute a query operation on the mapping relationship based on the target node type to obtain the target statement type corresponding to the target node type.
[0078] The mapping relationships are pre-defined and stored. After obtaining the target node type, since the mapping relationships store multiple correspondences between node types and statement types, a query operation can be performed on the mapping relationships based on the target node type to obtain the target statement type corresponding to the target node type. For example, when the target node type is "set," the statement type corresponding to the "set" type stored in the mapping relationships is the first statement type. Therefore, when the target node type is "set," a query operation can be performed on the mapping relationships to obtain the target statement type corresponding to this target node type as the first statement type.
[0079] Before obtaining the SQL statement corresponding to the target SQL task in step S201, the task execution method provided in this embodiment further includes the following steps:
[0080] Receive a target request sent by the client. The target request is used to instruct the execution of a target SQL task. The target request carries a target token, which is generated by the authentication server.
[0081] Verify the target token to obtain the verification result corresponding to the target token;
[0082] If the verification result indicates that the target token has been verified, execute the step of obtaining the SQL statement corresponding to the target SQL task.
[0083] In this embodiment, the authentication server generates a target token based on the username and password sent by the client. The authentication server then sends the generated target token to the client, enabling the client to authenticate with the server. After successful authentication, the client and server establish a connection. Once the connection is established, the client can sequentially submit the SQL statement corresponding to the target task to the server for processing.
[0084] S202: Determine whether the target statement type is the first statement type.
[0085] S203: When the target statement type is the second statement type, cache the SQL statement in the target memory.
[0086] In this embodiment, the SQL statements in the target SQL task often have context dependencies. That is, the first few SQL statements may be of the second statement type, for example, to set environment variables, load JAR packages, create temporary functions, switch database namespaces, etc. The first statement type SQL statement is executed only after the second statement type SQL statement is executed. Based on this, when a second statement type SQL statement is received from the client, a connection to the target engine is not directly established for it. Instead, it is cached in the target memory cache. When a first statement type SQL statement is received from the client, the context information related to the first statement type SQL statement (i.e., all second statement type SQL statements) can be retrieved from the target memory cache. The first statement type SQL statement and all second statement type SQL statements are packaged to obtain an execution cluster. Thus, in the above manner, all SQL statements in the target task can be divided into multiple target execution clusters. A connection is established between each target execution cluster and the target engine, so that the target engine executes each target execution cluster, ultimately determining the target execution result corresponding to the target task.
[0087] S204: When the target statement type is the first statement type, determine the context information of the SQL statement.
[0088] S205: Determine the target execution cluster corresponding to the SQL statement based on the SQL statement and its context.
[0089] S206: Establish a connection between the target execution cluster and the target engine so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0090] Regarding steps S204 to S206 above, step S204 determines the context information of the SQL statement, including:
[0091] Determine the target execution relationship corresponding to the SQL statement. The target execution relationship is used to characterize the execution order between SQL statements of the first statement type and SQL statements of the second statement type.
[0092] Based on the target execution relationship, determine all SQL statements of the second statement type that correspond to the SQL statements of the first statement type from the target memory;
[0093] The context information that identifies all SQL statements of type 2 as SQL statements of type 1.
[0094] In the above, the target execution relationship can be understood as the contextual relationship between SQL statements of the first statement type and SQL statements of the second statement type. Since the SQL statements are submitted to the server by the client according to the execution relationship between the various SQL statements in the target SQL task, when the SQL statement is of type 2, it is cached in the target memory. When the SQL statement is of type 1, since the SQL statements of type 2 preceding the SQL statement of type 1 have already been cached in the target memory, when the submitted SQL statement is of type 1, according to the target execution relationship corresponding to the SQL statement submitted by the client, all SQL statements of type 2 preceding the SQL statement can be retrieved from the target memory. Thus, the SQL statement is packaged with all the SQL statements of type 2 preceding the SQL statement to obtain the target execution cluster. After obtaining the target execution cluster, a connection is established between the target execution cluster and the target engine so that the target engine can execute the target execution cluster. It is not necessary to establish a connection for each SQL statement submitted by the client. In this way, all SQL statements in the target task can be divided into multiple target execution clusters. The target engine can execute the target task according to the order of the target execution clusters submitted by the server and the target execution relationship corresponding to each target execution cluster, thereby obtaining the target execution result corresponding to the target task.
[0095] In step S206 above, the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task in the following manner:
[0096] Determine the target execution relationships between the various SQL statements in the execution cluster;
[0097] Based on the target execution relationship, execute each SQL statement in the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0098] In this embodiment, since the target execution cluster is determined based on the target execution relationship, in order to ensure the accurate execution of the target task, after the target execution cluster is submitted to the target engine, the target engine can execute each SQL statement in the target execution cluster according to the target execution relationship, thereby ensuring the accurate execution of the target execution cluster and thus ensuring the accurate execution of the target task.
[0099] This embodiment provides a task execution method that analyzes the target statement type of the SQL statement corresponding to the submitted SQL task. When the target statement type is a non-environmentally affecting type, the SQL statement and its context information are processed into an execution cluster. A connection is established between the execution cluster and the engine to execute the SQL task. This avoids establishing a connection between each SQL statement in the SQL task and the engine, reduces the load on the engine side, and improves flexibility.
[0100] The following is an example illustrating the entire task execution process:
[0101] Step 1: The user develops an SQL task using the BI development platform, which is then scheduled to be executed at regular intervals. This SQL task includes loading JAR files, creating temporary functions, setting environment variables, and performing JOIN type queries.
[0102] Step 2: The scheduling platform integration entry client splits the complex SQL into a group of SQL and cleans up the comments. Then, it uses the JDBC interface to establish a connection with the engine entry. In this process, the Spark execution engine, the specific cluster, the authorization queue, and the relevant Spark configuration parameters are selected.
[0103] Step 3: When receiving SQL statements at the engine entry point, use Spark Parser to parse the SQL statements and transform them into an abstract syntax tree. For SQL statements that only affect the environment state, cache them in the task's memory cache. For SQL statements that do not affect the environment state, retrieve the SQL statements that affect the environment state mentioned above from the memory cache to form an execution cluster.
[0104] Step 4: Establish a connection between the execution cluster and the Spark engine.
[0105] Step 5: The Spark engine executes each SQL statement in the submitted execution cluster in sequence. If there are execution results, it constructs a result set and notifies the client that results have been returned.
[0106] Step 6: Collect the execution results (if any) on the client side and close the task connection with the server.
[0107] refer to Figure 3 , Figure 3This is a schematic diagram of a task execution device provided in an embodiment of this application. The task execution device provided in this embodiment includes a determining module 10 and an execution module 20. The determining module 10 is used to determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement when an SQL statement corresponding to a target SQL task is obtained; the determining module 10 is further used to determine the context information of the SQL statement when the target statement type is a first statement type, where the first statement type indicates that the SQL statement is a statement that does not affect the environment state; the determining module 10 is further used to determine the execution cluster corresponding to the SQL statement based on the SQL statement and its context information; the execution module 20 is used to establish a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0108] In this embodiment, the determining module 10 is further configured to:
[0109] Convert the SQL statement into an abstract syntax tree;
[0110] Based on the abstract syntax tree, determine the target node type corresponding to the SQL statement;
[0111] Based on the target node type, determine the target statement type corresponding to the SQL statement.
[0112] In this embodiment, the determining module 10 is further configured to:
[0113] Obtain the pre-established mapping relationship, which stores multiple sets of correspondences between node types and statement types;
[0114] A query operation is performed on the mapping relationship based on the target node type to obtain the target statement type corresponding to the target node type.
[0115] The task execution device provided in this embodiment further includes a caching module, which is used to cache the SQL statement in the target memory when the target statement type is a second statement type, wherein the second statement type is used to indicate that the SQL statement is a statement that affects the environment state.
[0116] In this embodiment, the determining module 10 is further configured to:
[0117] Determine the target execution relationship corresponding to the SQL statement, wherein the target execution relationship is used to characterize the execution order between the SQL statement of the first statement type and the SQL statement of the second statement type;
[0118] Based on the target execution relationship, determine from the target memory all SQL statements of the second statement type corresponding to the SQL statement of the first statement type;
[0119] All SQL statements of the second statement type are identified as context information of SQL statements of the first statement type.
[0120] In this embodiment, the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task in the following manner:
[0121] Determine the target execution relationship between the various SQL statements in the target execution cluster;
[0122] According to the target execution relationship, each of the SQL statements in the target execution cluster is executed to obtain the target execution result corresponding to the target SQL task.
[0123] In this embodiment, the determining module 10 is further configured to:
[0124] Receive a target request sent by a client, the target request being used to instruct the execution of the target SQL task, the target request carrying a target token generated by an authentication server;
[0125] The target token is verified to obtain the verification result corresponding to the target token;
[0126] When the verification result indicates that the target token has been verified, upon obtaining the SQL statement corresponding to the target SQL task, the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement are determined.
[0127] This embodiment provides a task execution device that analyzes the target statement type of the SQL statement corresponding to the submitted SQL task. When the target statement type is a non-environmentally affecting type, the SQL statement and its context information are processed into an execution cluster, and a connection is established between the execution cluster and the engine to execute the SQL task. This avoids establishing a connection between each SQL statement in the SQL task and the engine, reduces the load on the engine side, and improves flexibility.
[0128] Figure 4This is a schematic diagram of a task execution system provided in an embodiment of this application. The task execution system provided in this embodiment includes: a client 200 and a server 100. The client 200 is used to send an SQL statement corresponding to a target SQL task to the server. The server 100 is used to: determine the context information of the SQL statement when the target statement type is a first statement type, wherein the first statement type indicates that the SQL statement is a statement that does not affect the environment state; determine the execution cluster corresponding to the SQL statement based on the SQL statement and its context information; and establish a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0129] This embodiment provides a task execution system that analyzes the target statement type of the SQL statement corresponding to the submitted SQL task. When the target statement type is a non-environmentally affecting type, the SQL statement and its context information are processed into an execution cluster. A connection is established between the execution cluster and the engine to execute the SQL task. This avoids establishing a connection between each SQL statement in the SQL task and the engine, reduces the load on the engine side, and improves flexibility.
[0130] Figure 5 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Figure 5 The server 500 shown includes at least one processor 501, a memory 502, at least one network interface 504, and other user interfaces 503. The various components in the server 500 are coupled together via a bus system 505. It is understood that the bus system 505 is used to implement communication between these components. In addition to a data bus, the bus system 505 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 5 The general designated all buses as Bus System 505.
[0131] The user interface 503 may include a display, keyboard, or clicking device (e.g., mouse, trackball, touchpad, or touchscreen).
[0132] It is understood that the memory 502 in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DRRAM). The memory 502 described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0133] In some implementations, memory 502 stores elements, executable units or data structures, or subsets thereof, or extended sets thereof: operating system 5021 and application program 5022.
[0134] The operating system 5021 includes various system programs, such as the framework layer, core library layer, and driver layer, used to implement various basic business functions and handle hardware-based tasks. The application program 5022 includes various applications, such as a media player and a browser, used to implement various application functions. Programs implementing the methods of this application embodiment can be included in application program 5022.
[0135] In this embodiment, by calling the program or instructions stored in memory 502, specifically the program or instructions stored in application program 5022, processor 501 executes the method steps provided in each method embodiment, such as: when obtaining the SQL statement corresponding to the target SQL task, determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement; when the target statement type is a first statement type, determining the context information of the SQL statement, the first statement type being used to indicate that the SQL statement is a statement that does not affect the environmental state; determining the target execution cluster corresponding to the SQL statement based on the SQL statement and its context information; establishing a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0136] The methods disclosed in the embodiments of this application can be applied to or implemented by processor 501. Processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in processor 501 or by instructions in the form of software. The processor 501 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software units in the decoding processor. The software units may be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 502. Processor 501 reads the information in memory 502 and, in conjunction with its hardware, completes the steps of the above method.
[0137] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.
[0138] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.
[0139] The server provided in this embodiment can be as follows: Figure 5 The server shown can execute as follows: Figure 1-2 All steps of the task execution method are implemented to achieve Figure 1-2 For details on the technical effects of the task execution method shown, please refer to [link / reference]. Figure 1-2 The relevant descriptions are presented concisely and will not be elaborated upon here.
[0140] This application also provides a storage medium (computer-readable storage medium). This storage medium stores one or more programs. The storage medium may include volatile memory, such as random access memory; it may also include non-volatile memory, such as read-only memory, flash memory, hard disk, or solid-state drive; and it may also include combinations of the above types of memory.
[0141] When one or more programs in the storage medium can be executed by one or more processors to implement the task execution method described above that is executed on the task execution device side.
[0142] The processor is used to execute the task execution program stored in the memory to implement the following steps of the task execution method executed on the task execution device side: when the SQL statement corresponding to the target SQL task is obtained, the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement are determined; when the target statement type is a first statement type, the context information of the SQL statement is determined, the first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state; based on the SQL statement and its context information, the target execution cluster corresponding to the SQL statement is determined; a connection is established between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
[0143] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0144] It should be noted that the terms "one implementation," "embodiment," "exemplary embodiment," and "some embodiments" used in the specification indicate that the described embodiment may include a specific feature, structure, or characteristic, but not every embodiment necessarily includes that specific feature, structure, or characteristic. Furthermore, such phrases do not necessarily refer to the same embodiment. Moreover, when a specific feature, structure, or characteristic is described in connection with an embodiment, implementing such a feature, structure, or characteristic in conjunction with other embodiments, whether explicitly described or not, is within the knowledge scope of those skilled in the art.
[0145] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0146] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A task execution method, characterized in that, Applied to the server side, the method includes: When the SQL statement corresponding to the target SQL task is obtained, the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement are determined. When the target statement type is the second statement type, the SQL statement is cached in the target memory. The second statement type is used to indicate that the SQL statement is a statement that affects the environment state. The statements that affect the environment state include statements that set environment variables, statements that load JAR packages, statements that create temporary functions, and statements that switch database namespaces. When the target statement type is the first statement type, determine the context information of the SQL statement; Based on the SQL statement and the information above, determine the target execution cluster corresponding to the SQL statement; Establish a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task; The determination of the context information of the SQL statement includes: Determine the target execution relationship corresponding to the SQL statement. The target execution relationship is used to characterize the execution order between the SQL statement of the first statement type and the SQL statement of the second statement type. The first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state. The statements that do not affect the environment state include query statements, update statements, delete statements and add statements. Based on the target execution relationship, determine from the target memory all SQL statements of the second statement type corresponding to the SQL statement of the first statement type; All SQL statements of the second statement type are identified as context information of SQL statements of the first statement type.
2. The method according to claim 1, characterized in that, Determining the target statement type corresponding to the SQL statement includes: Convert the SQL statement into an abstract syntax tree; Based on the abstract syntax tree, determine the target node type corresponding to the SQL statement; Based on the target node type, determine the target statement type corresponding to the SQL statement.
3. The method according to claim 2, characterized in that, The step of determining the target statement type corresponding to the SQL statement based on the target node type includes: Obtain the pre-established mapping relationship, which stores multiple sets of correspondences between node types and statement types; A query operation is performed on the mapping relationship based on the target node type to obtain the target statement type corresponding to the target node type.
4. The method according to claim 1, characterized in that, The target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task in the following manner: Determine the target execution relationship between the various SQL statements in the target execution cluster; According to the target execution relationship, each of the SQL statements in the target execution cluster is executed to obtain the target execution result corresponding to the target SQL task.
5. The method according to claim 1, characterized in that, Before executing the steps of determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement when obtaining the SQL statement corresponding to the target SQL task, the method further includes: Receive a target request sent by a client, the target request being used to instruct the execution of the target SQL task, the target request carrying a target token generated by an authentication server; The target token is verified to obtain the verification result corresponding to the target token; When the verification result indicates that the target token has been verified, the steps of determining the target engine corresponding to the target SQL task and determining the target statement type corresponding to the SQL statement are executed when the SQL statement corresponding to the target SQL task is obtained.
6. A task execution device, characterized in that, include: The determination module is used to determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement when the SQL statement corresponding to the target SQL task is obtained; The caching module is used to cache the SQL statement in the target memory when the target statement type is the second statement type. The second statement type is used to indicate that the SQL statement is a statement that affects the environment state. The statements that affect the environment state include statements that set environment variables, statements that load JAR packages, statements that create temporary functions, and statements that switch database namespaces. The determining module is further configured to determine the context information of the SQL statement when the target statement type is a first statement type. The first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state. The statement that does not affect the environment state includes query statements, update statements, delete statements and add statements. The determining module is further configured to determine the target execution relationship corresponding to the SQL statement when the target statement type is a first statement type, wherein the target execution relationship is used to characterize the execution order between the SQL statement of the first statement type and the SQL statement of the second statement type; Based on the target execution relationship, determine from the target memory all SQL statements of the second statement type corresponding to the SQL statement of the first statement type; All SQL statements of the second statement type are identified as the context information of the SQL statements of the first statement type; The determining module is further configured to determine the target execution cluster corresponding to the SQL statement based on the SQL statement and its preceding information; The execution module is used to establish a connection between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
7. A task execution system, characterized in that, This includes both the client and server sides; The client is used to send the SQL statement corresponding to the target SQL task to the server. The server is used to determine the target engine corresponding to the target SQL task and the target statement type corresponding to the SQL statement when it obtains the SQL statement corresponding to the target SQL task. When the target statement type is the second statement type, the SQL statement is cached in the target memory. The second statement type is used to indicate that the SQL statement is a statement that affects the environment state. The statements that affect the environment state include statements that set environment variables, statements that load JAR packages, statements that create temporary functions, and statements that switch database namespaces. When the target statement type is a first statement type, the target execution relationship corresponding to the SQL statement is determined. The target execution relationship is used to characterize the execution order between the SQL statement of the first statement type and the SQL statement of the second statement type. The first statement type is used to indicate that the SQL statement is a statement that does not affect the environment state. The statements that do not affect the environment state include query statements, update statements, delete statements and add statements. Based on the target execution relationship, determine from the target memory all SQL statements of the second statement type corresponding to the SQL statement of the first statement type; All SQL statements of the second statement type are identified as the context information of the SQL statements of the first statement type; Based on the SQL statement and the information above, determine the target execution cluster corresponding to the SQL statement; A connection is established between the target execution cluster and the target engine, so that the target engine executes the target execution cluster to obtain the target execution result corresponding to the target SQL task.
8. A server, comprising: A processor and a memory, the processor being configured to execute a task execution program stored in the memory to implement the task execution method according to any one of claims 1 to 5.
9. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the task execution method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Processing method and device of data in HBase
CN108334506A
Database supporting mixed load based on multiple storage engines and data processing method
CN116561119A