Methods, apparatus, devices, and storage media for executing Structured Query Language statements

By overloading the original function during SQL statement execution, the problem of SQL statement execution errors caused by differences in function definitions across different databases is solved, reducing user costs and improving SQL statement execution efficiency.

CN117131064BActive Publication Date: 2025-10-28HANGZHOU HIKVISION SYST TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311016434.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-11
Publication Date
2025-10-28
Estimated Expiration
2043-08-11

AI Technical Summary

Technical Problem

In existing technologies, when users use a unified SQL analysis system, they need to deal with the function definitions and implementations of different databases. There may be differences in function definitions and implementations when executing SQL statements, which may lead to query errors. Existing technologies cannot effectively solve the problem that users need to understand the function definitions of each database when executing SQL statements, which increases the cost of use.

Method used

By performing function overloading on the original function during SQL statement execution, the function information of the original function is determined, and matching SQL functions are selected from the target SQL function library. This reduces the user's familiarity with each SQL function library and enables automatic matching and execution of SQL functions.

Benefits of technology

This reduces the user's familiarity with each SQL function library, lowers the user's usage cost, and improves the execution efficiency and correctness of SQL statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117131064B_ABST
    Figure CN117131064B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, device, and storage medium for executing Structured Query Language (SQL) statements, relating to the field of big data processing technology. The execution method includes: receiving a SQL statement; executing the SQL statement; and, during the execution of the SQL statement, performing a function overloading operation on the original function to obtain the corresponding SQL function. The function overloading operation includes: determining the function information of the original function; filtering out SQL functions matching the function information from a target SQL function library; determining a target SQL function based on the SQL function corresponding to the original function, and updating the original function based on the target SQL function; and executing the updated original function. The execution method provided by this application allows users to write SQL statements without needing to be familiar with specific functions in various function libraries, as functions defined in other function libraries can be used for SQL execution, thus reducing user costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of big data processing technology, and in particular to a method, apparatus, device, and storage medium for executing structured query language statements. Background Technology

[0002] With the rapid development of big data technology, the components and services for underlying data storage are also increasing, such as common relational databases: Oracle, MySQL, SQL Server, PostgreSQL, DB2, etc. Unified Structured Query Language (SQL) analysis can provide an entry point for computation and analysis of multiple data sources through the unified SQL syntax of industry-standard SQL. Unified SQL analysis technology effectively solves the problem of differences in SQL syntax among different data sources.

[0003] However, different databases may have different definitions and implementations of the same function. If a function in the SQL statement after unified SQL transformation does not have a corresponding definition in the database product, it will cause a query error. In other words, when using a unified SQL analysis system to query a specific data source, users need to understand not only the syntax of the function in general SQL, but also the definition of the function in that data source to ensure that the SQL statement is executed correctly after it is issued. This increases the user's usage cost to some extent. Summary of the Invention

[0004] This application provides a method, apparatus, device, and storage medium for executing Structured Query Language statements, which matches the most suitable SQL function during SQL statement execution and performs the execution, so that users do not need to fully understand the SQL functions in each function library, thus reducing the user's usage cost.

[0005] The first aspect of this application provides a method for executing a Structured Query Language (SQL) statement, comprising: receiving a SQL statement; executing the SQL statement, the SQL statement including at least one original function; during the execution of the SQL statement, performing a function overloading operation on the original function to obtain an SQL function corresponding to the original function; the function overloading operation includes: determining the function information of the original function; filtering out SQL functions matching the function information in a target SQL function library; determining a target SQL function based on the SQL function corresponding to the original function, and updating the original function based on the target SQL function; and executing the updated original function.

[0006] The SQL statement execution method provided in this application performs function overloading on the original function in the SQL statement to obtain the corresponding SQL function. Since users may not be familiar with all SQL functions in all SQL function libraries when writing SQL statements, function overloading eliminates the need for users to be familiar with specific functions in each SQL function library. As long as the original function is defined in another function library, a matching SQL function can be obtained. A target SQL function is selected from the SQL functions corresponding to the original function, and the original function is updated based on the target SQL function for execution. In this way, users do not need to be familiar with specific functions in each SQL function library when writing SQL statements; as long as a corresponding function is defined in another function library, it can be automatically matched for SQL execution, reducing the user's usage cost.

[0007] Combining the first implementation method of the first aspect, the target SQL function is determined based on the SQL function corresponding to the original function, including: selecting the target SQL function from the SQL functions corresponding to the original function based on the priority of the SQL function library to which the SQL function belongs; the SQL function library includes: the current data source function library, the standard function library, and other data source function libraries, with the priority of the current data source function library being higher than the priority of the standard function library, and the priority of the standard function library being higher than the priority of other data source function libraries; each data source corresponds to one SQL function library; the current data source function library is the SQL function library of the data source corresponding to the SQL statement.

[0008] Combining the second implementation method of the first aspect, when function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library.

[0009] In conjunction with the third implementation method of the first aspect, before receiving the Structured Query Language (SQL) statement, the execution method further includes: responding to the user's operation of enabling function pushdown, outputting prompt information, which is used to prompt the user to select the target SQL function library from the current data source function library and the standard function library.

[0010] In conjunction with the fourth implementation method of the first aspect, the function information includes: function name, function syntax, number of function parameters, function parameter types, and function category.

[0011] In conjunction with the fifth implementation method of the first aspect, the execution method also includes: defining each SQL function in the SQL function library so that each SQL function corresponds to a function information.

[0012] A second aspect of this application provides an execution apparatus for a Structured Query Language (SQL) statement, comprising: a receiving module for receiving a SQL statement; an execution module for executing the SQL statement, the SQL statement including at least one original function; an overloading module for performing function overloading operations on the original function during the execution of the SQL statement to obtain an SQL function corresponding to the original function; the function overloading operation includes: determining function information of the original function; filtering out SQL functions matching the function information from a target SQL function library; a determining module for determining a target SQL function based on the SQL function corresponding to the original function, and updating the original function based on the target SQL function; and the execution module further comprising executing the updated original function.

[0013] Combining the first implementation method of the second aspect, the module is specifically used to select the target SQL function from the SQL functions corresponding to the original function based on the priority of the SQL function library to which the SQL function belongs. The SQL function library includes: the current data source function library, the standard function library, and other data source function libraries. The priority of the current data source function library is higher than the priority of the standard function library, and the priority of the standard function library is higher than the priority of other data source function libraries. Each data source corresponds to one SQL function library. The current data source function library is the SQL function library of the data source corresponding to the SQL statement.

[0014] When function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library;

[0015] The execution device also includes: an output module, used to output a prompt message when the user enables function pushdown, the prompt message being used to prompt the user to select the target SQL function library from the current data source function library and the standard function library;

[0016] Function information includes: function name, function syntax, number of function parameters, parameter types, and function category;

[0017] The execution device also includes a definition module, which defines each SQL function in the SQL function library so that each SQL function corresponds to a function information.

[0018] A third aspect of this application provides an electronic device, including: one or more processors; one or more memories; wherein the one or more memories are used to store computer program code, the computer program code including computer instructions, and when the one or more processors execute the computer instructions, the electronic device performs the above-described execution method.

[0019] A fourth aspect of this application provides a computer-readable storage medium storing computer-executable instructions that, when executed on a computer, cause the computer to perform the aforementioned execution method.

[0020] The beneficial effects described in aspects two through four can be referred to the analysis of the beneficial effects in aspect one, and will not be repeated here. Attached Figure Description

[0021] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of the present invention and do not constitute a limitation on the technical solutions of the present invention.

[0022] Figure 1 A system architecture diagram of a unified SQL analysis system with multiple data sources provided in this application embodiment;

[0023] Figure 2 A flowchart of a unified SQL analysis system for multiple data sources provided in this application embodiment;

[0024] Figure 3 A method flow for executing SQL statements provided in this application embodiment Figure 1 ;

[0025] Figure 4 A method flow for executing SQL statements provided in this application embodiment Figure 2 ;

[0026] Figure 5 A method flow for executing SQL statements provided in this application embodiment Figure 3 ;

[0027] Figure 6 A method flow for executing SQL statements provided in this application embodiment Figure 4 ;

[0028] Figure 7 This is a schematic diagram of the structure of an execution device provided in an embodiment of this application;

[0029] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0030] 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, and 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.

[0031] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0032] In the description of this application, it should be noted that, unless otherwise expressly specified and limited, the terms "connected" and "linked" should be interpreted broadly, for example, as a fixed connection, a detachable connection, or an integral connection. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances. Furthermore, when describing pipelines, the terms "connected" and "linked" as used in this application have the meaning of establishing electrical connection. The specific meaning needs to be understood in conjunction with the context.

[0033] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0034] As described in the background section, Unified SQL Analysis provides an entry point for computational analysis of various data sources through industry-standard unified SQL syntax. Unified SQL Analysis technology effectively solves the problem of differences in SQL syntax among different data sources.

[0035] However, different databases may have different definitions and implementations of the same function. If a function in the SQL statement, after being converted to standard SQL, is not defined in the database product, it will cause a query error. Take the definition of the string concatenation function CONCAT in different databases as an example:

[0036] Oracle: The syntax is CONCAT(str1,str2), which only supports receiving two string parameters. It returns NULL if and only if both parameters are NULL; otherwise, NULL is treated as an empty string.

[0037] SQL Server: The syntax is CONCAT(str1,str2[,strN]*), which accepts 2-254 parameters. NULL values ​​are treated as empty strings, meaning that NULL results are never returned.

[0038] MySQL: The syntax is CONCAT(str1[,strN]*), which accepts at least one string parameter and returns NULL if any parameter contains a NULL value.

[0039] PostgreSQL: The syntax is CONCAT(str1[,strN]*), which accepts at least one string parameter. NULL values ​​are treated as empty strings and never return NULL results.

[0040] The string concatenation function CONCAT, which performs the same function, varies across different database products in terms of the number of parameters, the logic for handling NULL values, and the return value. When users use the unified SQL analysis entry to query a specific data source, in addition to mastering the syntax of the function in general SQL, they also need to understand the definition of the function in that data source to ensure that the SQL is executed correctly after it is issued. This increases the user's usage cost to some extent.

[0041] Based on this, this application provides a method for executing Structured Query Language (SQL) statements. When executing the original function in an SQL statement, a function overloading operation is performed on the original function to obtain the corresponding SQL function; the corresponding SQL function is then used as the original function. The function overloading operation includes: determining the function information of the original function; and filtering out SQL functions matching the function information from a target SQL function library. In other words, function overloading is performed based on the user-inputted original function, and SQL functions matching the original function are filtered out for execution. In this way, users do not need to be familiar with specific functions in various function libraries; functions with corresponding definitions in other function libraries can be automatically matched for SQL statement execution, reducing the user's usage cost.

[0042] It should be understood that the structured query language statement execution method provided in this application is applicable to electronic devices including unified SQL analysis systems (or platforms) with multiple data sources. The electronic device can be a terminal device, such as a personal computer (PC), laptop computer, mobile device, tablet computer, etc. Alternatively, the electronic device can be a single server or a server cluster consisting of multiple servers; in some implementations, the server cluster can be a distributed cluster server. This application does not limit the specific form of the electronic device.

[0043] Please see Figure 1 The method for executing structured query language statements provided in this application embodiment is applicable to... Figure 1 The multi-data source unified SQL analysis system 10 (or platform) shown includes: a query general configuration module 101, a function library definition module 102, a function library loading module 103, a function overloading module 104, and a function matching module 105.

[0044] The query general configuration module 101 is a global configuration item for SQL request processing. In this application, it mainly includes two items: the SQL function library specified for the current query and whether the SQL function is pushed down.

[0045] It should be understood that the unified SQL analysis system includes SQL function libraries corresponding to each data source and a standard SQL function library (meeting industrial-grade SQL standards). Users can specify the target SQL function library in the SQL function library corresponding to each data source and the standard SQL function library. During execution, functions that match the original function will be selected from the target SQL function library.

[0046] Function pushdown is an optimization technique used to improve query performance. It refers to applying functions at the database level, rather than processing them at the application level. When using SQL queries, if the query conditions contain a function, such as aggregate functions like SUM(), AVG(), or COUNT(), the traditional approach is to first retrieve all the data and then perform the function calculation on the results in the application. However, through function pushdown optimization, the database system can postpone the calculation of these aggregate functions to the database level, thus reducing data transfer and processing time and improving query efficiency.

[0047] Users can specify the target SQL function library to be filtered and choose whether the SQL function is pushed down in the query general configuration module 101.

[0048] The function library definition module 102 is used to define functions in all function libraries. Since various data sources generally support functions outside the SQL standard, and some functions with the same name differ from those defined in the standard SQL function library (such as the CONCAT function in the example above), these functions need to be defined in the function library to distinguish them.

[0049] The definition of a function mainly includes several aspects: the library to which the function belongs (such as Oracle-Library, SqlServer-Library, MySQL-Library, etc.), the function category (each function contains a category parameter, which defaults to OTHER_FUNCTION), the function syntax (such as BINARY, PREFIX, etc.), the function name, the parameter types (such as String, Integer, Double, etc.), the number of parameters, and the return value type. These are all important references for subsequent function overloading steps.

[0050] The function library loading module 103 is used to load the target SQL function library specified in the query general configuration module 101 into the memory of the unified SQL analysis system.

[0051] As a feasible implementation, the target SQL function library is stored using a hash map (HashMap). A HashMap is a hash table that stores key-value pairs. In this embodiment, the key is uniquely identified by the defined function name and function syntax, and the value represents the function object.

[0052] The function overloading module 104 is used to perform function overloading operations on the original function when executing the original function, so as to obtain the SQL function corresponding to the original function.

[0053] It should be understood that after an SQL statement is parsed and validated, an abstract syntax tree (AST) is typically obtained, and each original function in the SQL statement is a node in the syntax tree. When processing nodes in the AST, based on the functions already loaded in the function library loading module 103, a function overloading operation is performed to obtain the SQL function corresponding to the original function. Since the original function may correspond to multiple SQL functions, the SQL functions obtained by the function overloading module 104 can be placed into an SQL function set to obtain the SQL function set corresponding to the original function.

[0054] The function matching module 105 is used to match the most suitable SQL function to the set of SQL functions obtained from the function overloading module 104. If the match is successful, the matched SQL function is executed directly; if the match fails, the execution of the current SQL statement is terminated directly and the corresponding exception information is thrown.

[0055] It should be noted that if the user has enabled function pushdown, it means that the current function needs to be executed in the underlying data source. Therefore, the matched SQL function can only be a function in the function library or standard function library corresponding to that data source.

[0056] Therefore, as a feasible implementation method, it can be set in the query general configuration module 101. If the user chooses to enable function pushdown, then the user can only specify from the function library and standard function library corresponding to the data source. In this way, all SQL functions in the SQL function set obtained by the function overload module 104 can be pushed down.

[0057] As another feasible implementation, function matching module 105 can perform function matching based on whether the user has enabled function pushdown. If the user has enabled function pushdown, the SQL function matching module 105 needs to search for SQL functions belonging to the function library and standard function library corresponding to the current data source from the SQL function set. If they exist, the function is pushed down; otherwise, an SQL execution exception is thrown. If the user has not enabled function pushdown, the function matching module 105 retrieves the SQL functions from the SQL function set in a specific order (current data source function library, standard function library, other data source function libraries) and executes them in the unified SQL analysis layer.

[0058] In some embodiments, please refer to Figure 2 The unified SQL analysis system for multiple data sources provided in this application embodiment has the following overall process when executing SQL statements: Figure 2 As shown, it includes:

[0059] S201, Function library loading module 103 loads the function library specified by the user in the query general configuration module from the function definition module into the memory of the unified SQL analysis system.

[0060] S202, The function overloading module 104 selects SQL functions that match the function information of the original functions in the SQL statement from the loaded functions to obtain a function set.

[0061] S203, Function matching module 105 determines the target SQL function from the function set based on whether the user has enabled function pushdown.

[0062] S204. Execute the target SQL function.

[0063] It should be noted that the system architecture described in the above embodiments is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, but does not constitute a limitation on the technical solutions provided by the embodiments of this application. In other embodiments, the system may include fewer or more components than shown in the figures, or combine certain components, or have different component arrangements, and the embodiments of this application do not impose any limitations in this regard.

[0064] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0065] Figure 3The diagram shows a method flowchart for executing an SQL statement according to an embodiment of this application. Please refer to [link / reference]. Figure 3 The SQL statement execution method provided in this application includes the following steps:

[0066] S301, Receive SQL statements.

[0067] The SQL statement includes at least one primitive function.

[0068] When a user-edited SQL statement is received, it needs to be parsed and validated to obtain an Abstract Syntax Tree (AST). An AST is an abstract representation of the syntax structure of an SQL statement (source code). It represents the syntax structure of the SQL statement in a tree-like form, with each node in the AST representing a primitive function in the SQL statement.

[0069] S302, Execute SQL statements.

[0070] In the embodiments of this application, please refer to Figure 4 During the execution of the SQL statement, S401-S403 need to be executed for each node in the AST, that is, for each primitive function in the SQL statement:

[0071] S401. Perform function overloading to obtain the SQL function corresponding to the original function.

[0072] In the embodiments of this application, please refer to Figure 5 Function overloading involves the following steps:

[0073] S501. Determine the function information of the original function.

[0074] As a feasible implementation method, function information includes, but is not limited to: function name, function syntax, number of function parameters, function parameter types, and function category.

[0075] S502. In the target SQL function library, filter out the SQL functions that match the function information.

[0076] It should be understood that the unified SQL analysis system includes SQL function libraries corresponding to each data source and a standard SQL function library.

[0077] As a feasible approach, before using SQL statements to perform queries, users can specify the target SQL function library in the SQL function library corresponding to each data source and the standard SQL function library. During execution, functions that match the original function will be selected from the target SQL function library.

[0078] If the user does not specify, as a feasible approach, the standard SQL function library can be used as the target SQL function library.

[0079] In some embodiments, function information includes: function name, function syntax, number of function parameters, function parameter types, and function category. Since there are relatively few functions with the same name across multiple SQL function libraries, filtering can be prioritized based on function name, thus avoiding wasting algorithmic resources in subsequent steps.

[0080] As one feasible approach, please refer to Figure 6 When filtering SQL functions that match the function information, you can follow these steps:

[0081] S601. From the target SQL function library, filter by function name and function syntax to obtain a function set.

[0082] In other words, from the target SQL function library, the function names and function syntax are filtered out, and the SQL functions whose names and function syntax match the function information are obtained to form a function set.

[0083] S602. Based on the number of function parameters in the function information, remove functions from the function set whose number of function parameters does not match.

[0084] In the function set, delete SQL functions whose number of function parameters differs from the number of function parameters in the function information.

[0085] S603. Based on the function parameter types in the function information, remove functions from the function set whose function parameter types do not match.

[0086] In the function collection, delete SQL functions whose parameter types differ from the parameter types in the function information.

[0087] S604. Based on the function category in the function information, remove functions from the function set whose function categories do not match.

[0088] Within the function set, delete SQL functions whose function category differs from the function category specified in the function information. This results in a function set where all SQL functions match the function information of the original functions.

[0089] It should be understood that Figure 6 This is merely an example illustrating one implementation of an SQL function that filters for matching function information, and is not intended to be limiting.

[0090] S402. Determine the target SQL function based on the SQL function corresponding to the original function, and update the original function based on the target SQL function.

[0091] Because function overloading results in the original function potentially corresponding to multiple SQL functions, and the function information of each SQL function matches that of the original function, but only one SQL function can be executed at a time, a target SQL function needs to be determined.

[0092] Therefore, as a feasible implementation method, the target SQL function can be any SQL function among the SQL functions corresponding to the original function.

[0093] As another feasible approach, since query performance is best for each data source using its corresponding SQL function library, the target SQL function can be selected from the SQL functions corresponding to the original function based on the priority of the SQL function library to which the SQL function belongs.

[0094] For example, since a unified SQL analysis system includes SQL function libraries corresponding to each data source and a standard SQL function library, as a feasible implementation approach, the SQL function libraries can be divided into three categories: the current data source function library, the standard function library, and other data source function libraries. It should be understood that the current data source function library is the SQL function library corresponding to the data source from which the SQL statement needs to be executed; the standard function library is the standard SQL function library that meets industry-grade SQL standards; and the other data source function libraries are those other than the current data source function library and the standard function library among the multiple SQL function libraries.

[0095] Since the query performance is best for each data source using its corresponding SQL function library, the current data source function library has a higher priority than the standard function library, and the standard function library has a higher priority than other data source function libraries.

[0096] In other words, based on the priority of the SQL function library to which the SQL function belongs, the target SQL function with higher priority is selected from the SQL functions corresponding to the original function. That is, the SQL function is selected from the set of functions obtained by function overloading in a specific order (current data source function library, standard function library, other data source function libraries).

[0097] For example, if the SQL function obtained by function overloading belongs to the function libraries corresponding to Oracle and MySQL respectively, and the data source to be queried by the SQL statement is MySQL, then the SQL function in the function library corresponding to MySQL is selected as the target SQL function.

[0098] Based on the priority of the SQL function library to which the SQL function belongs, the target SQL function is selected from the SQL functions corresponding to the original function. The resulting SQL function is the SQL function with the best query performance in the current data source, thus achieving high execution efficiency when executing the SQL function.

[0099] After obtaining the target SQL function, the original function is updated based on the target SQL function. This avoids errors in the original function when the user writes the SQL statement, which could lead to execution exceptions.

[0100] S403, Execute the updated original function.

[0101] The updated original function is executed, which is based on the target SQL function. Since the target SQL function is determined based on a pre-set target SQL function library, there will be no writing errors. Therefore, it can avoid the problem of writing SQL statements by users and reduce the user's usage cost.

[0102] The SQL statement execution method provided in this application performs function overloading on the original function when executing the SQL statement, obtaining the corresponding SQL function. Since users may not be familiar with all SQL functions in the SQL function library when writing SQL statements, function overloading selects the target SQL function based on the original function and updates the original function accordingly. Thus, when the original function is executed, it is actually executed based on the target SQL function in the SQL function library, avoiding the problem of users being unfamiliar with all SQL functions in the library and reducing the user's usage cost.

[0103] In some embodiments, function pushdown can apply functions to the database layer, reducing data transfer and processing time and improving query efficiency. Therefore, users may enable function pushdown when executing SQL statements to improve query efficiency.

[0104] Function pushdown applies functions to the database level, rather than processing them at the application level. It allows the database system to leverage the underlying query execution engine and query optimizer to handle function computations. These engines and optimizers are typically optimized for specific database structures and data distributions, resulting in more efficient function operations.

[0105] However, not all functions can be pushed down. Only functions that can perform calculations at the database level can be optimized for function pushdown. For the data source corresponding to the SQL statement (the current data source), only SQL functions in the current data source function library and the standard function library can be pushed down. Therefore, when a user enables function pushdown, the target SQL function can only be an SQL function in the current data source function library or the standard function library.

[0106] As a feasible implementation method, when function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library.

[0107] In other words, when function pushdown is enabled, when determining the target SQL function based on the SQL function corresponding to the original function, only SQL functions in the current data source function library or the standard function library are identified as the target SQL function. For example, when function pushdown is enabled, SQL functions belonging to the current data source function library and the standard function library are found from the function set obtained from function overloading. The SQL functions obtained in this way can be pushed down for processing, thereby executing function operations more efficiently.

[0108] As another feasible implementation method, before receiving the Structured Query Language (SQL) statement, the execution method also includes: in response to the user's operation of enabling function pushdown, outputting prompt information.

[0109] The prompt message is used to suggest selecting the target SQL function library from the current data source function library and the standard function library.

[0110] In other words, when a user enables function pushdown, the user is prompted that the target SQL function library can only be specified in the current data source function library and the standard function library. After function overloading, the resulting SQL function can be pushed down, meaning that it can be used as the target SQL function, thus enabling more efficient execution of function operations.

[0111] For example, if a user does not enable function pushdown to look up Oracle tables, and the function library specifies Oracle and MySQL, after function overloading, only the SQL function defined in the MySQL function library meets the matching requirements. In this case, the SQL function in the MySQL function library will be used for calculation in the unified SQL analysis layer.

[0112] In some embodiments, some functions with the same name in multiple SQL function libraries have different definitions from those in the standard function library (such as the CONCAT function mentioned above). These functions need to be defined in the SQL function library to distinguish them.

[0113] Therefore, as a feasible implementation method, the SQL statement execution method provided in this application embodiment further includes: defining each SQL function in the SQL function library so that each SQL function corresponds to a function information.

[0114] As a feasible implementation method, the definition of a function mainly includes the following aspects: the library to which the function belongs (such as Oracle-Library, SqlServer-Library, MySQL-Library, etc.), the function category (each function contains a category parameter, which defaults to OTHER_FUNCTION), the function syntax (such as BINARY, PREFIX, etc.), the function name, the parameter type (such as String, Integer, Double, etc.), the number of parameters, and the return value type.

[0115] By defining SQL functions so that each SQL function corresponds to a function information, a reliable filtering basis can be provided for function overloading operations, making the results of function overloading more accurate.

[0116] This application also provides an execution device for Structured Query Language statements. Please refer to [link to relevant documentation]. Figure 7 The execution device 70 includes: a receiving module 71 for receiving a Structured Query Language (SQL) statement; an execution module 72 for executing the SQL statement, the SQL statement including at least one original function; an overloading module 73 for performing function overloading operations on the original function during the execution of the SQL statement to obtain the SQL function corresponding to the original function; the function overloading operation includes: determining the function information of the original function; filtering out SQL functions that match the function information in a target SQL function library; a determining module 74 for determining a target SQL function based on the SQL function corresponding to the original function, and updating the original function based on the target SQL function; and the execution module 72 is also used to execute the updated original function.

[0117] As a feasible implementation method, the module is specifically used to select the target SQL function from the SQL functions corresponding to the original function based on the priority of the SQL function library to which the SQL function belongs. The SQL function library includes: the current data source function library, the standard function library, and other data source function libraries. The priority of the current data source function library is higher than the priority of the standard function library, and the priority of the standard function library is higher than the priority of other data source function libraries. Each data source corresponds to one SQL function library. The current data source function library is the SQL function library of the data source corresponding to the SQL statement.

[0118] As a feasible implementation method, when function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library.

[0119] As a feasible implementation method, the execution device also includes: an output module, used to output prompt information when the user enables function pushdown, the prompt information being used to prompt the user to select the target SQL function library from the current data source function library and the standard function library.

[0120] As a feasible implementation method, function information includes: function name, function syntax, number of function parameters, function parameter types, and function category.

[0121] As a feasible implementation method, the execution device also includes: a definition module, which is used to define each SQL function in the SQL function library, so that each SQL function corresponds to a function information.

[0122] This application also provides an electronic device; please refer to [link / reference]. Figure 8 The electronic device 80 includes: one or more memories 81; one or more processors 82, wherein the one or more memories 81 are used to store computer program code, the computer program code including computer instructions; when the one or more processors 82 execute the computer instructions, the electronic device 80 performs the method provided in the above embodiments.

[0123] Optionally, the memory 81 may be a non-transitory computer-readable storage medium, such as a read-only memory (ROM), random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. This application embodiment does not impose any restrictions on this.

[0124] The processor 82 may be a central processing unit (CPU), a general-purpose processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof, and the embodiments of this application do not impose any limitations on this.

[0125] This application also provides a computer program product comprising one or more instructions, which are stored in the memory of a computer device and executed by a processor to complete the various processes described in the above embodiments.

[0126] This application also provides a computer-readable storage medium, which includes computer-executable instructions that, when executed on a computer, cause the computer to perform the method provided in the above embodiments.

[0127] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0128] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0129] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0130] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0131] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, etc.) or a processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0132] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for executing a Structured Query Language statement, characterized in that, include: Receives Structured Query Language (SQL) statements; Execute the SQL statement, which includes at least one primitive function; During the execution of the SQL statement, the original function is overloaded to obtain the corresponding SQL function. The function overloading operation includes: determining the function information of the original function; and filtering out SQL functions that match the function information from the target SQL function library. The target SQL function is determined based on the SQL function corresponding to the original function, and the original function is updated based on the target SQL function; Execute the updated original function.

2. The execution method according to claim 1, characterized in that, The step of determining the target SQL function based on the SQL function corresponding to the original function includes: Based on the priority of the SQL function library to which the SQL function belongs, the target SQL function is selected from the SQL functions corresponding to the original function; the SQL function library includes: the current data source function library, the standard function library, and other data source function libraries, wherein the priority of the current data source function library is greater than the priority of the standard function library, and the priority of the standard function library is greater than the priority of the other data source function libraries; each data source corresponds to one SQL function library; the current data source function library is the SQL function library of the data source corresponding to the SQL statement.

3. The execution method according to claim 2, characterized in that, When function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library.

4. The execution method according to claim 1, characterized in that, Before receiving the Structured Query Language (SQL) statement, the execution method further includes: In response to the user's operation of enabling function pushdown, a prompt message is output, which prompts the user to select the target SQL function library from the current data source function library and the standard function library.

5. The execution method according to any one of claims 1-4, characterized in that, The function information includes: function name, function syntax, number of function parameters, function parameter types, and function category.

6. The execution method according to claim 5, characterized in that, The execution method further includes: Each SQL function in the SQL function library is defined such that each SQL function corresponds to a set of function information.

7. An execution device for a Structured Query Language statement, characterized in that, include: The receiving module is used to receive Structured Query Language (SQL) statements. An execution module is used to execute the SQL statement, which includes at least one primitive function; The overloading module is used to perform function overloading operations on the original function during the execution of the SQL statement, so as to obtain the SQL function corresponding to the original function; The function overloading operation includes: determining the function information of the original function; and filtering out SQL functions that match the function information from the target SQL function library. The determination module is used to determine the target SQL function based on the SQL function corresponding to the original function, and update the original function based on the target SQL function; The execution module is also used to execute the updated original function.

8. The actuator according to claim 7, characterized in that, The determining module is specifically used to select the target SQL function from the SQL functions corresponding to the original function based on the priority of the SQL function library to which the SQL function belongs; the SQL function library includes: the current data source function library, the standard function library, and other data source function libraries, wherein the priority of the current data source function library is greater than the priority of the standard function library, and the priority of the standard function library is greater than the priority of the other data source function libraries; each data source corresponds to one SQL function library; the current data source function library is the SQL function library of the data source corresponding to the SQL statement; When function pushdown is enabled, the SQL function library corresponding to the target SQL function is the current data source function library or the standard function library; The execution device further includes: an output module, used to output prompt information when the user enables function pushdown, the prompt information being used to prompt the user to select the target SQL function library from the current data source function library and the standard function library; The function information includes: function name, function syntax, number of function parameters, function parameter types, and function category; The execution device further includes a definition module, used to define each of the SQL functions in the SQL function library, such that each SQL function corresponds to a function information.

9. An electronic device, characterized in that, include: One or more processors; one or more memories; One or more memories are used to store computer program code, which includes computer instructions. When one or more processors execute the computer instructions, the electronic device performs the execution method according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when executed on a computer, cause the computer to perform the execution method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data processing method, device, electronic device and storage medium

    CN109460416A

  • Generating Structured Query Language / Extensible Markup Language (SQL / XML) Statements

    US20100299327A1