Data dynamic query method and device, equipment, medium and program product
By obtaining compound expressions from online form clients and generating dynamic query statements using a semantic mapping database and function registry, the problem of rigid data queries caused by pre-configured templates is solved, realizing autonomous and flexible data queries that can adapt to various complex query needs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI PUDONG DEVELOPMENT BANK
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-10
AI Technical Summary
In existing technologies, when data querying and report generation are performed using pre-configured templates, business users need to confirm the indicators, query logic, and calculation methods with the technical developers in advance. This results in different business scenarios needing to prepare independent templates, making decentralized management and maintenance difficult, and reducing the flexibility of data application.
This paper provides a method for dynamic data querying. By obtaining compound expressions from online form clients, dynamic query statements are generated using a semantic mapping database and a function registry. This enables automatic conversion from expressions to executable query statements, supporting flexible data querying and result sending.
It enables autonomous and flexible data querying, reduces operational difficulty, avoids the rigidity of pre-configured templates, ensures the correctness and flexibility of query statements, and adapts to various complex query needs.
Smart Images

Figure CN121833764A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data processing technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for dynamic data query. Background Technology
[0002] With the development of big data technology, enterprises face the need for rapid and flexible querying and analysis of massive amounts of data. Among related technologies, data querying and report generation are performed using pre-configured templates, such as in traditional BI tools. Technical personnel pre-write SQL queries and solidify report templates, and the system then queries the pre-processed data based on the configuration.
[0003] However, with fixed templates, business users need to confirm the metrics, query logic, and calculation methods with the technical developers in advance. Different business scenarios require separate templates, and decentralized management leads to maintenance difficulties. The large increase in business data also reduces the flexibility of data application. Summary of the Invention
[0004] Therefore, it is necessary to provide a data dynamic query method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can enhance the flexibility of data query in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a method for dynamic data querying, including:
[0006] Obtain a compound expression from an online form client; wherein the compound expression includes an indicator identifier and a function identifier;
[0007] Based on the indicator identifier, query the corresponding metadata information from the semantic mapping database, and based on the function identifier, obtain the corresponding query language template from the function registry center;
[0008] Based on the metadata information and the query language template, a dynamic query statement is generated;
[0009] The data is queried according to the dynamic query statement, the query result data is obtained, and the query result data is sent to the online form client.
[0010] In one embodiment, obtaining the compound expression from the online form client includes:
[0011] In response to an edit event in the online form client, obtain the edit event information;
[0012] If a preset identifier is detected in the edit event information, the expression corresponding to the preset identifier and the cell position information of the cell where the expression is located are obtained;
[0013] Based on the expression and the cell position information, a compound expression is generated according to a preset data structure.
[0014] In one embodiment, sending the query result data to the online form client includes:
[0015] Extract the derived format identifier from the compound expression;
[0016] Generate a query response message based on the query result data, the cell location information, and the export format identifier;
[0017] The query response message is sent to the online form client.
[0018] In one embodiment, generating a dynamic query statement based on the metadata information and the query language template includes:
[0019] Extract at least one of the database name, table name, and field name from the metadata information and fill it into the corresponding placeholder in the query language template;
[0020] Based on the function identifier, each function is processed sequentially according to the nesting order to obtain the function parameter value;
[0021] The parameter values of each function are filled into the query language template to obtain the sub-query fragments corresponding to each function, and a dynamic query statement is generated based on each sub-query fragment.
[0022] In one embodiment, the method further includes:
[0023] In response to the template save command, multiple cells in the online form client are scanned to identify cells containing compound expressions;
[0024] Extract the compound expression and its corresponding cell position information, and record the table layout information and format configuration information corresponding to the compound expression;
[0025] An expression template is generated based on the table layout information, the format configuration information, and the compound expression.
[0026] In one embodiment, the method further includes:
[0027] In response to the export format definition instruction, a format control expression is obtained; wherein, the format control expression includes a format type identifier and a format parameter identifier;
[0028] The exported file type is determined based on the format type identifier, and the exported file type includes at least one of spreadsheet file, text file or database file;
[0029] The formatting rules are determined based on the format parameter identifier, and the formatting rules include at least one of the following: delimiter rules, field width rules, and character encoding rules;
[0030] Add the exported file type and the formatting rule to the expression template.
[0031] Secondly, this application also provides a data dynamic query device, comprising:
[0032] The data acquisition module is used to acquire compound expressions from online form clients; wherein, the compound expression includes an indicator identifier and a function identifier;
[0033] The data analysis module is used to query the corresponding metadata information from the semantic mapping database based on the indicator identifier, and to obtain the corresponding query language template from the function registry based on the function identifier.
[0034] The statement generation module is used to generate dynamic query statements based on the metadata information and the query language template;
[0035] The data query module is used to perform data queries based on the dynamic query statement, obtain query result data, and send the query result data to the online form client.
[0036] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps described in the first aspect.
[0037] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps described in the first aspect.
[0038] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps described in the first aspect.
[0039] The aforementioned data dynamic query method, apparatus, computer equipment, computer-readable storage medium, and computer program product acquire a compound expression from an online form client. This compound expression includes an indicator identifier and a function identifier. Based on the indicator identifier, corresponding metadata information is queried from a semantic mapping database, and based on the function identifier, a corresponding query language template is obtained from a function registry. This encapsulates the data processing logic into reusable functions, significantly reducing operational complexity. Dynamic query statements are generated based on the metadata information and query language templates, achieving automatic conversion from expression to executable query statements. Each query can be precisely constructed according to current needs, avoiding the rigidity of pre-configured templates. Data is queried based on the dynamic query statements to obtain query results, which are then sent to the online form client. This automatically completes the conversion from business semantics to technical implementation, achieving autonomous and flexible data application and enhancing data query flexibility. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 This is a diagram illustrating the application environment of a dynamic data query method in one embodiment.
[0042] Figure 2 This is a flowchart illustrating a dynamic data query method in one embodiment;
[0043] Figure 3 This is a flowchart illustrating the dynamic data query method in another embodiment;
[0044] Figure 4 This is a structural block diagram of a data dynamic query device in one embodiment;
[0045] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0047] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0048] The data dynamic query method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located on the cloud or other network servers. The data storage system can be used to store data such as semantic mapping databases. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, drones, low-altitude aircraft, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Head-mounted devices can be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0049] In one exemplary embodiment, such as Figure 2 As shown, a dynamic data query method is provided, which can be applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps S202 to S208. Wherein:
[0050] Step S202: Obtain the compound expression from the online form client.
[0051] Online spreadsheet clients refer to spreadsheet applications that run in the user's browser, providing a spreadsheet-like interface that allows users to enter and edit content in cells.
[0052] Compound expressions can be used to describe a user's data query requirements, and they include indicator identifiers and function identifiers. Indicator identifiers can be strings representing business metrics, such as "number of customers"; function identifiers can be the names of functions that process data, such as "SUM" (summation) and "AVG" (average).
[0053] For example, server 104 can respond to an edit event from an online form client and obtain edit event information; if a preset identifier is detected in the edit event information, server 104 can obtain the expression corresponding to the preset identifier and the cell position information of the cell where the expression is located; and generate a compound expression according to a preset data structure based on the expression and the cell position information.
[0054] For example, server 104 can establish a network connection with the online spreadsheet client and listen for data sent by the client via the WebSocket protocol or HTTP request-response mechanism. When a user enters content in a cell in the online spreadsheet client, the client can generate an edit event. Server 104 can continuously listen for edit events. Server 104 can parse the received edit event data and extract information such as cell content and cell position. For each edit event, server 104 can check whether the cell content contains specific identifiers used to identify compound expressions. When server 104 detects that the cell content contains a preset identifier, such as a string starting with "#", it can identify the content as a potential compound expression. Subsequently, server 104 can extract the complete content of the expression and record the cell position information where the expression is located, including the spreadsheet ID, worksheet name, row index, and column index.
[0055] Furthermore, server 104 can perform preliminary parsing of the extracted expression content, decomposing it into indicator and function parts. For example, for the expression "#sales revenue:SUM", server 104 can identify "sales revenue" as an indicator identifier and "SUM" as a function identifier. During the parsing process, server 104 can also handle nested structures and parameter information in the expression. After parsing is complete, server 104 can organize the parsing results into standardized compound expression objects according to a predefined data structure pattern, which may include the original expression content, parsed structured data, cell position information, etc.
[0056] Step S204: Based on the indicator identifier, query the corresponding metadata information from the semantic mapping database, and based on the function identifier, obtain the corresponding query language template from the function registry center.
[0057] The semantic mapping database stores the correspondence between metric identifiers and underlying data structures, recording the mapping between business metric names and database names, table names, and field names in the actual database. Metadata information can include data location, structure, type, and other information. The function registry is a component in the system used to manage various data processing functions, storing function names, parameter rules, and corresponding query language templates. The query language template can contain parameter placeholders used to generate the final query statement.
[0058] For example, server 104 can perform syntax parsing on compound expressions, breaking them down into structured components. For instance, for the expression "#!LAST_N_DAYS:DATE()", server 104 can extract the indicator identifier "LAST_N_DAYS" and the function identifier "DATE()". After obtaining the indicator identifier, server 104 can access the semantic mapping database, construct a query statement, and use the indicator identifier as a condition to query the semantic mapping table.
[0059] Furthermore, server 104 can access the function registry in the system based on the parsed function identifier. The function registry manages data processing functions and can be implemented as a database or memory cache, storing the definitions and templates of all available functions. Server 104 can construct query conditions, using the function identifier as the subject to query the function registry. For example, for the function "DATE()", server 104 can execute the query "SELECT function_template, parameter_rules FROM function_registry WHERE function_name = 'DATE()'". Server 104 can execute this query to obtain the corresponding SQL template, such as "WHERE dt = CURRENT_DATE" or a template with parameters "WHERE dt BETWEEN {start_date} AND {end_date}". The curly braces in the function template represent parameter placeholders, which can be replaced by actual parameter values.
[0060] Step S206: Generate a dynamic query statement based on metadata information and query language template.
[0061] Dynamic queries can be Structured Query Language (SCL) statements used to retrieve specific data from a database. Unlike predefined static queries, dynamic queries can flexibly adapt to different parameters and conditions to meet various query needs. The query language template can be a predefined SQL fragment containing variable placeholders, which can be replaced by actual values at runtime to form a complete query statement.
[0062] For example, server 104 can extract at least one of the database name, table name, and field name from the metadata information and populate the corresponding placeholders in the query language template; based on the function identifier, each function is processed sequentially according to the nesting order to obtain the function parameter values; the function parameter values are populated into the query language template to obtain the subquery fragments corresponding to each function, and a dynamic query statement is generated based on each subquery fragment. For example, server 104 can initialize a basic query template, such as a standard SELECT statement framework, such as "SELECT {field} FROM {table} WHERE {condition} {grouping} {sorting} {limitation}". The basic template can contain multiple placeholders. Server 104 can process the metadata information to extract the database name, table name, and field name. For example, if the metadata information can contain the database name "finance_db", the table name "transactions", and the field name "amount", server 104 can populate these values into the corresponding positions in the basic query template. For example, server 104 can fill the field name "amount" into the {field} placeholder in the SELECT clause, and fill the database name and table name combination ("finance_db.transactions") into the {table} placeholder in the FROM clause.
[0063] Next, server 104 can process the query template for the function portion. Server 104 can first analyze the nested structure of functions in the compound expression to determine the execution order of the functions. For nested functions, server 104 can process each function sequentially from the inside out. When processing function parameters, server 104 can handle them appropriately based on their type. For string parameters, appropriate quotation marks can be added; for numeric parameters, the value is used directly; for date parameters, they can be converted according to the database's required format. If a parameter is a reference to another cell, server 104 can obtain the current value of that cell and use it as the parameter value. For functions with multiple parameters, server 104 can process each parameter sequentially and fill it into the corresponding position.
[0064] After processing all functions, server 104 can combine the generated SQL fragments according to the nested order of the functions. SQL fragments generated by inner functions can be used as part of or conditions of outer functions. For example, the WHERE clause generated by the FILTER function can be combined with other conditions to form a complete conditional statement. Finally, server 104 can combine all the processed parts into a complete SQL query statement, such as a HiveQL statement.
[0065] Through the above steps, server 104 constructs a complete query statement by filling and combining different template fragments. This ensures the flexibility of the generated query, adapting to various complex query needs, while also ensuring the correctness of the query statement, avoiding syntax errors that may occur when manually writing SQL. Furthermore, it implements query optimization functionality, analyzing and optimizing the generated query statement.
[0066] Step S208: Perform a data query based on the dynamic query statement to obtain the query result data, and send the query result data to the online form client.
[0067] Data queries can take various forms, including single values, single rows with multiple columns, multiple rows with a single column, or multiple rows with multiple columns. Query response messages can use structured formats such as JSON or XML. Export format identifiers are tags that define the data output format, such as identifiers indicating whether the data should be output in Excel or TXT format.
[0068] For example, server 104 can extract the export format identifier from the compound expression; generate a query response message based on the query result data, cell position information and export format identifier; and send the query response message to the online form client.
[0069] For example, server 104 can establish a connection with a big data cluster, such as a Hadoop cluster, Hive cluster, or other big data processing systems. After the connection is established, server 104 can create a query session and set session parameters, such as timeout and maximum number of rows to return. Server 104 can submit dynamic query statements to the big data cluster for execution. Before submission, server 104 can perform a final syntax check and security verification on the query statement to ensure that the query statement conforms to the syntax specifications and does not contain malicious code. After submission, server 104 can monitor the execution status of the query, including whether execution has started, execution progress, and completion. For long-running queries, server 104 can periodically check the execution status and may send progress updates to the client to inform the user of the query's execution status. If the query execution time is found to be too long, server 104 can take measures such as automatically adjusting query parameters, optimizing the execution plan, or enabling query result caching to improve query efficiency.
[0070] After the big data cluster completes query execution, server 104 can receive the query result data. The query result can be in various formats, such as a single value (e.g., a count or sum), a single row with multiple columns (e.g., multiple fields in a single record), multiple rows with a single column (e.g., multiple values in a single column of data), or multiple rows with multiple columns (e.g., a tabular dataset). Server 104 can perform preliminary processing on the received result data, such as format conversion, data type adjustment, and handling of null values, to ensure the data is suitable for display on the client. For example, formatting numeric data to a specific precision, converting date data to an easily readable format, and converting NULL values to an empty string or default value.
[0071] Next, server 104 can send the query results back to the online form client. Server 104 can extract cell position information from the original compound expression to determine where in the table the query results should be filled. If the original expression contains an export format identifier, server 104 can also extract it to determine the output format of the data. Server 104 can determine the filling strategy for the result data based on the structure of the query results (single value, row, column, or table) and the cell position information. For example, if the result is a single value, it can be filled directly into the cell containing the expression; if it is a multi-row, single-column structure, it can start filling downwards from the cell containing the expression; if it is a multi-row, multi-column structure, it can start filling to the right and downwards from the cell containing the expression to form a rectangular area.
[0072] Subsequently, server 104 can combine the query result data, cell position information, and fill strategy into a query response message. The response message can be in JSON format and includes information such as query status (success or failure), result data, cell position, and fill range. If an error occurs during query execution, the response message can also include an error code and an error message. Server 104 can send the query response message to the online form client via a network connection. During transmission, server 104 can perform necessary encoding and compression of the data to reduce network traffic and improve transmission efficiency. For large amounts of data, server 104 can use a batch transmission method, sending a portion of the data for the user to view first, and then continuing to transmit the remaining data in the background.
[0073] In the aforementioned dynamic data query method, a compound expression is obtained from the online form client. This compound expression includes an indicator identifier and a function identifier. Based on the indicator identifier, the corresponding metadata information is queried from the semantic mapping database, and based on the function identifier, the corresponding query language template is obtained from the function registry. This encapsulates the data processing logic into a reusable function, greatly reducing the operational difficulty. Based on the metadata information and the query language template, a dynamic query statement is generated, realizing the automatic conversion from expression to executable query statement. Each query can be accurately constructed according to the current needs, avoiding the rigidity of pre-configured templates. Data is queried based on the dynamic query statement, and the query result data is obtained and sent to the online form client. This automatically completes the conversion from business semantics to technical implementation, realizing the autonomy and flexibility of data application and enhancing the flexibility of data query.
[0074] In one exemplary embodiment, such as Figure 3 As shown, the above method may also include steps S302 to S306. Wherein:
[0075] In step S302, in response to the template save command, multiple cells in the online form client are scanned to identify cells containing compound expressions.
[0076] The template save command is a user-sent command via the online spreadsheet client to save the current spreadsheet as a template, triggered by clicking the save button or using a keyboard shortcut. Expression templates can be data structures that store table structures, compound expressions, or formatting settings; they do not contain actual data values and can be used for subsequent reuse and automation. Table layout information refers to the table's structural features, such as row height, column width, and merged cell settings. Formatting configuration information can include cell style settings, such as font, color, and borders.
[0077] For example, in response to a template save command, server 104 scans multiple cells in the online form client and identifies cells containing compound expressions. When a user triggers a template save operation on the online form client, the client can send a template save request to server 104. This request can include basic information about the form, such as the form ID, form name, and user ID. After receiving the save request, server 104 can verify user permissions to ensure that the user has the right to perform the operation. After successful verification, server 104 can begin processing the save request, preparing to scan the form content to identify compound expressions.
[0078] Furthermore, server 104 can obtain complete structural information about the table, including a list of all worksheets, the number of rows and columns in each worksheet, etc. This information can be obtained from an online spreadsheet client via API or by reading the latest state of the table from a database. After obtaining the table structure, server 104 can scan the worksheets one by one. For each worksheet, server 104 can traverse all cells in a left-to-right, top-to-bottom order. During the traversal, server 104 can check the content of each non-empty cell to determine whether it contains features of compound expressions, such as specific prefix identifiers (e.g., "#!").
[0079] When server 104 detects that a cell's content matches the characteristics of a compound expression, it can mark the cell as containing a compound expression and record its location information (worksheet name, row index, column index). After scanning all worksheets, server 104 can summarize the information of all cells containing compound expressions, forming a list of expression cells.
[0080] Step S304: Extract the compound expression and its corresponding cell position information, and record the table layout information and format configuration information corresponding to the compound expression.
[0081] For example, server 104 can iterate through the list of expression cells and process each cell. For each expression cell, server 104 can extract the content of the compound expression and record the complete location information of the cell, including the worksheet name, row index, column index, and the start and end positions in the case of merged cells. Next, server 104 can parse the structure of the compound expression and identify the indicator identifiers, function identifiers, and parameter information. Server 104 can then associate the parsed structured expression information with the cell location information to form an expression mapping table.
[0082] In some embodiments, server 104 can also record table layout information. Server 104 can obtain the overall layout settings of the table, including the number of worksheets, the name of each worksheet, default row height, and column width. Server 104 can also obtain settings for special rows and columns, such as frozen rows and columns, hidden rows and columns, and rows and columns with adjusted widths. For merged cells, server 104 can record their range and merging method. Furthermore, server 104 can also obtain table view settings, such as zoom level, scroll position, and active cell.
[0083] Furthermore, for expressions with dependencies, server 104 can analyze and record these dependencies. For example, if expression A references the value of the cell containing expression B, server 104 can record the dependency relationship between A and B, ensuring that the expressions are processed in the correct order after the template is loaded. Server 104 can clearly represent the referencing relationships between expressions by constructing an expression dependency graph. This dependency graph is a directed graph structure where each node represents an expression and each edge represents a dependency relationship.
[0084] Step S306: Generate an expression template based on the table layout information, format configuration information, and compound expression.
[0085] For example, server 104 can create a new template object and set basic template properties such as template name, creation time, creation user, and description information. Next, server 104 can add the overall structure information of the table to the template. This includes a list of worksheets, basic settings for each worksheet (such as name, index, and visibility), default row height and column width, frozen areas, hidden rows and columns, and view settings. For special layout settings, such as split panes and worksheet tab colors, server 104 can also record them in the template.
[0086] Next, server 104 can add compound expression information to the template. For each compound expression, server 104 can record its content, location, parsed structure (indicators, functions, parameters), and dependencies with other expressions. Server 104 can add formatting configuration information to the template, including global formatting settings (such as default font, default color), worksheet-level formatting settings (such as background color, gridlines), and cell-level formatting settings (such as font, color, border, background color, alignment, number format, etc.).
[0087] For expressions with special requirements, such as numeric values or dates requiring a specific format, server 104 can add corresponding formatting rules to the template. For example, for currency values, it adds currency symbols and thousands separators; for percentage values, it adds a percent sign and specifies the number of decimal places; for date values, it adds a specific date format, etc. After integrating the above information, server 104 can serialize the template object into a specific format, such as JSON or XML. Server 104 can also save the template data to a database or file system and generate an access link or identifier for the user for later use. Finally, server 104 can return a message to the client indicating successful saving, including the template identifier and access method.
[0088] In some embodiments, server 104 may also respond to an export format definition instruction to obtain a format control expression; wherein the format control expression includes a format type identifier and a format parameter identifier; determine the export file type based on the format type identifier, the export file type including at least one of a spreadsheet file, a text file, or a database file; determine the formatting rules based on the format parameter identifier, the formatting rules including at least one of a delimiter rule, a field width rule, and a character encoding rule; and add the export file type and the formatting rules to the expression template.
[0089] For example, when a user triggers an export format definition operation on an online form client, the client can send a format definition request to server 104. Server 104 can verify user permissions and, upon successful verification, process the format definition request, preparing to scan the form to identify format control expressions. These format control expressions can be located in specific areas of the form, such as the first row or specific configuration cells, and are identified using a specific prefix (such as "#!FORMAT"). Server 104 can scan these areas and identify all format control expressions. A format control expression can include two parts: a format type identifier and a format parameter identifier.
[0090] The format type identifier specifies the basic type of the exported file, such as "EXCEL" for Excel, "TXT" for text, and "CSV" for CSV. The format parameter identifier specifies detailed formatting rules, such as delimiter type (comma, tab, custom character), field width settings (column width in fixed-width format), character encoding rules (UTF-8, GBK, etc.), and text qualifier settings (single quotes, double quotes). Based on the obtained format control expression, server 104 can determine the exported file type according to the format type identifier. Supported file types include spreadsheet files (e.g., .xlsx, .xls), text files (e.g., .txt, .csv), and database files (e.g., .sql, .json). Each file type can have its specific format characteristics and use cases, and server 104 can prepare the corresponding export processing flow according to the user's selection.
[0091] Next, server 104 can determine the specific formatting rules based on the format parameter identifier. For text files (such as TXT and CSV), server 104 can set delimiter rules, such as using commas, tabs, or custom characters as field delimiters, and using carriage returns, line feeds, or combinations thereof as line delimiters. For fixed-width text files, server 104 can set field width rules, specifying the number of characters occupied by each field and how to handle excessive or insufficient length (such as truncation, padding with spaces, etc.). For all types of files, server 104 can set character encoding rules, such as using UTF-8, GBK, ASCII, etc. Furthermore, depending on the data type, server 104 can also set specific formatting rules, such as the decimal places and thousands separator for numeric data, the date format for date data, and the handling of quotation marks for text data.
[0092] Finally, server 104 can add the exported file type and formatting rules to the expression template, update the template object after completing the format configuration, reserialize and save it to storage, and return a message of successful update to the client, which may include the updated template identifier and access method.
[0093] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0094] Based on the same inventive concept, this application also provides a data dynamic query device for implementing the data dynamic query method described above. The solution provided by this device is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more data dynamic query device embodiments provided below can be found in the limitations of the data dynamic query method described above, and will not be repeated here.
[0095] In one exemplary embodiment, such as Figure 4As shown, a dynamic data query device is provided, including: a data acquisition module 402, a data analysis module 404, a statement generation module 406, and a data query module 408, wherein:
[0096] The data acquisition module 402 is used to acquire compound expressions from online form clients; wherein, the compound expression includes indicator identifiers and function identifiers;
[0097] The data analysis module 404 is used to query the corresponding metadata information from the semantic mapping database based on the indicator identifier, and to obtain the corresponding query language template from the function registry based on the function identifier.
[0098] The statement generation module 406 is used to generate dynamic query statements based on metadata information and query language templates;
[0099] The data query module 408 is used to perform data queries based on dynamic query statements, obtain query result data, and send the query result data to the online form client.
[0100] In one embodiment, the data acquisition module 402 is specifically used to: in response to an editing event from an online form client, acquire editing event information; if a preset identifier is detected in the editing event information, acquire the expression corresponding to the preset identifier and the cell position information of the cell where the expression is located; and generate a compound expression according to a preset data structure based on the expression and the cell position information.
[0101] In one embodiment, the data query module 408 is specifically used to extract the export format identifier in the compound expression; generate a query response message based on the query result data, cell position information and export format identifier; and send the query response message to the online form client.
[0102] In one embodiment, the statement generation module 406 is specifically used to extract at least one of the database name, table name, and field name from the metadata information and fill it into the corresponding placeholder in the query language template; according to the function identifier, each function is processed in the nesting order of each function to obtain the function parameter value; each function parameter value is filled into the query language template to obtain the subquery fragment corresponding to each function, and a dynamic query statement is generated based on each subquery fragment.
[0103] In one embodiment, the apparatus further includes: a template processing module, configured to, in response to a template saving instruction, scan multiple cells of the online form client, identify cells containing compound expressions; extract the compound expressions and corresponding cell position information, and record the table layout information and format configuration information corresponding to the compound expressions; and generate an expression template based on the table layout information, format configuration information, and compound expressions.
[0104] In one embodiment, the apparatus further includes: a format processing module, configured to obtain a format control expression in response to an export format definition instruction; wherein the format control expression includes a format type identifier and a format parameter identifier; determine an export file type based on the format type identifier, the export file type including at least one of a spreadsheet file, a text file, or a database file; determine a formatting rule based on the format parameter identifier, the formatting rule including at least one of a delimiter rule, a field width rule, and a character encoding rule; and add the export file type and the formatting rule to an expression template.
[0105] Each module in the aforementioned dynamic data query device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0106] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as semantic mapping databases. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a dynamic data query method.
[0107] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0108] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0109] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0110] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0111] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0112] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0113] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0114] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for dynamic data query, characterized in that, The method includes: Obtain a compound expression from an online form client; wherein the compound expression includes an indicator identifier and a function identifier; Based on the indicator identifier, query the corresponding metadata information from the semantic mapping database, and based on the function identifier, obtain the corresponding query language template from the function registry center; Based on the metadata information and the query language template, a dynamic query statement is generated; The data is queried according to the dynamic query statement, the query result data is obtained, and the query result data is sent to the online form client.
2. The method according to claim 1, characterized in that, The step of obtaining the compound expression from the online form client includes: In response to an edit event in the online form client, obtain the edit event information; If a preset identifier is detected in the edit event information, the expression corresponding to the preset identifier and the cell position information of the cell where the expression is located are obtained; Based on the expression and the cell position information, a compound expression is generated according to a preset data structure.
3. The method according to claim 2, characterized in that, Sending the query result data to the online form client includes: Extract the derived format identifier from the compound expression; Generate a query response message based on the query result data, the cell location information, and the export format identifier; The query response message is sent to the online form client.
4. The method according to claim 1, characterized in that, The step of generating a dynamic query statement based on the metadata information and the query language template includes: Extract at least one of the database name, table name, and field name from the metadata information and fill it into the corresponding placeholder in the query language template; Based on the function identifier, each function is processed sequentially according to the nesting order to obtain the function parameter value; The parameter values of each function are filled into the query language template to obtain the sub-query fragments corresponding to each function, and a dynamic query statement is generated based on each sub-query fragment.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: In response to the template save command, multiple cells in the online form client are scanned to identify cells containing compound expressions; Extract the compound expression and its corresponding cell position information, and record the table layout information and format configuration information corresponding to the compound expression; An expression template is generated based on the table layout information, the format configuration information, and the compound expression.
6. The method according to claim 5, characterized in that, The method further includes: In response to the export format definition instruction, a format control expression is obtained; wherein, the format control expression includes a format type identifier and a format parameter identifier; The exported file type is determined based on the format type identifier, and the exported file type includes at least one of spreadsheet file, text file or database file; The formatting rules are determined based on the format parameter identifier, and the formatting rules include at least one of the following: delimiter rules, field width rules, and character encoding rules; Add the exported file type and the formatting rule to the expression template.
7. A dynamic data query device, characterized in that, The device includes: The data acquisition module is used to acquire compound expressions from online form clients; wherein, the compound expression includes an indicator identifier and a function identifier; The data analysis module is used to query the corresponding metadata information from the semantic mapping database based on the indicator identifier, and to obtain the corresponding query language template from the function registry based on the function identifier. The statement generation module is used to generate dynamic query statements based on the metadata information and the query language template; The data query module is used to perform data queries based on the dynamic query statement, obtain query result data, and send the query result data to the online form client.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.