A method, system, device and medium for generating chart data
By configuring field metadata information and data filtering conditions, and assembling and generating a structured query language, the problem of single query conditions and inconsistent input and output formats in the existing chart query technology is solved, flexible chart query and unified data format are realized, and the system is expanded and maintained.
Patent Information
- Application Number
- CN202210530216.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2042-05-16
AI Technical Summary
In the existing chart query technology, the query conditions are single, and different chart data cannot be flexibly queried and switched. At the same time, the input and output formats of traditional methods are not uniform, resulting in poor scalability and maintenance.
By obtaining query conditions, configuring the field metadata information and data filtering conditions of the pending data, assemble and generate a structured query language, performing the query language to obtain the result data, and formatting the result data to generate chart data.
It realizes the richness and flexibility of chart query conditions, unify the input and output format of chart data, and improves the scalability and maintenance of the system.
Smart Images

Figure CN114969193B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data visualization, and in particular to a method, system, device and medium for generating chart data. Background Art
[0002] Chart display controls such as bar charts, pie charts, and cross tables are used to present data. They are intuitive and easy to understand, and are widely used in scenarios such as reports and large-screen presentations.
[0003] There are various styles of chart controls, and the data structure of each chart is inconsistent. When using database table data as the data source to query and display chart data, the data filtering conditions are also various. The traditional approach is to customize SQL (Structured Query Language) query display for each chart. Once a business change occurs, all chart SQL may need to be reconstructed, which has poor scalability and maintainability. At the same time, the query conditions of traditional chart data are also very simple, and it is not possible to flexibly query and switch between different chart data. Summary of the invention
[0004] In order to overcome the problems of single query conditions and inconsistent input and output formats in existing chart query technologies, the purpose of the present invention is to provide a method, system, device and medium for generating chart data.
[0005] To achieve the above object, the present invention provides a method for generating chart data, the method comprising the following steps:
[0006] Get the query conditions;
[0007] Obtaining data to be processed based on a database table;
[0008] Configure the field metadata information and the first data filtering condition corresponding to the data to be processed based on the query condition;
[0009] Assembling and generating a structured query language based on the query condition, the field metadata information and the first data filtering condition;
[0010] Executing the structured query language in the data to be processed to obtain result data;
[0011] The result data is formatted to obtain chart data.
[0012] The principle of the present invention is as follows: first, query conditions are obtained, query information is obtained based on the query conditions, data to be processed, i.e., query objects, are obtained according to the database table, field metadata information and first data filtering conditions corresponding to the data to be processed are configured based on the query conditions, wherein the field metadata information and the first data filtering conditions are configured to define general parameters that satisfy chart queries, and then a structured query language is generated based on the data to be processed, the field metadata information, and the first data filtering conditions, and the structured query language is executed in the data to be processed to obtain result data that satisfies the query conditions, and finally the result data is formatted to obtain chart data, which is provided to the chart component for rendering and drawing. By configuring the field metadata information and assembling the structured query language, the unified data input format is achieved; by configuring the first data filtering conditions and assembling the structured query language, the chart query conditions are enriched, and flexible and complex chart queries can be performed; by formatting the result data, the query results are unified, and the unified data output format is achieved.
[0013] Preferably, in this method, the field metadata information includes the name of the field and the business attributes of the field. The field metadata information indicates the name of the field to be queried and the business attributes of each field.
[0014] Preferably, in this method, if the first data filtering condition is a first preset condition, the first data filtering condition is implemented by a combination of several preset mathematical operations; if the first data filtering condition is a second preset condition, the first data filtering condition is implemented by specifying a database function.
[0015] Among them, the first data filtering condition limits two implementation methods, one is to be implemented through a combination of several preset mathematical operations, and the other is to be implemented through a specified database function. By judging the type of the first data filtering condition, a corresponding method is selected to implement the first data filtering condition.
[0016] Preferably, in the method, the structured query language includes a selection part, a source part and a condition part. The above preferred embodiment illustrates the components of the structured query language.
[0017] Preferably, in this method, the selection part is generated by: obtaining query information based on the query condition, and obtaining the selection part based on the query information. The above preferred method illustrates that the selection part in the structured query language can be quickly and accurately generated based on the query information.
[0018] Preferably, in this method, the generation method of the selected part specifically includes:
[0019] By parsing the field metadata information, determining the aggregation type in the field metadata information, selecting the corresponding aggregation function based on the aggregation type to perform aggregation processing on the fields in the query information to obtain an aggregation result, and obtaining the selected part based on the aggregation result and the query information; or determining whether there is a preset function field in the field metadata information, if there is a preset function field, applying the corresponding preset function to the fields in the query information to obtain a processing result, and obtaining the selected part based on the processing result and the query information.
[0020] Among them, the "aggregation type" field and the "preset function" field in the field metadata information are input setting parameters. If they exist, response processing will be performed, and if not, no processing will be performed. Through the above preferred method, the generation method of the selected part is optimized.
[0021] Preferably, in this method, the source portion is generated in a manner comprising:
[0022] Based on the database table, the database table name is formatted using corresponding data delimiters to obtain a first database table name, and the source part is obtained based on the first database table name. In this way, the source part in the structured query language can be generated quickly and accurately.
[0023] Preferably, in the present method, the method for generating the conditional part includes: traversing each condition in the first data filtering condition, converting each condition in the first data filtering condition into a corresponding database language, splicing each condition in the first data filtering condition based on the connection type in the field metadata information to obtain a second data filtering condition, and obtaining the conditional part based on the second data filtering condition.
[0024] Among them, each condition in the first data filtering condition is a condition field. When assembling the structured query language, each condition in the first data filtering condition needs to be converted into a corresponding database language to facilitate the subsequent execution of the structured query language. In the field metadata information, there is a "connection type" field that is an input setting parameter, and the splicing condition is a splicing condition defined according to the standard SQL specification. Through the above preferred method, the query conditions are enriched and complex and flexible chart queries are realized.
[0025] Preferably, in this method, the structured query language generation method includes:
[0026] Process the structured query language to determine whether there is an aggregate function field in the field metadata information. If so, group the data to be processed; determine whether there is a sorting field in the field metadata information. If so, sort the data to be processed; determine whether there are top N fields in the field metadata information. If so, perform top N statistical processing on the data to be processed; determine whether there is a deduplication field in the field metadata information. If so, deduplication the data to be processed; determine whether there is a paging field in the field metadata information. If so, paging the data to be processed.
[0027] Among them, the "aggregation function" field, "sort" field, "top N items" field, "de-duplicate" field and "paging" field in the field metadata information are input setting parameters. By judging whether the field metadata information exists, if so, a response processing is performed, and if not, no processing is performed. Through the above preferred method, the optimized processing of the structured query language is realized.
[0028] Preferably, in this method, formatting the result data specifically includes:
[0029] Obtaining metadata information of the result data corresponding to the structured query language;
[0030] Traversing the metadata information of the result data to obtain field information of the result data, the field information including field name, field type and field position index;
[0031] Parse the result data, traverse the result set, parse the value corresponding to each field in the result data according to the field information, and format and convert the value corresponding to each field in the result data based on the data conversion template in the field metadata information.
[0032] Among them, metadata information of the result data is obtained, and the metadata information is traversed to obtain field information of the result data, wherein the field information includes field name, field type and field position index; based on the field information, corresponding data is found from the result set for parsing to obtain parsing results; finally, the parsing results are formatted and converted based on the data conversion template, thereby achieving a unified format for data output.
[0033] Preferably, in the method, formatting the result data further comprises: determining whether the amount of the chart data is greater than a preset threshold, and if so, paging the chart data; if not, directly outputting the chart data.
[0034] The above condition is set because if the amount of the chart data exceeds the limit, it will be inconvenient to display the chart. At this time, paging processing is required. In the actual query process, the data of a page is returned based on the data of that page that is needed.
[0035] Preferably, in this method, the method further comprises rendering and drawing a chart page based on the chart data using a chart component. Wherein, the chart data is displayed in the form of a chart through the above preferred method, thereby realizing visualization processing of the chart data.
[0036] The present invention also provides a system for generating chart data, the system comprising:
[0037] A first obtaining unit, used to obtain a query condition;
[0038] A second obtaining unit, used for obtaining the data to be processed based on the database table;
[0039] A configuration unit, configured to configure field metadata information and a first data filtering condition corresponding to the data to be processed based on the query condition;
[0040] An assembling unit, configured to assemble and generate a structured query language based on the query condition, the field metadata information and the first data filtering condition;
[0041] A third obtaining unit, configured to execute the structured query language in the data to be processed to obtain result data;
[0042] A processing unit is used to perform format processing on the result data to obtain chart data.
[0043] The present invention also provides a device for generating chart data, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for generating chart data when executing the computer program.
[0044] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating chart data are implemented.
[0045] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:
[0046] Based on the query conditions, by configuring the data filtering conditions for the data to be processed and subsequently assembling the structured query language, the conditions for chart queries are enriched, so that flexible and complex chart data queries can be performed;
[0047] By configuring the field metadata information of the data to be processed, assembling the structured query language and formatting the result data, the chart query input and output formats are unified. Queries of different charts can use the same set of query logic, and the front end can uniformly adapt the display of chart data. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of the present invention, and do not constitute a limitation on the embodiments of the present invention;
[0049] Figure 1 It is a schematic flow chart of the method for generating chart data in the present invention;
[0050] Figure 2 It is a schematic diagram of the composition of the system for generating chart data in the present invention. DETAILED DESCRIPTION
[0051] In order to more clearly understand the above-mentioned purpose, features and advantages of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0052] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those within the scope of this description. Therefore, the protection scope of the present invention is not limited to the specific embodiments disclosed below.
[0053] Embodiment 1
[0054] Please refer to Figure 1 , a method for generating chart data, the method comprising the following steps:
[0055] Get the query conditions;
[0056] Obtaining data to be processed based on a database table;
[0057] Configure the field metadata information and the first data filtering condition corresponding to the data to be processed based on the query condition;
[0058] Assembling and generating a structured query language based on the query condition, the field metadata information and the first data filtering condition;
[0059] Executing the structured query language in the data to be processed to obtain result data;
[0060] The result data is formatted to obtain chart data.
[0061] Among them, in this embodiment, the query condition is to query the number of adult male students / underage male students in each class who are not in Beijing, and only take the first ten records of the number of people. The database table is Table 1 class table (class table name t_class) and Table 2 student table (student table name t_student). Based on the class table and the student table, the data information to be processed is obtained. Based on the query condition, the field metadata information and data filtering conditions of the data to be processed are configured, which specifically include:
[0062] Table 1
[0063] c_id c_name 1 Class 1 2 Class 2
[0064] Table 2
[0065] s_id s_name s_gender s_age s_area c_id 1 Tom man 20 Chengdu 1 2 Bob man 17 Chengdu 1 3 Lisa woman 17 Chengdu 2 4 Rose woman 19 Chengdu 1 5 Jerry man 16 Chengdu 2 6 Bang man 20 Beijing 1 7 Mike man 17 Wuhan 2
[0066] The field metadata information is {Id: s_id, Name: student id, Type: numeric type, AggType: statistical quantity, FiledType: indicator}, {Id: s_age, Name: student age, Type: numeric type, FormatMask: s_age<18 minors; s_age>18 adults, FieldType: dimension, AdvanceCalc: grouping, Order: descending}, {Id: c_name, Name: class name, Type: string type, FiledType: dimension, AdvanceCalc: grouping}.
[0067] The data filtering conditions are {Column: s_gender; Operate: equal; Value: man; combinationType: and} (query for boys in the gender column and connect them with "and"), {Column: s_area; Operate: not equal; Value: Beijing; combinationType: and} (query for areas that are not equal to Beijing in the area column and connect them with "and"), {Column: t_student.c_id; Operate: equal; Value: t_class.c_id; combinationType: join} (query for data where c_id in the student table is equal to c_id in the class table and connect them).
[0068] Based on the class table, the student table, the field metadata information and the data filtering condition, SQL (Structured Query Language) is assembled and generated, specifically including:
[0069] Generate the SELECT part of the SQL to query the number of adults / minors in each class. Because it involves counting the number of people, the aggregate function COUNT is needed to count the number of people.
[0070] Generate the FROM part of SQL, obtain the student table name (t_student) from the student table, and use the corresponding data delimiter to perform format processing to obtain `t_student`, where the c_id in the student table corresponds to the c_id in the class table;
[0071] Generate the WHERE part of the SQL statement, with the restriction that the query is for male students who are not in Beijing.
[0072] Process the SQL: Because the field metadata information contains the aggregate function COUNT, the class category and age need to be grouped; because the field metadata information contains the OREDER field, the data needs to be sorted in descending order; finally, based on the query conditions, the number of query results returned is limited to 10.
[0073] The SQL language is executed in the class table and the student table to obtain result data as shown in Table 3. In Class 1, Tom is 20 years old and lives in Chengdu, Bob is 17 years old and lives in Chengdu, and in Class 2, Jerry is 16 years old and lives in Chengdu, and Mike is 17 years old and lives in Wuhan. The result data is processed to obtain chart data, including:
[0074] The metadata information of Table 3 is obtained, and the metadata information is traversed to obtain the field information, which includes the field name, field type and field position index. Based on the extracted field information, the corresponding data can be found from the result set for parse. Finally, based on the FormatMask (data conversion template) in the field metadata information, the response data is formatted and converted to obtain the chart data as shown in Table 4, where the number of minors in Class 1 is 1, the number of adults is 1, and the number of minors in Class 2 is 2.
[0075] Based on the data in Table 4, a chart page is rendered and drawn using a chart component. The chart component shown may be a bar chart component, a pie chart component, a line chart component, or other chart components. The corresponding chart component may be selected according to actual needs, and the embodiment of the present invention does not make any specific limitation.
[0076] Table 3
[0077] s_id s_name s_gender s_age s_area c_name 1 Tom man 20 Chengdu Class 1 2 Bob man 17 Chengdu Class 1 5 Jerry man 16 Chengdu Class 2 7 Mike man 17 Wuhan Class 2
[0078] Table 4
[0079] class category quantity Class 1 Minors 1 Class 1 adult 1 Class 2 Minors 2
[0080] Among them, please refer to Table 5, which is a field metadata information table, which includes the attribute name, attribute type, attribute function and necessity of the field. For example, id belongs to the string type, is the unique key of the field, and must be configured; name belongs to the string type, is the field alias, and must be configured; type belongs to the enumeration type, is the field type, and must be configured; aggType belongs to the enumeration type, is the database aggregation type, and is not required to be configured; filedType belongs to the numeric type, is the identification dimension, and must be configured; formatMask belongs to the string type, is the data conversion template, and is not required to be configured; advancedCalc belongs to the enumeration type, is the advanced calculation function, and is not required to be configured; order belongs to the numeric type, is ascending / descending order, and must be configured. In the field metadata information table, we have agreed that some configuration items must be configured, while some are optional. The setting of optional items can enrich the subsequent SQL assembly module, which means that in the actual query process, the field metadata information can be configured based on the query conditions.
[0081] Table 5
[0082]
[0083] Among them, please refer to Table 6, which is a data filtering condition table, and the data filtering condition table includes the attribute name, attribute type, attribute function and necessity of the condition. For example, column belongs to the string type, is the unique key of the field, and must be configured; operate belongs to the string type, is an operation symbol, and must be configured; value belongs to any type, is a value domain, and must be configured; combinationType belongs to the enumeration type, which refers to the connection method with the previous condition (and / or), which is not required to be configured; distinct belongs to the numeric type, which refers to whether to remove duplicates, which is not required to be configured; join belongs to the object type, which plays the role of connecting tables, and is not required to be configured; topN belongs to the numeric type, which refers to the top N data, which is not required to be configured; page belongs to the object type, which refers to the paging processing object, which is not required to be configured. In the data filtering condition table, we have agreed that some configuration items must be configured, while some are optional. The setting of optional items can enrich the subsequent SQL assembly module, which means that the data filtering conditions can be configured based on the query conditions.
[0084] Table 6
[0085]
[0086] Among them, if the first data filtering condition is the first preset condition, the first data filtering condition is implemented by a combination of several preset mathematical operations (for example, there are conditions such as "name contains Zhang", "age>20", "gender=female", "region=Chengdu", these conditions can be arbitrarily spliced together with "or" and "and" conditions), the first preset condition can be greater than, or less than, or equal to, or contain ordinary operation expression conditions, which can be judged according to actual needs, and the present invention does not make specific limitations; if the first data filtering condition is the second preset condition, the first data filtering condition is implemented by specifying a database function (such as average function AVG, sum function COUNT, maximum function MAX, minimum function MIN, which can be selected according to actual needs, and the present invention does not make specific limitations), the second preset condition can be grouping, or year-on-year or month-on-month, or average, or maximum value and other conditions with quantitative statistics, which can be judged according to actual needs, and the present invention does not make specific limitations).
[0087] Among them, by parsing the field metadata information, the aggregation type in the field metadata information is determined, and the corresponding aggregation function is selected based on the aggregation type to aggregate the fields in the query information to obtain an aggregation result. The selection part is obtained based on the aggregation result and the query information. There is an "aggregation type (aggType)" field in the field metadata information, which is an input setting parameter. The setting parameter is a dictionary, and its specific value corresponds to the function of the corresponding database, such as "COUNT" corresponds to "quantity statistics function COUNT()", "AVG" corresponds to "average statistics function AVG()", etc. The corresponding function can be selected according to actual needs, and the present invention does not make specific limitations; or it is determined whether there is a preset function field in the field metadata information. If there is a preset function field, the corresponding preset function is applied to the field in the query information to obtain a processing result. The selection part is obtained based on the processing result and the query information. It is determined whether there is an advanceCalc (advanced function) field in the field metadata information, which is an input setting parameter. The advanced function can be a set operation function, a sorting function, or an aggregation query function or other functions. The corresponding function can be selected according to actual needs, and the present invention does not make specific limitations.
[0088] Among them, based on the database table, the database table name is formatted using the corresponding data delimiter to obtain the first database table name, and the source part is obtained based on the first database table name. In the database, different types of data are generally stored in different tables, such as student information is stored in the student table t_student, and class information is stored in the class table t_class. Different database delimiters are inconsistent. For the same table name such as t_student, different delimiters may be used to output "`t_student`" or "[t_student]" or ""t_student"". There will be a dictionary of databases and delimiters. The corresponding delimiter is selected according to the database for formatting. The corresponding data delimiter can be selected to process the database table name according to actual needs. The present invention does not make specific limitations.
[0089] The generation method of the condition part includes: traversing each condition in the first data filtering condition, converting each condition in the first data filtering condition into the corresponding database language, splicing each condition in the first data filtering condition to obtain the second data filtering condition based on the connection type in the field metadata information, and obtaining the condition part based on the second data filtering condition. In the field metadata information, there is a "combination type (combinationType) field, which is an input setting parameter. The splicing processing of the conditions is based on the connection conditions defined in the annotation SQL specification (inner join, left join, right join, etc.). The corresponding connection conditions can be selected according to actual needs, and the present invention does not make specific limitations."
[0090] Embodiment 2
[0091] Please refer to Figure 2 , an embodiment of the present invention provides a system for generating chart data, the system comprising:
[0092] A first obtaining unit, used to obtain a query condition;
[0093] A second obtaining unit, used for obtaining the data to be processed based on the database table;
[0094] A configuration unit, configured to configure field metadata information and a first data filtering condition corresponding to the data to be processed based on the query condition;
[0095] An assembling unit, configured to assemble and generate a structured query language based on the query condition, the field metadata information and the first data filtering condition;
[0096] A third obtaining unit, configured to execute the structured query language in the data to be processed to obtain result data;
[0097] A processing unit is used to perform format processing on the result data to obtain chart data.
[0098] Embodiment 3
[0099] Embodiment 3 of the present invention provides a device for generating chart data, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method for generating chart data when executing the computer program.
[0100] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors, application-specific integrated circuits, field programmable gate arrays or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0101] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the position updating device of the dual-arm intelligent fitness equipment in the invention by running or executing the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card, a secure digital card, a flash memory card, at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0102] Embodiment 4
[0103] A fourth embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for generating chart data are implemented.
[0104] If the method generating device of the chart data is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be stored in a computer-readable storage medium through a computer program. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, point carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0105] The present invention has described the basic concepts. Obviously, for those skilled in the art, the above detailed disclosure is only for example and does not constitute a limitation of this specification. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements and corrections to this specification. Such modifications, improvements and corrections are suggested in this specification, so such modifications, improvements and corrections still belong to the spirit and scope of the exemplary embodiments of this specification.
[0106] At the same time, this specification uses specific words to describe the embodiments of this specification. For example, "one embodiment", "an embodiment", and / or "some embodiments" refer to a certain feature, structure or characteristic related to at least one embodiment of this specification. Therefore, it should be emphasized and noted that "one embodiment" or "an embodiment" or "an alternative embodiment" mentioned twice or more in different positions in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures or characteristics in one or more embodiments of this specification can be appropriately combined.
[0107] In addition, it will be understood by those skilled in the art that various aspects of this specification may be illustrated and described by a number of patentable categories or situations, including any new and useful process, machine, product or combination of substances, or any new and useful improvements thereto. Accordingly, various aspects of this specification may be performed entirely by hardware, entirely by software (including firmware, resident software, microcode, etc.), or by a combination of hardware and software. The above hardware or software may be referred to as "data blocks", "modules", "engines", "units", "components" or "systems". In addition, various aspects of this specification may be represented as a computer product located in one or more computer-readable media, which includes computer-readable program code.
[0108] A computer storage medium may include a propagated data signal containing computer program code, for example, in baseband or as part of a carrier wave. The propagated signal may be in a variety of forms, including electromagnetic, optical, etc., or a suitable combination. A computer storage medium may be any computer-readable medium other than a computer-readable storage medium, which can be connected to an instruction execution system, device or apparatus to communicate, propagate or transmit the program for use. The program code on the computer storage medium may be transmitted via any suitable medium, including radio, cable, fiber optic cable, RF, or similar media, or any combination of the above media.
[0109] The computer program code required for the operation of each part of this specification can be written in any one or more programming languages, including object-oriented programming languages such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, Python, etc., conventional procedural programming languages such as C language, Visual Basic, Fortran 2003, Perl, COBOL 2002, PHP, ABAP, dynamic programming languages such as Python, Ruby and Groovy, or other programming languages. The program code can be run entirely on the user's computer, or run on the user's computer as an independent software package, or run partially on the user's computer and partially on a remote computer, or run entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer through any network form, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service such as software as a service (SaaS).
[0110] In addition, unless explicitly stated in the claims, the order of the processing elements and sequences described in this specification, the use of alphanumeric characters, or the use of other names are not intended to limit the order of the processes and methods of this specification. Although the above disclosure discusses some invention embodiments that are currently considered useful through various examples, it should be understood that such details are only for illustrative purposes, and the attached claims are not limited to the disclosed embodiments. On the contrary, the claims are intended to cover all modifications and equivalent combinations that are consistent with the essence and scope of the embodiments of this specification. For example, although the system components described above can be implemented by hardware devices, they can also be implemented only by software solutions, such as installing the described system on an existing server or mobile device.
[0111] Similarly, it should be noted that in order to simplify the description disclosed in this specification and thus help understand one or more embodiments of the invention, in the above description of the embodiments of this specification, multiple features are sometimes combined into one embodiment, figure or description thereof. However, this disclosure method does not mean that the features required by the subject matter of this specification are more than the features mentioned in the claims. In fact, the features of the embodiments are less than all the features of the single embodiment disclosed above.
[0112] Each patent, patent application, patent application publication, and other materials, such as articles, books, specifications, publications, documents, etc., cited in this specification are hereby incorporated by reference in their entirety. Except for application history documents that are inconsistent with or conflicting with the contents of this specification, documents that limit the broadest scope of the claims of this specification (currently or later attached to this specification) are also excluded. It should be noted that if the descriptions, definitions, and / or use of terms in the materials attached to this specification are inconsistent or conflicting with the contents described in this specification, the descriptions, definitions, and / or use of terms in this specification shall prevail.
[0113] Finally, it should be understood that the embodiments described in this specification are only used to illustrate the principles of the embodiments of this specification. Other variations may also fall within the scope of this specification. Therefore, as an example and not a limitation, alternative configurations of the embodiments of this specification may be considered consistent with the teachings of this specification. Accordingly, the embodiments of this specification are not limited to the embodiments explicitly introduced and described in this specification.
[0114] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0115] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A method for generating chart data, characterized in that: The method comprises the following steps: Get the query conditions; Obtaining data to be processed based on a database table; Configure the field metadata information and the first data filtering condition corresponding to the data to be processed based on the query condition; Assembling and generating a structured query language based on the query condition, the field metadata information and the first data filtering condition; the structured query language includes a selection part, a source part and a condition part; The selection part is generated by: obtaining query information based on the query condition, and obtaining the selection part based on the query information; The generation method of the selected part specifically includes: by parsing the field metadata information, determining the aggregation type in the field metadata information, selecting a corresponding aggregation function based on the aggregation type to perform aggregation processing on the fields in the query information to obtain an aggregation result, and obtaining the selected part based on the aggregation result and the query information; or determining whether there is a preset function field in the field metadata information, and if there is a preset function field, applying the corresponding preset function to the fields in the query information to obtain a processing result, and obtaining the selected part based on the processing result and the query information; The method for generating the source part includes: based on the database table, formatting the database table name using a corresponding data delimiter to obtain a first database table name, and obtaining the source part based on the first database table name; The method for generating the condition part includes: traversing each condition in the first data filtering condition, converting each condition in the first data filtering condition into a corresponding database language, splicing each condition in the first data filtering condition based on the connection type in the field metadata information to obtain a second data filtering condition, and obtaining the condition part based on the second data filtering condition; Executing the structured query language in the data to be processed to obtain result data; The result data is formatted to obtain chart data.
2. A method for generating chart data according to claim 1, characterized in that: The field metadata information includes the name of the field and the business attributes of the field.
3. A method for generating chart data according to claim 1, characterized in that: If the first data filtering condition is a first preset condition, the first data filtering condition is implemented by a combination of several preset mathematical operations; if the first data filtering condition is a second preset condition, the first data filtering condition is implemented by a specified database function.
4. A method for generating chart data according to claim 1, characterized in that: Structured query language generation methods include: Process the structured query language to determine whether there is an aggregate function field in the field metadata information. If so, group the data to be processed; determine whether there is a sorting field in the field metadata information. If so, sort the data to be processed; determine whether there are top N fields in the field metadata information. If so, perform top N statistical processing on the data to be processed; determine whether there is a deduplication field in the field metadata information. If so, deduplication the data to be processed; determine whether there is a paging field in the field metadata information. If so, paging the data to be processed.
5. A method for generating chart data according to claim 1, characterized in that: The formatting of the result data specifically includes: Obtaining metadata information of the result data corresponding to the structured query language; Traversing the metadata information of the result data to obtain field information of the result data, the field information including field name, field type and field position index; Parse the result data, traverse the result set, parse the value corresponding to each field in the result data according to the field information, and format and convert the value corresponding to each field in the result data based on the data conversion template in the field metadata information.
6. A method for generating chart data according to claim 5, characterized in that: The formatting of the result data further includes: determining whether the amount of the chart data is greater than a preset threshold, and if so, performing paging processing on the chart data; if not, directly outputting the chart data.
7. A method for generating chart data according to claim 1, characterized in that: The method also includes rendering and drawing a chart page using a chart component based on the chart data.
8. A system for generating chart data, characterized in that: The system comprises: A first obtaining unit, used to obtain a query condition; A second obtaining unit, used for obtaining the data to be processed based on the database table; A configuration unit, configured to configure field metadata information and a first data filtering condition corresponding to the data to be processed based on the query condition; An assembling unit, configured to assemble and generate a structured query language based on the query condition, the field metadata information and the first data filtering condition; the structured query language includes a selection part, a source part and a condition part; The selection part is generated by: obtaining query information based on the query condition, and obtaining the selection part based on the query information; The generation method of the selected part specifically includes: by parsing the field metadata information, determining the aggregation type in the field metadata information, selecting a corresponding aggregation function based on the aggregation type to perform aggregation processing on the fields in the query information to obtain an aggregation result, and obtaining the selected part based on the aggregation result and the query information; or determining whether there is a preset function field in the field metadata information, and if there is a preset function field, applying the corresponding preset function to the fields in the query information to obtain a processing result, and obtaining the selected part based on the processing result and the query information; The method for generating the source part includes: based on the database table, formatting the database table name using a corresponding data delimiter to obtain a first database table name, and obtaining the source part based on the first database table name; The method for generating the condition part includes: traversing each condition in the first data filtering condition, converting each condition in the first data filtering condition into a corresponding database language, splicing each condition in the first data filtering condition based on the connection type in the field metadata information to obtain a second data filtering condition, and obtaining the condition part based on the second data filtering condition; A third obtaining unit, configured to execute the structured query language in the data to be processed to obtain result data; A processing unit is used to perform format processing on the result data to obtain chart data.
9. A device for generating chart data, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method for generating chart data according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method for generating chart data according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method for automatically generating sql statements from human natural languages for querying data
CN111324631A
Query statement generation method and device
CN113535749A