CN117555919A - Data query method, device, equipment and storage medium - Google Patents

Data query method, device, equipment and storage medium Download PDF

Info

Publication number
CN117555919A
CN117555919A CN202311737391.0A CN202311737391A CN117555919A CN 117555919 A CN117555919 A CN 117555919A CN 202311737391 A CN202311737391 A CN 202311737391A CN 117555919 A CN117555919 A CN 117555919A
Authority
CN
China
Prior art keywords
index
template
templates
data
query
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311737391.0A
Other languages
Chinese (zh)
Inventor
尤海浪
桑强
吴洪亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lianlian Hangzhou Information Technology Co ltd
Original Assignee
Lianlian Hangzhou Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lianlian Hangzhou Information Technology Co ltd filed Critical Lianlian Hangzhou Information Technology Co ltd
Priority to CN202311737391.0A priority Critical patent/CN117555919A/en
Publication of CN117555919A publication Critical patent/CN117555919A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention discloses a data query method, a device, equipment and a storage medium, wherein the method comprises the following steps: receiving a data query request; the data query request comprises a user query index and a query limiting condition; packaging the user query indexes and the query limiting conditions into a data query function; determining an index template to be processed from a plurality of index templates based on the user query index; under the condition that the number of index templates to be processed is multiple and similar index templates exist, carrying out template merging on the similar index templates based on a data query function to obtain merged index templates; obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except similar index templates in the plurality of index templates to be processed. The data query method disclosed by the invention can realize dynamic construction of the target query statement, thereby improving the construction efficiency and the data query efficiency of the target query statement.

Description

Data query method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a data query method, a data query device, data query equipment and a storage medium.
Background
In the process of using the index and developing the new index, similar or repeated sentences exist in most SQL (Structured Query Language, database language) sentence structures involved; in the prior art, a developer is required to frequently carry out modification such as copying, pasting and the like on SQL sentences so as to modify indexes into target sentences conforming to user requests, and the defect of low efficiency of generating the target sentences exists; in addition, the generated target statement has repeated statements, and the same data table is accessed for multiple times in the execution process, so that the execution efficiency of the target statement is poor.
Disclosure of Invention
In view of the above-mentioned drawbacks of the prior art, the present invention aims to solve the technical problems of how to improve the generation efficiency of the target query statement and how to optimize the execution efficiency of the target query statement.
In order to solve at least one technical problem set forth above, the invention provides a data query method, a device, equipment and a storage medium.
According to an aspect of the present disclosure, there is provided a method of data query, including:
Receiving a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
packaging the user query indexes and the query limiting conditions into a data query function;
determining at least one index template to be processed from a plurality of index templates based on the user query index;
when the number of the at least one index template to be processed is multiple and similar index templates exist in the multiple index templates to be processed, carrying out template merging processing on the similar index templates based on the data query function to obtain merged index templates;
obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
In some possible embodiments, each index template to be processed corresponds to one piece of dimension information;
the method comprises the steps of:
respectively acquiring dimension information corresponding to each index template to be processed;
And determining the index templates to be processed with consistent dimension information as the similar index templates in the index templates to be processed based on the dimension information.
In some possible embodiments, the index template types include a single index template and a composite index template; the single index template is an index template for executing one processing task, and the composite index template is an index template for executing a plurality of processing tasks;
the step of carrying out template merging processing on the similar index templates based on the data query function to obtain merged index templates comprises the following steps:
code compiling is carried out on the similar index templates based on the data query function, and compiled index templates are obtained;
and sequentially carrying out template merging treatment on the compiled index templates according to the sequence of the single index template and the composite index template to obtain the merged index template.
In some possible embodiments, after the obtaining the target query statement corresponding to the data query request, the method includes:
acquiring an original execution program; the original execution program is used for executing data query;
under the condition that the original execution program does not meet the data query request, updating the original execution program based on the target query statement to obtain a target execution program;
And returning target query data corresponding to the data query request to the user based on the target execution program.
In some possible embodiments, the method further comprises:
and under the condition that the number of the at least one index template to be processed is multiple and similar index templates do not exist in the multiple index templates to be processed, obtaining the target query statement based on the data query function and the multiple index templates to be processed.
In some possible embodiments, the data query request further includes a user identifier;
after receiving the data query request sent by the user, the method further comprises:
performing query permission detection on the user based on the user identifier to obtain a permission detection result;
and under the condition that the permission detection result indicates that the user has the index query permission, determining that the user is a legal user.
In some possible embodiments, the method further comprises:
acquiring index metadata corresponding to the at least one index template to be processed; the index metadata are description data corresponding to the index templates to be processed;
respectively carrying out data verification on the index metadata to obtain a data verification result;
And under the condition that the data detection result indicates that the index metadata is effective data, determining an index template to be processed corresponding to the effective data as an effective template.
According to a second aspect of the present disclosure, there is provided an apparatus for data querying, the apparatus comprising:
the request receiving module is used for receiving a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
the data packaging module is used for packaging the user query indexes and the query limiting conditions into a data query function;
the template determining module is used for determining at least one index template to be processed from a plurality of index templates based on the user query index;
the template merging module is used for carrying out template merging processing on the similar index templates based on the data query function under the condition that the number of the at least one index template to be processed is multiple and the similar index templates exist in the multiple index templates to be processed, so as to obtain a merged index template;
the statement determining module is used for obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
According to a third aspect of the present disclosure, there is provided an electronic device comprising a processor and a memory having stored therein at least one instruction and at least one program, the at least one instruction and the at least one program being loaded and executed by the processor to implement a method of data querying as described above.
According to a fourth aspect of the present disclosure, there is provided a computer storage medium having stored therein at least one instruction and at least one program, the at least one instruction and the at least one program being loaded and executed by a processor to implement a method of data querying as described above.
The implementation of the invention has the following beneficial effects:
according to the method and the device, at least one index template to be processed is determined from a plurality of index templates based on the user query index in the data query request sent by the user, so that the efficiency and the correctness of determining the index templates can be improved; packaging the user query indexes and the query limiting conditions into a data query function, and further processing the index templates to be processed based on the data query function, so that the index templates can be personalized processed, and the suitability of the generated target query statement and the data query request is improved; the similar index templates in the index templates to be processed are combined, repeated codes in the index templates can be reduced, repeated access of the repeated codes to the data table is avoided, the scanning times of the data table are reduced, and the execution efficiency of the target query statement is optimized.
Drawings
In order to more clearly illustrate the technical solutions of the present invention, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart corresponding to a method for querying data according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a process for determining correspondence of similar templates according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of a similar template merging process according to an embodiment of the present invention;
FIG. 4 is a flow chart corresponding to an update of an execution program according to an embodiment of the present invention;
fig. 5 is a schematic flow chart corresponding to user authority detection provided in the embodiment of the present invention;
FIG. 6 is a flow chart corresponding to the index validity detection provided by the embodiment of the invention;
FIG. 7 is a block diagram of a SQL statement corresponding to a single index according to an embodiment of the present invention;
FIG. 8 is a block diagram of another SQL statement corresponding to a single index according to an embodiment of the invention;
FIG. 9 is a SQL statement corresponding to a composite index according to an embodiment of the invention;
FIG. 10 is a first merged SQL statement according to one embodiment of the invention;
FIG. 11 is a diagram illustrating a second merged target query statement according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram corresponding to a data query device according to an embodiment of the present invention.
Detailed Description
The technical solutions of the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is apparent that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present invention based on the embodiments herein.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Various exemplary embodiments, features and aspects of the disclosure will be described in detail below with reference to the drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Although various aspects of the embodiments are illustrated in the accompanying drawings, the drawings are not necessarily drawn to scale unless specifically indicated.
The word "exemplary" is used herein to mean "serving as an example, embodiment, or illustration. Any embodiment described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of a plurality or any combination of at least two of a plurality, for example, including at least one of A, B, C, and may mean including any one or more elements selected from the group consisting of A, B and C.
Furthermore, numerous specific details are set forth in the following detailed description in order to provide a better understanding of the present disclosure. It will be understood by those skilled in the art that the present disclosure may be practiced without some of these specific details. In some instances, methods, means, elements, and circuits well known to those skilled in the art have not been described in detail in order not to obscure the present disclosure.
Fig. 1 shows a flow diagram corresponding to a method for querying data according to an embodiment of the present invention; the execution subject may be any terminal capable of being configured with an index system and of realizing a method of data query; referring to fig. 1, a method for querying data includes:
step S101: receiving a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
in a specific embodiment, the data query request characterizes data information to be queried, i.e. data information that the user wants to query; the data query request comprises a user query index and a query limiting condition; the user query index is used for determining an index template corresponding to the data query request from a plurality of index templates, the user query index can be determined based on user query requirements, and template identifiers corresponding to the index templates, for example, the user query requirements are transaction merchants with the transaction amount larger than M in one quarter and the proportion of the transaction merchants in the whole season, and the template identifiers can be counting, summing and calculating the ratio; the query limit condition may include any limit condition such as time limit, dimension limit, etc., and the limit condition may be a range of values, such as sales amount of a product in approximately seven days, transaction merchants with a transaction amount of a product ranging from N1 to N2, or a specific value, such as sales amount of a product in a specific day.
Step S102: packaging the user query indexes and the query limiting conditions into a data query function;
in a specific embodiment, the index templates to be processed can be determined according to the user query index, each index template to be processed corresponds to index metadata, and the index metadata is description data of the index templates to be processed; and packaging the index metadata and the query limit conditions into the data query function, namely constructing a data query function corresponding to the data query request based on the index metadata and the query limit conditions. The data query function comprises data needed in the user query process, and when the follow-up query needs to be changed, only the query parameters and the data query function need to be modified, and the stability of the query interface can be ensured without modifying the interface.
Step S103: determining at least one index template to be processed from a plurality of index templates based on the user query index;
in a specific embodiment, the index template is a pre-constructed index code capable of realizing different functions; the user query index corresponds to a specific index code, so that an index template to be processed is determined from a plurality of index templates based on the user query index; the number of index templates to be processed can be one or a plurality of index templates, and the index templates are determined according to the user query index (namely the user requirement).
For example, the templates corresponding to the user query indexes are identified as an identifier a1, an identifier a2 and an identifier a3, each index template corresponds to an identifier, and the index templates identified as the identifier a1, the identifier a2 and the identifier a3 are selected as the index templates to be processed.
Step S104: when the number of the at least one index template to be processed is multiple and similar index templates exist in the multiple index templates to be processed, carrying out template merging processing on the similar index templates based on the data query function to obtain merged index templates;
in a specific embodiment, in order to implement optimization of the target query statement, if there are multiple index templates to be processed, it is first required to determine whether there are similar index templates in the multiple index templates to be processed, and if there are similar index templates in the multiple index templates to be processed, the similar index templates are combined based on the data query function to obtain a combined index template.
Step S105: obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
In a specific embodiment, the remaining index templates are index templates except similar index templates in the plurality of index templates to be processed, and after the template merging processing is performed, query statement construction is performed on the similar index templates and the remaining index templates based on a data query function, so as to obtain target query statements corresponding to the data query request; the target query statement may be an SQL statement for implementing the data query request.
Specifically, before the data query method is performed, data model definition is required to be performed in an index system, and then index construction is completed, so that a user can dynamically generate a target query statement based on an index template in the index system.
In a specific application scenario, a dimension table for storing transaction data exists, the dimension table can be constructed based on a data table existing in a number bin tool or can be constructed based on text data, the dimension table can define a dimension column, and the dimension column can comprise dimension information; firstly, creating a data model according to business topics of a plurality of bins, wherein the data model can be synchronized every day after being generated, and data is imported from a plurality of bins tool in an SQL sentence mode; after the data model is built, limiting conditions, statistical periods and index units can be built, and index construction is further carried out, wherein the index construction is divided into single index construction and complex index construction, the single index construction is carried out on the basis of the data model and the dimension columns, and the complex index construction is carried out on the basis of the single index; after the indexes are well established, the indexes are stored in an index system, and after the index system receives a data query request of a user, a target query statement is generated.
In a specific embodiment, the user query index included in the data query request may be a single-day sales amount, a sum of sales amounts in the first quarter, and a proportion of the single-day sales amount to the sales amounts in the first quarter; the query qualifier may be that the sales amount is greater than A1; the number of the index templates to be processed is three, namely a single index template, the template mark is a 4-sum traversal, the template mark is a 5-sum and a composite index template, and the template mark is b 1-sum proportional; after compiling a4, a5 and b1, firstly merging the compiled a4 with the compiled a5, merging the merged index templates, and merging the merged index templates with the compiled b1 to obtain the target query statement.
In the embodiment of the invention, at least one index template to be processed is determined from a plurality of index templates based on the user query index in the data query request sent by the user, so that the efficiency and the correctness of determining the index templates can be improved; packaging the user query indexes and the query limiting conditions into a data query function, and further processing the index templates to be processed based on the data query function, so that the index templates can be personalized processed, and the suitability of the generated target query statement and the data query request is improved; the similar index templates in the index templates to be processed are combined, repeated codes in the index templates can be reduced, repeated access of the repeated codes to the data table is avoided, the scanning times of the data table are reduced, and the execution efficiency of the target query statement is optimized.
Fig. 2 is a schematic flow chart of determining correspondence of similar templates provided in an embodiment of the present invention, where each index template to be processed corresponds to one dimension information; as shown in fig. 2, before performing a template merging process on the similar index templates to obtain a merged index template, the method includes:
step S201: respectively acquiring dimension information corresponding to each index template to be processed;
in a specific embodiment, each index template is constructed based on the data model and the dimension column, so that each index template corresponds to one piece of dimension information, and the dimension information can include source table information and limiting condition information when the index template is constructed; determining whether the source tables and the limiting conditions of the two index templates are consistent according to the dimension information; and regarding the similarity judgment of the index templates, the index templates with the same source list and consistent query conditions are considered to be similar index templates.
For example, for the index template 1 to be processed, the corresponding dimension information 1 is the source table 1, the limiting condition information is that the merchant number is greater than N3, the index template 2 to be processed, the corresponding dimension information 2 is the source table 1, the limiting condition information is that the merchant number is greater than N3, the index template 3 to be processed, the corresponding dimension information 1 is the source table 1, the limiting condition information is that the merchant number is less than N4, the index template 4 to be processed, the corresponding dimension information 1 is the source table 2, and the limiting condition information is that the merchant number is greater than N3; the index template to be processed 1 and the index template to be processed 2 are determined as similar index templates.
Step S202: and determining the index templates to be processed with consistent dimension information as the similar index templates in the index templates to be processed based on the dimension information.
In a specific embodiment, after a plurality of index templates to be processed are acquired, dimension information of each index template to be processed is compared, and the index templates to be processed with consistent dimension information are determined to be similar index templates. For the similar index templates, carrying out template merging treatment on the similar index templates to obtain merged index templates; for merging index templates, the index expression thereof may be modified appropriately.
In the embodiment of the invention, the similarity judgment is carried out on the index templates to be processed to determine whether the similar index templates exist in the index templates to be processed, and the template combination is carried out on the similar index templates, so that the scanning times of the data table are reduced, and the execution efficiency of SQL sentences is further realized.
The index template type comprises a single index template and a composite index template; the single index template is an index template for executing one processing task, and the composite index template is an index template for executing a plurality of processing tasks; fig. 3 is a schematic flow chart of a similar template merging correspondence provided in an embodiment of the present invention, as shown in fig. 3, where, based on the data query function, the similar index template is subjected to a template merging process, so as to obtain a merged index template, where the method includes:
Step S301: code compiling is carried out on the similar index templates based on the data query function, and compiled index templates are obtained;
in a specific embodiment, index metadata corresponding to a similar index template is dynamically compiled through Java, source codes corresponding to the similar index template are called, real-time loading is carried out on the source codes into a Java virtual machine to generate an object instance, and the compiled index metadata is transmitted to the object instance to obtain the compiled index template.
Step S302: and sequentially carrying out template merging treatment on the compiled index templates according to the sequence of the single index template and the composite index template to obtain the merged index template.
In a specific embodiment, for the compiled index templates, when the templates are combined, the template combination is performed according to a rule that a single index template is combined first and then a composite index template is combined, so as to obtain a combined index module.
For example, there are a plurality of single index templates A1, A2, and A3 in the similar index template, a composite index template B1; when the template merging processing is performed, firstly merging the A1, the A2 and the A3, indicating the template A, and then merging the indicator template A with the composite indicator template B1 to obtain a merged indicator template C.
In the embodiment of the invention, the index template is dynamically compiled, and the compiled index template can be adapted to various databases, so that the suitability of the index template is improved; the similarity index templates are combined according to the sequence of single-first and then composite, so that the accuracy of template combining treatment and the efficiency of template combining can be effectively improved.
Fig. 4 is a schematic flow chart corresponding to update of an execution program according to an embodiment of the present invention, and as shown in fig. 4, after obtaining a target query statement corresponding to the data query request, the method includes:
step S401: acquiring an original execution program; the original execution program is used for executing data query;
in a specific embodiment, the original execution program is used for executing data management, where the data management may include at least data query, data modification, data deletion, etc.; the original execution program does not necessarily satisfy the user request, and therefore, in the case where the user request is inconsistent with the data management that can be achieved by the original execution program, a target sentence that satisfies the user request needs to be pushed to the original execution program, so that the original execution program is updated and satisfies the user request.
Step S402: under the condition that the original execution program does not meet the data query request, updating the original execution program based on the target query statement to obtain a target execution program;
in a specific embodiment, in order to save computing resources and avoid repeated construction of the target query statement, before updating the original execution program, it may be first determined whether the original execution program can satisfy the user request; the original executive program without the target query statement is considered to be incapable of meeting the data query request; if the original execution program can meet the user request, the original execution program does not need to be updated, the original execution program can directly respond to the user request, and data corresponding to the user request is returned to the user; pushing a target query statement meeting the user request to the original execution program under the condition that the original execution program can not meet the user request, so that the original execution program is updated, and the target execution program is obtained; the target execution program can satisfy the user request.
Step S403: and returning target query data corresponding to the data query request to the user based on the target execution program.
In a specific embodiment, the updated original execution program is the target execution program, and based on the target execution program, the query sub-function is called to determine target query data matched with the data query request, and the target query data is returned to the user.
In the embodiment of the invention, the generated target query statement can realize the data query request of the user and push the data query request to the original execution program so as to update the original execution program, and the real-time performance of the update of the original execution program can be improved, so that the execution program can be matched with the user requirement.
The method further comprises the steps of:
and under the condition that the number of the at least one index template to be processed is multiple and similar index templates do not exist in the multiple index templates to be processed, obtaining the target query statement based on the data query function and the multiple index templates to be processed.
In a specific embodiment, index metadata corresponding to a plurality of index templates to be processed are dynamically compiled through Java, source codes corresponding to the index templates to be processed are called, the source codes are actually loaded into a Java virtual machine to generate an object instance, and the compiled index metadata are transmitted to the object instance to obtain a compiled index template; based on the data query function, constructing a plurality of compiled index templates into target query sentences.
Specifically, the user query index included in the data query request may be a single-day sales amount, a sum of sales amounts in the first quarter, and a proportion of the single-day sales amount to the sales amounts in the first quarter; the query qualifier may be that the sales amount is greater than A2; the number of the index templates to be processed is three, namely a single index template, the template mark is c 1-sum traversal, the template mark is c 2-sum and a composite index template, and the template mark is d 1-sum proportional; after compiling c1, c2 and d1, firstly merging compiled c1 with compiled c2 to obtain a merged index template, merging the merged index template with compiled d1 to obtain a target query statement, pushing the target query statement to an original execution program to obtain a target execution program, and accordingly inputting daily sales amount in the first quarter, sum of sales in the first quarter and proportion of the daily sales amount to the sales amount in the first quarter respectively.
In the embodiment of the invention, the index template to be processed is processed based on the data query function, so that the index template can be processed in a personalized way, the suitability of the generated target query statement and the data query request is improved, and the generation efficiency of the target query statement is improved.
Fig. 5 is a schematic flow chart corresponding to user authority detection provided in the embodiment of the present invention; the data query request also comprises a user identifier; as shown in fig. 5, after receiving the data query request sent by the user, the method further includes:
step S501: performing query permission detection on the user based on the user identifier to obtain a permission detection result;
in an optional specific embodiment, in order to ensure that each index template in the index system is not modified randomly, the data query request further includes user identifiers corresponding to users, each user has a unique corresponding identifier, and a specific and unique user can be determined based on the user identifiers; after receiving the data query request sent by the user, the index system reads the user identifier included in the data query request, and then performs user permission detection based on the user identifier, wherein the permission detection can be query permission, modification permission, access permission and the like, and a permission detection result is obtained.
Step S502: and under the condition that the permission detection result indicates that the user has the index query permission, determining that the user is a legal user.
In a specific embodiment, determining whether the user is a legal user or an illegal user according to the authority detection result, if the user is determined to be the legal user, responding to a data query request sent by the user, and executing the steps S102-S105; if the user is determined to be an illegal user, the illegal user is not allowed to access the index system, so that the safety of the index system is ensured.
In the embodiment of the invention, after the data query request is received, the user permission is determined according to the user identification contained in the data query request, so that the safety of the index system can be ensured, the index system is not accessed or tampered by an illegal user, and the correctness and the effectiveness of target query statement generation can be further ensured; in addition, the user accessing the index system each time can be determined according to the user identification, and under the condition that the index template is modified, the specific user can be traced back according to the user identification, so that the convenience of index template management can be improved.
Fig. 6 is a schematic flow chart of the index validity detection according to the embodiment of the present invention, where as shown in fig. 6, the method further includes:
step S601: acquiring index metadata corresponding to the at least one index template to be processed; the index metadata are description data corresponding to the index templates to be processed;
in a specific embodiment, the metadata is descriptive data corresponding to the code; each index template to be processed corresponds to index metadata, the index metadata is description data of the index template, and can comprise index template data, index creation data and the like, for example, the index template data can comprise index number, merchant name information, project number, target number and the like, and the index creation data can comprise creation time, creator and the like.
Step S602: respectively carrying out data verification on the index metadata to obtain a data verification result;
in a specific embodiment, the index metadata is subjected to data verification to determine the correctness of the index metadata; the data verification result is used for representing that the index metadata are valid data or that the index metadata are invalid data.
Step S603: and under the condition that the data detection result indicates that the index metadata is effective data, determining an index template to be processed corresponding to the effective data as an effective template.
In a specific embodiment, the index metadata is valid data, i.e. the index metadata is correct data; the index metadata is invalid data, and the index metadata is error data; for the effective index metadata, determining the corresponding template to be processed as an effective template, and executing a data query method to generate a target query statement; and for the invalid index metadata, the corresponding template to be processed is an invalid template, and detection and debugging are required.
In the embodiment of the invention, the correctness of the index metadata is determined by carrying out data verification on the index metadata, so that whether the index template is an effective template is determined, and the generation error of the target query statement caused by the invalidation of the index template can be avoided, thereby improving the generation efficiency and the accuracy of the target query statement.
In a specific embodiment, the user query indexes corresponding to the data query requests sent by the user may be counts, sums and ratios, and the query limit conditions may be data corresponding to the Merchant with the query name Merchant B, and the date is 2023, 10, 1, and 2023, 10, 31; a single index template 108 for summation, a single index template 109 for counting, and a composite index template 112 for rationing are determined from the index system.
For the data query request, the query sentence generated by the index template 108 is shown in fig. 7, the query sentence generated by the index template 109 is shown in fig. 8, and the query sentence generated by the index template 110 is shown in fig. 9; firstly, carrying out a first optimization process, namely merging SQL sentences corresponding to the single index templates 108 and 109 shown in fig. 7 and 8 to obtain a merged single index template, wherein in the merging process, as shown in fig. 10, due to the change of table aliases, proper rewrite is required for index expressions, and after the first optimization process, the scanning times of a data table are reduced to 2 times; further, a second optimization process is performed, and the combined single index template and the composite index template 112 are combined to obtain a target query sentence, as shown in fig. 11; through the process, a plurality of index templates are combined, so that the scanning times of the data table are reduced to 1 time, and the query efficiency is improved.
The embodiment of the invention also provides a device for inquiring data, as shown in fig. 12, the device comprises:
a request receiving module 1210, configured to receive a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
a data packaging module 1220, configured to package the user query index and the query constraint into a data query function;
a template determination module 1230 for determining at least one index template to be processed from a plurality of index templates based on the user query index;
template merging module 1240, configured to, when the number of the at least one index template to be processed is multiple and similar index templates exist in the multiple index templates to be processed, perform template merging processing on the similar index templates based on the data query function, so as to obtain a merged index template;
statement determination module 1250, configured to obtain a target query statement corresponding to the data query request based on the data query function, the combined index template, and the remaining index templates; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
In other embodiments, the apparatus further comprises:
the dimension information acquisition module is used for respectively acquiring dimension information corresponding to each index template to be processed;
the similarity template determining module is used for determining the to-be-processed index templates with consistent dimension information as the similarity index templates in the plurality of to-be-processed index templates based on the plurality of dimension information.
In other embodiments, the template merge module 1240 further comprises:
the code compiling module is used for compiling codes of the similar index templates based on the data query function to obtain compiled index templates;
and the template processing module is used for carrying out template merging processing on the compiled index templates according to the sequence of the single index template and the composite index template in sequence to obtain the merged index template.
In other embodiments, the apparatus further comprises:
the program acquisition module is used for acquiring an original execution program; the original execution program is used for executing data query;
the program updating module is used for updating the original execution program based on the target query statement to obtain a target execution program under the condition that the original execution program does not meet the data query request;
And the data return module is used for returning target query data corresponding to the data query request to the user based on the target execution program.
In other embodiments, the apparatus further comprises:
the query statement generating module is configured to obtain, when the number of the at least one index template to be processed is multiple and similar index templates do not exist in the multiple index templates to be processed, the target query statement based on the data query function and the multiple index templates to be processed.
In other embodiments, the apparatus further comprises:
the permission detection module is used for carrying out inquiry permission detection on the user based on the user identifier to obtain a permission detection result;
and the user determining module is used for determining that the user is a legal user under the condition that the permission detection result indicates that the user has the index query permission.
In other embodiments, the apparatus further comprises:
the index data acquisition module is used for acquiring index metadata corresponding to the at least one index template to be processed; the index metadata are description data corresponding to the index templates to be processed;
The data verification module is used for respectively carrying out data verification on the index metadata to obtain a data verification result;
and the effective template determining module is used for determining that the index template to be processed corresponding to the effective data is an effective template under the condition that the index metadata is indicated as the effective data by the data detection result.
The device and method embodiments in the device embodiments are based on the same inventive concept, and are used for implementing the method for querying data.
The embodiment of the invention also provides electronic equipment, which comprises: a processor and a memory having stored therein at least one instruction, at least one program, code set or instruction set loaded and executed by the processor to implement a method of data querying as in any of the method embodiments.
Embodiments of the present invention also provide a storage medium that may be disposed in a server to hold at least one instruction, at least one program, a set of codes, or a set of instructions for implementing a method of data querying as in any of the method embodiments, the at least one instruction, the at least one program, the set of codes, or the set of instructions being loaded and executed by the processor to implement a method of data querying as in any of the method embodiments.
Alternatively, in an embodiment of the present invention, the storage medium may be located on at least one network server of a plurality of network servers of a computer network. Alternatively, in an embodiment of the present invention, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
According to the embodiment provided by the invention, in the invention, at least one index template to be processed is determined from a plurality of index templates based on the user query index in the data query request sent by the user, so that the efficiency and the correctness of determining the index templates can be improved; packaging the user query indexes and the query limiting conditions into a data query function, and further processing the index templates to be processed based on the data query function, so that the index templates can be personalized processed, and the suitability of the generated target query statement and the data query request is improved; the similar index templates in the index templates to be processed are combined, repeated codes in the index templates can be reduced, repeated access of the repeated codes to the data table is avoided, the scanning times of the data table are reduced, and the execution efficiency of the target query statement is optimized.
It should be noted that: the foregoing description of various embodiments of the present disclosure has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the various embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the various embodiments described. The terminology used herein was chosen in order to best explain the principles of the embodiments, the practical application, or the technical improvement in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (10)

1. A method of data querying, the method comprising:
receiving a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
packaging the user query indexes and the query limiting conditions into a data query function;
determining at least one index template to be processed from a plurality of index templates based on the user query index;
when the number of the at least one index template to be processed is multiple and similar index templates exist in the multiple index templates to be processed, carrying out template merging processing on the similar index templates based on the data query function to obtain merged index templates;
Obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
2. The method of claim 1, wherein each index template to be processed corresponds to a piece of dimension information;
the method comprises the steps of:
respectively acquiring dimension information corresponding to each index template to be processed;
and determining the index templates to be processed with consistent dimension information as the similar index templates in the index templates to be processed based on the dimension information.
3. The method of claim 2, wherein the index template types include a single index template and a composite index template; the single index template is an index template for executing one processing task, and the composite index template is an index template for executing a plurality of processing tasks;
the step of carrying out template merging processing on the similar index templates based on the data query function to obtain merged index templates comprises the following steps:
Code compiling is carried out on the similar index templates based on the data query function, and compiled index templates are obtained;
and sequentially carrying out template merging treatment on the compiled index templates according to the sequence of the single index template and the composite index template to obtain the merged index template.
4. The method according to claim 1, wherein after obtaining the target query statement corresponding to the data query request, the method comprises:
acquiring an original execution program; the original execution program is used for executing data query;
under the condition that the original execution program does not meet the data query request, updating the original execution program based on the target query statement to obtain a target execution program;
and returning target query data corresponding to the data query request to the user based on the target execution program.
5. The method of claim 1, wherein the method further comprises:
and under the condition that the number of the at least one index template to be processed is multiple and similar index templates do not exist in the multiple index templates to be processed, obtaining the target query statement based on the data query function and the multiple index templates to be processed.
6. The method according to claim 1, wherein the data query request further comprises a user identifier;
after receiving the data query request sent by the user, the method further comprises:
performing query permission detection on the user based on the user identifier to obtain a permission detection result;
and under the condition that the permission detection result indicates that the user has the index query permission, determining that the user is a legal user.
7. The method of claim 1, wherein the method further comprises:
acquiring index metadata corresponding to the at least one index template to be processed; the index metadata are description data corresponding to the index templates to be processed;
respectively carrying out data verification on the index metadata to obtain a data verification result;
and under the condition that the data detection result indicates that the index metadata is effective data, determining an index template to be processed corresponding to the effective data as an effective template.
8. An apparatus for querying data, the apparatus comprising:
the request receiving module is used for receiving a data query request sent by a user; the data query request comprises a user query index and a query limiting condition;
The data packaging module is used for packaging the user query indexes and the query limiting conditions into a data query function;
the template determining module is used for determining at least one index template to be processed from a plurality of index templates based on the user query index;
the template merging module is used for carrying out template merging processing on the similar index templates based on the data query function under the condition that the number of the at least one index template to be processed is multiple and the similar index templates exist in the multiple index templates to be processed, so as to obtain a merged index template;
the statement determining module is used for obtaining a target query statement corresponding to the data query request based on the data query function, the combined index template and the residual index template; the remaining index templates are index templates except the similar index templates in the plurality of index templates to be processed.
9. An electronic device comprising a processor and a memory having stored therein at least one instruction and at least one program, the at least one instruction and the at least one program being loaded and executed by the processor to implement the method of data querying of any of claims 1-7.
10. A computer storage medium having at least one instruction and at least one program stored therein, the at least one instruction and the at least one program loaded and executed by a processor to implement a method of data querying as claimed in any of claims 1-7.
CN202311737391.0A 2023-12-15 2023-12-15 Data query method, device, equipment and storage medium Pending CN117555919A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311737391.0A CN117555919A (en) 2023-12-15 2023-12-15 Data query method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311737391.0A CN117555919A (en) 2023-12-15 2023-12-15 Data query method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117555919A true CN117555919A (en) 2024-02-13

Family

ID=89821798

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311737391.0A Pending CN117555919A (en) 2023-12-15 2023-12-15 Data query method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117555919A (en)

Similar Documents

Publication Publication Date Title
CN108027833B (en) Method for creating structured data language query
KR102432104B1 (en) Systems and methods for determining relationships between data elements
Wilensky LispCraft
US7743071B2 (en) Efficient data handling representations
US10042921B2 (en) Robust and readily domain-adaptable natural language interface to databases
US20030177481A1 (en) Enterprise information unification
US20070239742A1 (en) Determining data elements in heterogeneous schema definitions for possible mapping
CN110795455A (en) Dependency relationship analysis method, electronic device, computer device and readable storage medium
JP2007149096A (en) Data element naming system and method
US20080208874A1 (en) Handling multi-dimensional data including writeback data
CN110795524A (en) Main data mapping processing method and device, computer equipment and storage medium
Vajk et al. Automatic NoSQL schema development: A case study
US7711675B2 (en) Database simulation of data types
Gui et al. IFC-based partial data model retrieval for distributed collaborative design
CN115599359A (en) Code generation method, device, equipment and medium
US11222170B2 (en) Spreadsheet with unit parsing
EP1383055A2 (en) Map and data location provider
US10942892B2 (en) Transport handling of foreign key checks
CN117555919A (en) Data query method, device, equipment and storage medium
US20230195792A1 (en) Database management methods and associated apparatus
CN113934729A (en) Data management method based on knowledge graph, related equipment and medium
CN115617773A (en) Data migration method, device and system
Hulten et al. A simulation model for performance analysis of large shared data bases
Belic et al. User‐friendly web application for bibliographic material processing
US8250090B2 (en) Method for performing message-based distributed computing, involves executing expression of matched message response on members identified by set instance definition using dimension values derived from message

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination