A method and apparatus for configuring a query template
By configuring query templates and using a device, query units and their costs are generated based on query requests and user instructions. The display area module and query template are combined, which solves the problems of low query efficiency and poor user experience caused by the independence of the database and query components, and realizes efficient multi-data source query.
Patent Information
- Application Number
- CN202111216773.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-19
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2041-10-19
AI Technical Summary
In existing technologies, the large variety and independence of databases and query components make the process of querying data cumbersome, inefficient, and result in a poor user experience.
A method and apparatus for configuring query templates are provided. The target data source is determined by the query request, the query unit and its cost are generated according to the user's instructions, the display area module and the query template are combined, and the query template is used to complete data queries for various types of data sources.
It improves the efficiency of data querying and the user experience, and simplifies the data querying process for various types of data sources.
Smart Images

Figure CN113886423B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a method and device for configuring a query template. BACKGROUND
[0002] With the development of information technology, the types of databases and the amount of data stored in the databases are increasing. When querying data from a database, a user usually uses query components such as Impala and Phoenix to query data. However, because the types of databases and query components are numerous and independent of each other, the process of querying data by a user is relatively complicated, which leads to low efficiency of querying data and poor user experience. SUMMARY
[0003] Therefore, embodiments of the present application provide a method and device for configuring a query template to solve the problems of low efficiency and poor user experience in the prior art.
[0004] To achieve the above object, embodiments of the present application provide the following technical solutions.
[0005] A method for configuring a query template is disclosed in a first aspect of embodiments of the present application, and the method comprises the following steps.
[0006] According to a query request, a target data source is determined from a plurality of data sources that have been classified in advance;
[0007] A query field and a display field corresponding to a data table are generated by using a data table name entered by a user according to the target data source;
[0008] In response to a first configuration instruction of the user, a corresponding query unit is generated according to the query field and the display field, and the query unit is a single-table query unit or a join-table query unit;
[0009] A query cost of the query unit is determined by using a preset basic query cost of the target data source and the query field, or by using a preset query statement;
[0010] In response to a second configuration instruction of the user, any query unit is combined to obtain a corresponding display area module, and a corresponding display area cost is determined by using the query cost of the query unit combined into the display area module;
[0011] In response to a third configuration instruction of the user, any display area module is combined to obtain a corresponding query template, and a corresponding total query cost is determined by using the display area cost of the display area module combined into the query template;
[0012] In response to a fourth configuration instruction of the user, the query template is configured into a corresponding subject module.
[0013] Preferably, the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source.
[0014] The data table name entered by the user according to the target data source is used to generate query fields and display fields corresponding to the data table, including:
[0015] In the case that the target data source is a phoenix data source, the secondary index table name entered by the user is used to determine query fields corresponding to the data table from rowkey fields and phoenix secondary index fields, and to determine display fields corresponding to the data table from all fields.
[0016] In the case that the target data source is a sybase data source, an oracle data source or an impala data source, the data table name entered by the user is used to determine query fields and display fields corresponding to the data table from all fields.
[0017] Preferably, in response to the first configuration instruction of the user, the query unit is generated according to the query fields and the display fields, including:
[0018] In response to the first configuration instruction of the user, the selected query fields and display fields are used to generate a single-table query unit.
[0019] And / or,
[0020] In response to the first configuration instruction of the user, the selected multiple single-table query units are used to generate a join-table query unit.
[0021] Preferably, the query unit is determined according to the preset basic query overhead of the target data source and the query fields, or according to a preset query statement, including:
[0022] In the case that the query unit is a single-table query unit, the query overhead of the query unit is determined according to the type of the target data source, in combination with the type and number of the query fields constituting the single-table query unit.
[0023] In the case that the query unit is a join-table query unit, the query overhead of the query unit is determined according to a preset query statement corresponding to the join-table query unit.
[0024] Preferably, after the query overhead of the query unit is determined, the method further includes:
[0025] if the query cost of the query unit is greater than the cost threshold, sending warning information.
[0026] Preferably, in response to a third configuration instruction of the user, combining any of the display area modules to obtain a corresponding query template, and determining a corresponding total query cost by using display area costs of the display area modules combined into the query template.
[0027] According to the total query cost corresponding to the query template, generating a single-page list query length corresponding to the query template.
[0028] Preferably, after configuring the query template into the corresponding theme module in response to a fourth configuration instruction of the user, the method further comprises:
[0029] In response to a selection instruction of the user or other users, determining a target query template in a target theme module from a plurality of theme modules;
[0030] Using the target query template to perform data query from a specified data source, and returning a data query result to the front end for encapsulation processing.
[0031] Preferably, before determining a target data source from a plurality of data sources that have been pre-classified according to a query request, the method further comprises:
[0032] For the plurality of data sources that have been pre-classified, configuring a data source connection tool corresponding to each of the data sources.
[0033] The second aspect of the embodiment of the application discloses a device for configuring a query template, and the device comprises:
[0034] A first determining unit is configured to determine a target data source from a plurality of data sources that have been pre-classified according to a query request.
[0035] A first generating unit is configured to generate a query field and a display field corresponding to a data table by using a data table name entered by a user according to the target data source.
[0036] A second generating unit is configured to generate a corresponding query unit according to the query field and the display field in response to a first configuration instruction of the user, wherein the query unit is a single-table query unit or a join-table query unit.
[0037] A second determining unit is configured to determine a query cost of the query unit by using a preset basic query cost of the target data source and the query field, or by using a preset query statement.
[0038] a first processing unit, configured to combine any of the query units to obtain a corresponding display area module in response to a second configuration instruction of the user, and to determine a corresponding display area overhead by using query overheads of the query units combined into the display area module;
[0039] a second processing unit, configured to combine any of the display area modules to obtain a corresponding query template in response to a third configuration instruction of the user, and to determine a corresponding total query overhead by using display area overheads of the display area modules combined into the query template;
[0040] a configuration unit, configured to configure the query template into a corresponding theme module in response to a fourth configuration instruction of the user.
[0041] Preferably, the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source.
[0042] The first generating unit is specifically configured to: in the case that the target data source is a phoenix data source, determine query fields corresponding to a data table from a rowkey field and a phoenix secondary index field by using a secondary index table name entered by a user, and determine display fields corresponding to the data table from all fields; and in the case that the target data source is a sybase data source, an oracle data source or an impala data source, determine query fields and display fields corresponding to a data table from all fields by using a data table name entered by a user.
[0043] Based on the above method and device for configuring a query template provided by the embodiment of the application, the method is as follows: determining a target data source from a plurality of data sources classified in advance according to a query request; generating a query field and a display field corresponding to a data table by using a data table name entered by a user according to the target data source; generating a corresponding query unit according to the query field and the display field in response to a first configuration instruction of the user; determining a query cost of the query unit by using a preset basic query cost of the target data source and the query field, or by using a preset query statement; combining any query unit to obtain a corresponding display area module and determining a corresponding display area cost by using the query cost of the query unit combined into the display area module in response to a second configuration instruction of the user; combining any display area module to obtain a corresponding query template and determining a corresponding total query cost by using the display area cost of the display area module combined into the query template in response to a third configuration instruction of the user; and configuring the query template into a corresponding theme module in response to a fourth configuration instruction of the user. In the scheme, the target data source is determined by using the query request; the query unit and the corresponding query cost thereof are generated according to the instruction and the data table name entered by the user; the display area module and the corresponding display area cost thereof are determined by using the query unit and the corresponding query cost thereof; the query template and the corresponding total query cost thereof are determined according to the display area module and the corresponding display area cost thereof; and the query template is configured into the theme module. When data query is performed, the user can complete data query of various types of data sources by using the query template, thereby improving data query efficiency and user experience. BRIEF DESCRIPTION OF DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, hereinafter, a brief introduction will be given to the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only embodiments of the application, and for those skilled in the art, other drawings can also be obtained without creative effort based on the drawings provided.
[0045] Figure 1 A flowchart of a method for configuring a query template provided by the embodiment of the application;
[0046] Figure 2 A flowchart of generating a query unit and the corresponding query cost thereof provided by the embodiment of the application;
[0047] Figure 3 A structural block diagram of a device for configuring a query template provided by the embodiment of the application. DETAILED DESCRIPTION
[0048] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be described clearly and completely. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments of the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative effort are within the scope of the present application.
[0049] In the present application, the terms "comprising", "containing" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitations, the element defined by the sentence "including a…" does not exclude the presence of other identical elements in the process, method, article or equipment including the element.
[0050] As known from the background, when querying data from a database, a user needs to use corresponding components to query data. However, due to the large number of databases and query components and their independence, the process of querying data by the user is relatively complicated, resulting in low efficiency of querying data and poor user experience.
[0051] Therefore, the embodiments of the present application provide a method and device for configuring a query template, which determines a target data source by using a query request. According to the instruction and data table name entered by the user, a query unit and its corresponding query overhead are generated. By using the query unit and its corresponding query overhead, a display area module and its corresponding display area overhead are determined. According to the display area module and its corresponding display area overhead, a query template and its corresponding total query overhead are determined. The query template is configured into a theme module. When querying data, the user can complete data query of various types of data sources through the query template, so as to improve the efficiency of data query and user experience.
[0052] It should be noted that in the embodiments of the present application, the query overhead refers to quantitative data used to evaluate data such as query efficiency, response time, CPU usage and throughput.
[0053] Referring to Figure 1 , a flowchart of a method for configuring a query template provided by the embodiments of the present application is shown, and the method comprises:
[0054] Step S101: determining a target data source from a plurality of data sources pre-classified according to a query request.
[0055] It should be noted that the current common different data sources use different sql queries, for example: for sybase data source and oracle data source, the query syntax between the two data sources is different and the sensitivity to case is also different; for example: impala data source and phoenix data source, the two data sources can be used for querying Hive table and HBase table, the query syntax between the two data sources is different. Therefore, it is necessary to classify each data source in advance, and divide each data source into relational database data source (such as sybase data source and oracle data source) and non-relational database data source (such as impala data source and phoenix data source) according to the type of connection library.
[0056] It should be further noted that when querying data using a data source, a specific data source connection tool is required. In some specific embodiments, after classifying each data source, a data source connection tool corresponding to each data source is configured for the plurality of data sources classified.
[0057] Since different query requests correspond to different data sources, and the query request carries corresponding data source information. Therefore, in the process of implementing step S101, according to the query request, the target data source corresponding to the query request (i.e. the data source selected by the user) is determined from the plurality of data sources classified in advance, and the preset basic query overhead corresponding to the target data source is obtained. The basic query overhead can be used to judge the query efficiency.
[0058] It should be noted that different data sources can set a basic query overhead corresponding thereto (equivalent to an initial value of the query overhead), which can be set according to actual conditions, and is not limited herein.
[0059] Step S102: generating the query field and the display field corresponding to the data table using the data table name entered by the user according to the target data source.
[0060] In the process of implementing step S102, the data table name entered by the user according to the target data source is obtained, and the query field and the display field corresponding to the data table are generated according to the obtained data table name, for example: if the target data source is a phoenix data source, the query field and the display field configurable by the data table are generated according to the secondary index table name entered by the user.
[0061] It can be understood that different data sources generate query fields and display fields in different ways, that is, according to the actual situation of the target data source to determine how to generate the corresponding query field and display field.
[0062] In some embodiments, the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source; in the case where the target data source is a phoenix data source, the query field corresponding to the data table is determined from the rowkey field and the phoenix secondary index field, and the display field corresponding to the data table is determined from all the fields, by using the secondary index table name entered by the user; in the case where the target data source is a sybase data source, an oracle data source or an impala data source, the query field and the display field corresponding to the data table are determined from all the fields, by using the data table name entered by the user.
[0063] That is, when the target data source is a phoenix data source, the user needs to enter the secondary index table name, and the query field is determined from the rowkey field and the phoenix secondary index field, and the display field is determined from all the fields, according to the secondary index table name. When the target data source is a sybase data source, an oracle data source or an impala data source, the query field and the display field can be determined from all the fields.
[0064] It can be understood that the above content about which data source (phoenix data source, sybase data source, oracle data source or impala data source) the target data source is, is only for example, and the target data source can also be other data sources, which are not listed one by one here.
[0065] It should be noted that when the target data source is a phoenix data source, the overhead of the rowkey field (that is, the query overhead of the field) is less than the overhead of the phoenix secondary index field. When the target data source is a sybase data source or an oracle data source, the overhead of the index field in the query field is less than the overhead of the ordinary field. When the target data source is an impala data source, the overhead of each field in the query field is the same.
[0066] It can be understood that the overhead of the field can indicate the amount of computing resources occupied when querying a certain specific field.
[0067] Step S103: In response to the first configuration instruction of the user, a corresponding query unit is generated according to the query field and the display field.
[0068] It should be noted that the query unit is a single table query unit or a join table query unit.
[0069] After the configuration of the query fields and the display fields is completed, the corresponding query unit (which can be multiple) can be generated according to the query fields and the display fields selected by the user. In the process of specifically implementing step S103, a single-table query unit is generated by using the selected query fields and display fields in response to the first configuration instruction of the user; and / or, a join-table query unit is generated by using the selected multiple single-table query units in response to the first configuration instruction of the user.
[0070] That is, when the corresponding query unit is generated in response to the first configuration instruction of the user, if the first configuration instruction indicates that the generated query unit is a single-table query unit, the corresponding single-table query unit is generated according to the query fields and the display fields selected by the user, that is, the single-table query unit is composed of the query fields and the display fields. When the corresponding query unit is generated in response to the first configuration instruction of the user, if the first configuration instruction indicates that the generated query unit is a join-table query unit, the join-table query unit is generated according to the multiple single-table query units selected by the user, that is, the join-table query unit is composed of the multiple previously generated single-table query units.
[0071] For example, the user has generated multiple single-table query units by the first configuration instruction, when the query requirement of the user involves join-table query of the same data source, the user drags and associates any number (at least two) of the previously generated single-table query units and triggers the first configuration instruction, fills the association part between the associated single-table query units with the preset query statement, and combines the associated single-table query units to obtain the join-table query unit.
[0072] It should be noted that the single-table query unit is specifically used for querying a certain data table.
[0073] Step S104: determining the query cost of the query unit by using the preset basic query cost and the query fields of the target data source, or by using the preset query statement.
[0074] In the process of specifically implementing step S104, after the corresponding query unit is generated in response to the first configuration instruction of the user, the query cost of the generated query unit needs to be determined. In the specific implementation, the query cost of the query unit is determined by using the preset basic query cost and the query fields of the target data source, or by using the preset query statement.
[0075] It can be understood that, as known from the above content, the query unit is a single-table query unit or a join-table query unit, and the way of calculating the query cost of the single-table query unit is different from the way of calculating the query cost of the join-table query unit.
[0076] In some embodiments, when the query unit is a single-table query unit, the query cost of the query unit (i.e., the single-table query unit) is determined according to the type of the target data source, in combination with the types and quantities of the query fields constituting the single-table query unit.
[0077] As can be seen from the above, when the associated single-table query units are used to generate the join-table query unit, the preset query statement is filled in the association part between the associated single-table query units. The query statement filled in can be used to verify whether the join query has excessive cost and whether there is a performance problem, and the query statement can also be used to calculate the query time.
[0078] When the query unit is a join-table query unit, the query cost of the query unit (i.e., the join-table query unit) is determined using the preset query statement corresponding to the join-table query unit. Specifically, when the query unit is a join-table query unit, the query time can be calculated according to the preset query statement corresponding to the join-table query unit, the query efficiency can be estimated according to the query time, and the query cost of the query unit (i.e., the join-table query unit) can be generated according to the query efficiency.
[0079] Preferably, after the query cost of the query unit is determined, if the query cost of the query unit is greater than the cost threshold, a warning message is sent.
[0080] In some embodiments, when the query unit is a single-table query unit, if the query cost of the query unit is greater than the cost threshold, the content of the warning message sent indicates that the query statement has a performance problem and cannot be used. When the query unit is a join-table query unit, if the query cost of the query unit is greater than the cost threshold, the content of the warning message sent indicates that the statement has a performance problem and cannot be used, so as to avoid problems such as database lock caused by the association of multiple tables.
[0081] It should be noted that the user pre-configures a display framework, which is divided into a theme module, a query template, and a display area module in sequence. The user needs to configure the contents of the display area module, the query template, and the theme module in sequence. The configuration process is described in detail in the following steps S105 to S107.
[0082] Step S105: In response to a second configuration instruction of the user, any query unit is combined to obtain a corresponding display area module, and the query cost of the query unit combined into the display area module is used to determine the corresponding display area cost.
[0083] In the process of implementing step S105, the user can select any (single or multiple) query unit from all the generated query units (single table query unit and join table query unit) and trigger a second configuration instruction. In response to the second configuration instruction of the user, the user-selected any query unit is combined to obtain a corresponding display area module. For example, the user-selected any single table query unit and / or join table query unit is combined to obtain a corresponding single display area module, that is, any single table query unit and / or join table query unit is selected and combined each time to obtain a display area module.
[0084] After generating the display area module, the query overhead of the query unit combined into the display area module is used to determine the display area overhead corresponding to the display area module (that is, the query overhead of the display area module). The determined display area overhead is part of the attribute of the display area module.
[0085] In the above manner, a plurality of display area modules and their corresponding display area overheads are determined and obtained, and the configuration of the display area module is completed.
[0086] Step S106: In response to a third configuration instruction of the user, any display area module is combined to obtain a corresponding query template, and the display area overhead of the display area module combined into the query template is used to determine the corresponding total query overhead.
[0087] In the process of implementing step S106, the user can select any (single or multiple) from all the generated display area modules and trigger a third configuration instruction. In response to the third configuration instruction of the user, the user-selected any display area module is combined to obtain a corresponding query template. For example, one or more display area modules selected by the user are combined to obtain a corresponding single query template, that is, any display area module is selected and combined each time to obtain a query template.
[0088] In some embodiments, in the process of combining any display area module to obtain a query template, the position, size, and color of each display area module constituting the query template, and the like, are configured in the query template.
[0089] After generating the query template, the display area overhead of the display area module combined into the query template is used to determine the total query overhead corresponding to the query template (that is, the query overhead of the query template).
[0090] Preferably, for each query template, a single-page list query length (that is, the number of returned data rows) corresponding to the query template is generated according to the total query overhead corresponding to the query template.
[0091] It should be noted that for each query template, the total query overhead corresponding to the query template and the single page list query length are taken as part of the properties of the query template; the user can adjust the content of the display area module constituting the query template according to the total query overhead corresponding to the query template and the single page list query length, so as to prevent the page from being deadlocked or the database from being locked.
[0092] In the above manner, the plurality of query templates and the corresponding total query overheads are determined, and the configuration of the query templates is completed.
[0093] Step S107: In response to a fourth configuration instruction of the user, the query template is configured into the corresponding theme module.
[0094] In the process of specifically implementing step S107, after the configuration of each query template is completed, the user can classify each query template according to actual needs and trigger a fourth configuration instruction; in response to the fourth configuration instruction of the user, the query template is configured into the corresponding theme module. In this way, the query templates of different categories are configured into different theme modules, and in subsequent data query, the user or other users can select the query template from any theme module for data query and display.
[0095] In the above manner, the query templates of different categories are configured into different theme modules, and the configuration of the theme module is completed.
[0096] Preferably, in response to a selection instruction of the user or other users, a target query template in a target theme module is determined from the plurality of theme modules; the target query template is used to query data from a specified data source, and the data query result is returned to the front end for encapsulation processing.
[0097] In some specific embodiments, in the process of querying data from the specified data source by using the target query template, the specified data source is classified according to the content displayed by the query page after the query page is generated; and different query methods are used for querying different specified data sources, to obtain corresponding data query results and return them to the front end for encapsulation processing.
[0098] For example, for the specified data sources such as sybase data source and oracle data source, the data query result obtained by querying according to the pre-configured sql query statement is returned to the front end for encapsulation processing. For the specified data sources such as Hive data source or HBase data source, impala and phoenix are respectively used for analysis and driving to complete the query according to the configuration of the specified data source, and the data query result obtained by querying is returned to the front end for encapsulation processing.
[0099] In the embodiment of the present application, the target data source is determined by the query request. The query unit and the corresponding query overhead are generated according to the instruction and the data table name entered by the user. The display area module and the corresponding display area overhead are determined by the query unit and the corresponding query overhead. The query template and the corresponding total query overhead are determined according to the display area module and the corresponding display area overhead. The query template is configured into the theme module. When the data query is performed, the user can complete the data query of various data sources through the query template in the theme module, thereby improving the data query efficiency and the user experience.
[0100] To better explain the above embodiment of the present application Figure 1 The process of generating the query unit and the corresponding query overhead involved in steps S103 and S104 is exemplified by the content shown in the following table. Figure 2
[0101] Referring to Figure 2 , a flowchart of generating the query unit and the corresponding query overhead provided by the embodiment of the present application is shown, which includes the following steps:
[0102] Step S201: The target data source is determined according to the query request. If the target data source is a phoenix data source, steps S202 to S204 are executed to complete the generation of the single-table query unit; if the target data source is other data sources (such as a sybase data source, an oracle data source or an impala data source), steps S205 to S207 are executed to complete the generation of the single-table query unit.
[0103] Step S202: The secondary index table name is obtained.
[0104] Step S203: The query field and the display field are determined according to the secondary index table name.
[0105] Step S204: The single-table query unit and the corresponding query overhead are determined according to the selected query field and the display field, and step S208 is executed.
[0106] Step S205: The data table name is obtained.
[0107] Step S206: The query field and the display field are determined according to the data table name.
[0108] Step S207: The single-table query unit and the corresponding query overhead are determined according to the selected query field and the display field, and step S208 is executed.
[0109] Step S208: Whether the table join query is needed is determined. If the table join query is needed, steps S209 to S213 are executed; if the table join query is not needed, the flow is ended.
[0110] Step S209: determining the associated multiple single-table query units.
[0111] In the implementation of step S209, the user can drag and associate the generated single-table query units, and the associated multiple single-table query units can be determined in response to the user's instruction.
[0112] Step S210: configuring the query statement of the association part between the associated multiple single-table query units.
[0113] Step S211: determining the query overhead according to the query statement.
[0114] Step S212: judging whether the query overhead is greater than the overhead threshold value. If the query overhead is greater than the overhead threshold value, return to step S208; if the query overhead is not greater than the overhead threshold value, execute step S213.
[0115] Step S213: generating a join-table query unit according to the associated multiple single-table query units, and ending the flow.
[0116] The method for configuring a query template provided in the above embodiment of the application Figure 1 corresponds to the method for configuring a query template provided in the above embodiment of the application Figure 3 The embodiment of the application further provides a structural block diagram of a device for configuring a query template, which comprises a first determining unit 301, a first generating unit 302, a second generating unit 303, a second determining unit 304, a first processing unit 305, a second processing unit 306 and a configuring unit 307.
[0117] The first determining unit 301 is configured to determine a target data source from a plurality of data sources classified in advance according to a query request.
[0118] The first generating unit 302 is configured to generate a query field and a display field corresponding to a data table by using a data table name entered by a user according to the target data source.
[0119] In the implementation, the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source; and the first generating unit 302 is specifically configured to: in the case where the target data source is a phoenix data source, determine the query field corresponding to the data table from a rowkey field and a phoenix secondary index field and determine the display field corresponding to the data table from all fields by using a secondary index table name entered by the user; and in the case where the target data source is a sybase data source, an oracle data source or an impala data source, determine the query field and the display field corresponding to the data table from all fields by using a data table name entered by the user. In the implementation, the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source; and the first generating unit 302 is specifically configured to: in the case where the target data source is a phoenix data source, determine the query field corresponding to the data table from a rowkey field and a phoenix secondary index field and determine the display field corresponding to the data table from all fields by using a secondary index table name entered by the user; and in the case where the target data source is a sybase data source, an oracle data source or an impala data source, determine the query field and the display field corresponding to the data table from all fields by using a data table name entered by the user.
[0120] The second generation unit 303 is used to respond to the user's first configuration instruction and generate the corresponding query unit based on the query field and the display field. The query unit can be a single-table query unit or a join-table query unit.
[0121] In a specific implementation, the second generation unit 303 is specifically used to: generate a single-table query unit using the selected query fields and display fields in response to the user's first configuration instruction; and / or, generate a joint-table query unit using the selected multiple single-table query units in response to the user's first configuration instruction.
[0122] The second determining unit 304 is used to determine the query cost of the query unit by using the preset basic query cost and query fields of the target data source, or by using the preset query statement.
[0123] In a specific implementation, the second determining unit 304 is specifically used to: determine the query cost of the query unit based on the type of the target data source and the type and number of query fields constituting the single-table query unit when the query unit is a single-table query unit; and determine the query cost of the query unit by using a preset query statement corresponding to the single-table query unit when the query unit is a join query unit.
[0124] The first processing unit 305 is configured to respond to the user's second configuration instruction by combining any number of query units to obtain a corresponding display area module, and to determine the corresponding display area cost by using the query cost of the query units combined into the display area module.
[0125] The second processing unit 306 is used to respond to the user's third configuration instruction, combine any number of display area modules to obtain a corresponding query template, and use the display area overhead of the display area modules combined into the query template to determine the corresponding total query overhead.
[0126] Configuration unit 307 is used to configure the query template into the corresponding topic module in response to the user's fourth configuration command.
[0127] In this embodiment of the invention, the target data source is determined using a query request. Based on the user-entered instructions and data table names, a query unit and its corresponding query cost are generated. Using the query unit and its corresponding query cost, a display area module and its corresponding display area cost are determined. Based on the display area module and its corresponding display area cost, a query template and its corresponding total query cost are determined. The query template is then configured in the theme module. When performing data queries, users can complete data queries from various data sources using the query template, improving data query efficiency and user experience.
[0128] Preferred, combined Figure 3 The device, as shown, also includes:
[0129] The sending unit is configured to send warning information if the query cost of the query unit is greater than the cost threshold.
[0130] Preferably, in combination with the content shown, the device further comprises: Figure 3 Preferably, in combination with the content shown, the device further comprises:
[0131] The third generating unit is configured to generate a single-page list query length corresponding to the query template according to the total query cost corresponding to the query template.
[0132] Preferably, in combination with the content shown, the device further comprises: Figure 3 Preferably, in combination with the content shown, the device further comprises:
[0133] The query unit is configured to determine a target query template in a target subject module from a plurality of subject modules in response to a selection instruction of a user or another user, and perform data query from a specified data source by using the target query template, and return a data query result to the foreground for encapsulation processing.
[0134] Preferably, in combination with the content shown, the device further comprises: Figure 3 Preferably, in combination with the content shown, the device further comprises:
[0135] The classification unit is configured to configure a data source connection tool corresponding to each data source for a plurality of data sources that have been pre-classified.
[0136] In summary, the embodiment of the present application provides a method and device for configuring a query template, which determines a target data source by using a query request. According to an instruction and a data table name entered by a user, a query unit and a corresponding query cost are generated. By using the query unit and the corresponding query cost, a display area module and a corresponding display area cost are determined. According to the display area module and the corresponding display area cost, a query template and a corresponding total query cost are determined. The query template is configured into a subject module. When data query is performed, the user can complete data query of various types of data sources by using the query template, thereby improving data query efficiency and user experience.
[0137] The various embodiments described in this specification are described in progressive order of complexity, from the simplest embodiment to more complex embodiments. Embodiments described in this specification can be understood, and implemented, by those skilled in the art with the benefit of the following description and practice of the disclosure without necessitating use of more complex embodiments. The same parts and features of the various embodiments described in this specification can be referred to by the same reference numerals in all figures of which their presence in some or all of the various embodiments is indicated, and each embodiment highlights the differences from other embodiments. In particular, the system or system embodiments are described more briefly than the method embodiments, as they are substantially similar to the method embodiments. The system and system embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e. they may be located at one place or distributed over multiple network units. Some or all of the modules can be selected to achieve the purpose of the embodiments according to actual needs. Those skilled in the art can understand and implement without creative labor.
[0138] The person skilled in the art will further appreciate that the units and algorithm steps of the examples described in connection with the embodiments disclosed herein can be realized in electronic hardware, computer software, or a combination of both. The disclosure has been described in terms of specific embodiments in order to clearly explain the interchangeability of hardware and software under these embodiments and to aid in understanding the disclosure. Whether such functionality is implemented in hardware or software depends on the particular application and design constraints imposed on the overall system. Skilled artisans can implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
[0139] The above description of disclosed embodiments enables a person skilled in the art to implement or use the invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method of configuring a query template, the method comprising: The method comprises: determining a target data source from a plurality of data sources pre-classified according to a query request; generating query fields and display fields corresponding to a data table using a data table name entered by a user according to the target data source; generating a corresponding query unit according to the query fields and the display fields in response to a first configuration instruction of the user, the query unit being a single-table query unit or a join-table query unit; determining a query cost of the query unit using a preset basic query cost of the target data source and the query fields, or using a preset query statement; combining any query units to obtain a corresponding display area module in response to a second configuration instruction of the user, and determining a corresponding display area cost using the query costs of the query units combined into the display area module; combining any display area modules to obtain a corresponding query template in response to a third configuration instruction of the user, and determining a corresponding total query cost using the display area costs of the display area modules combined into the query template; configuring the query template into a corresponding theme module in response to a fourth configuration instruction of the user; wherein the target data source is a phoenix data source, a sybase data source, an oracle data source or an impala data source; the generating of the query fields and the display fields corresponding to the data table using the data table name entered by the user according to the target data source comprises: in the case that the target data source is a phoenix data source, determining the query fields corresponding to the data table from a rowkey field and a phoenix secondary index field, and determining the display fields corresponding to the data table from all fields using the secondary index table name entered by the user; in the case that the target data source is a sybase data source, an oracle data source or an impala data source, determining the query fields and the display fields corresponding to the data table from all fields using the data table name entered by the user; the determining of the query cost of the query unit using the preset basic query cost of the target data source and the query fields, or using the preset query statement, comprises: in the case that the query unit is a single-table query unit, determining the query cost of the query unit according to the type of the target data source and the type and number of the query fields constituting the single-table query unit; in the case that the query unit is a join-table query unit, determining the query cost of the query unit using a preset query statement corresponding to the join-table query unit.
2. The method of claim 1, wherein, the generating of the corresponding query unit according to the query fields and the display fields in response to the first configuration instruction of the user comprises: generating a single-table query unit using the selected query fields and display fields in response to the first configuration instruction of the user; and / or generating a join-table query unit using a plurality of selected single-table query units in response to the first configuration instruction of the user. 3. The method of any one of claims 1 to 2, wherein, determining the query cost of the query unit, further comprising: if the query cost of the query unit is greater than the cost threshold, sending a warning message.
4. The method of claim 1, wherein, in response to the third configuration instruction of the user, combining any of the display area modules to obtain a corresponding query template, and determining a corresponding total query cost by using the display area costs of the display area modules combined into the query template; generating a single-page list query length corresponding to the query template according to the total query cost corresponding to the query template.
5. The method of claim 1, wherein, in response to the fourth configuration instruction of the user, configuring the query template into a corresponding theme module, further comprising: in response to the selection instruction of the user or other users, determining a target query template in a target theme module from a plurality of theme modules; performing data query from a specified data source by using the target query template, and returning a data query result to the front end for encapsulation processing.
6. The method of claim 1, wherein, before determining the target data source from the plurality of data sources that have been pre-classified according to the query request, further comprising: configuring a data source connection tool corresponding to each of the plurality of data sources that have been pre-classified.
7. An apparatus for configuring a query template, the apparatus comprising: The device comprises: a first determination unit configured to determine a target data source from a plurality of data sources that have been pre-classified according to a query request; a first generation unit configured to generate a query field and a display field corresponding to a data table by using a data table name entered by a user according to the target data source; a second generation unit configured to generate a corresponding query unit according to the query field and the display field in response to a first configuration instruction of the user, the query unit being a single-table query unit or a join-table query unit; a second determination unit configured to determine a query cost of the query unit by using a preset basic query cost of the target data source and the query field, or by using a preset query statement; a first processing unit configured to combine any of the query units to obtain a corresponding display area module in response to a second configuration instruction of the user, and to determine a corresponding display area cost by using the query costs of the query units combined into the display area module; a second processing unit configured to combine any of the display area modules to obtain a corresponding query template in response to a third configuration instruction of the user, and to determine a corresponding total query cost by using the display area costs of the display area modules combined into the query template; a configuration unit configured to configure the query template into a corresponding theme module in response to a fourth configuration instruction of the user; wherein the target data source is a phoenix data source, a sybase data source, an oracle data source, or an impala data source. The first generating unit is specifically configured to: in the case that the target data source is a phoenix data source, determining query fields corresponding to a data table from a rowkey field and a phoenix secondary index field and determining display fields corresponding to the data table from all fields by using a secondary index table name input by a user; in the case that the target data source is a sybase data source, an oracle data source or an impala data source, determining query fields and display fields corresponding to a data table from all fields by using a data table name input by a user; The second determining unit is specifically configured to: in the case that the query unit is a single table query unit, determining query cost of the query unit according to the type of the target data source and in combination with the type and quantity of the query fields constituting the single table query unit; in the case that the query unit is a join table query unit, determining query cost of the query unit by using a preset query statement corresponding to the join table query unit.
Citation Information
Patent Citations
Report template generation method and device
CN110807306A