Interactive visual construction method of a rule engine, computer readable medium

By constructing a reversible mapping relationship between rule engine tables and SQL/CQL, ELT technology achieves flexible operation and security control in unstructured data processing, solving the problems of ELT's niche query language and complex operation in graph databases.

CN116701434BActive Publication Date: 2025-12-30COSCO SHIPPING TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310739650.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-21
Publication Date
2025-12-30
Estimated Expiration
2043-06-21

AI Technical Summary

Technical Problem

Existing ELT technology has limitations when processing unstructured data, especially graph databases. The query language is relatively niche, the raw data is easily exposed, the operation is difficult, and the access control is not flexible enough.

Method used

An interactive and visual construction method for rule engines is adopted. By constructing the metadata structure of rule engine tables, a one-to-one reversible mapping relationship is established between rule engine tables and SQL and CQL statements. Interactive configuration is performed using a visual interface to realize the mutual conversion between SQL and CQL statements.

Benefits of technology

It simplifies the operation for business personnel, standardizes code format, enables flexible access control, and improves the efficiency and security of data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0004296872590000151
    Figure BDA0004296872590000151
  • Figure BDA0004296872590000152
    Figure BDA0004296872590000152
  • Figure BDA0004296872590000153
    Figure BDA0004296872590000153
Patent Text Reader

Abstract

The embodiment of the application discloses a rule engine interactive visual construction method and a computer readable medium; the construction method comprises the following steps: constructing a metadata structure of a rule engine table; constructing a one-to-one reversible mapping relationship between the rule engine table and an SQL statement; constructing a one-to-one reversible mapping relationship between the rule engine table and a CQL statement; taking the constructed rule engine table as a bridge, and performing interactive configuration through a visual interface of a rule engine front end, and performing mutual conversion of the SQL statement and the CQL statement. The construction method can more conveniently and effectively perform subsequent analysis based on table data, and also provides a basis for interactive configuration of a webpage end; the interactive configuration provides a table field set, and enables a business personnel to select in a check manner, and the field set displayed to the personnel can also be controlled according to permissions. The method has the beneficial technical effects of simplifying operation difficulty, standardizing code format and flexibly controlling permissions.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application belongs to the technical field of semi-automatic operation and maintenance, and particularly relates to an interactive visual construction method of a rule engine and a computer readable medium. BACKGROUND

[0002] With the rapid development of cloud-based new generation computing storage solutions, the cost of cloud resources is continuously decreasing, and traditional ETL has gradually begun to be replaced by ELT. ELT is a new iterative architecture of traditional ETL, relying on the strong scalability of cloud data warehouse and the storage-computing separation architecture design, fully utilizing the excellent computing and storage capabilities of data warehouse or data lake, ELT has more advantages in processing unstructured data, providing a more flexible conversion mode, so that analysts can flexibly model according to actual needs, thereby improving analysis efficiency and reducing the risk of one-step error in traditional ETL conversion, no dependent table when one table fails.

[0003] However, in the prior art, ELT has some disadvantages, for example, ELT is often used in non-structured databases, but the query language of non-structured databases represented by graph databases is relatively niche compared to SQL, and ELT raw data is more likely to be exposed than ETL. SUMMARY

[0004] Therefore, on the one hand, some embodiments disclose an interactive visual construction method of a rule engine, which is used to simplify the operation difficulty of business personnel and show the field set to the personnel according to the permission control, and finally achieve the beneficial technical effects of simplifying the operation difficulty, standardizing the code format, and flexibly controlling the permission. The method comprises the following steps:

[0005] S1, constructing a metadata structure of a rule engine table;

[0006] S2, constructing a one-to-one reversible mapping relationship between the rule engine table and the SQL statement;

[0007] S3, constructing a one-to-one reversible mapping relationship between the rule engine table and the CQL statement;

[0008] S4, taking the constructed rule engine table as a bridge, and performing interactive configuration through a visual interface of the rule engine front end to convert the SQL statement and the CQL statement.

[0009] Further, some embodiments disclose an interactive visual construction method of a rule engine, and the metadata structure of the rule engine table comprises an engine table, a field table, a configuration table, and a relationship table, wherein:

[0010] The engine table contains attribute information of each rule in the rule engine;

[0011] The field table contains field information of each rule in the rule engine.

[0012] The configuration table contains condition information of each rule in the rule engine.

[0013] The relationship table contains all hierarchical relationships of rule dependencies.

[0014] Some embodiments disclose an interactive visual construction method of the rule engine, wherein:

[0015] The core fields of the table structure of the engine table are: rule number, rule name, main table information, rule activation state, CQL statement, SQL statement, and whether it is a subquery.

[0016] The core fields of the table structure of the field table are: rule number, field name, operation function, field information, whether it is a primary key field, and field role.

[0017] The core fields of the table structure of the configuration table are: configuration number, rule number, configuration type, field A operation function, field A information, operator, field B operation function, and field B information.

[0018] The core fields of the table structure of the relationship table are: rule number, parent node number, parent node level, child node number, configuration type, and parent node logic.

[0019] Some embodiments disclose an interactive visual construction method of the rule engine, wherein the one-to-one reversible mapping relationship between the rule engine table and the SQL statement in step S2 includes:

[0020] S2-1, for returned fields, sorting, and aggregation operations, add keywords in front of the returned fields according to the value of 'field role' in the field table, and if there are multiple returned fields, separate them with commas.

[0021] S2-2, for subquery and association operations, get the hierarchy of the subquery and the order of the table association according to the information of the relationship table; when generating SQL, define from inside to outside according to the hierarchy, from bottom to top according to the table association order.

[0022] S2-3, for association and filtering operations, get the logical hierarchy and combination structure of the filtering conditions or association conditions according to the information of the relationship table.

[0023] Some embodiments disclose an interactive visual construction method of the rule engine, wherein step S2-3 further includes:

[0024] The line information of the relationship table is combined by recursion. When the configuration type is 'filtering condition', add the keyword WHERE and place it at the end of the SQL statement, and when the configuration type is 'association condition', add the keyword ON and place it at the association condition of the corresponding association table.

[0025] The interactive visual construction method of the rule engine disclosed by some embodiments includes the following steps:

[0026] S3-1, for the returned field, sorting, and aggregation operation, a keyword is added in front of the returned field according to the value of the field function in the field table, and if there are multiple returned fields, they are separated by commas;

[0027] S3-2, for the subquery and the association operation, the hierarchy of the subquery and the order of the table association are obtained according to the information of the relationship table; when generating the CQL, the hierarchy is defined from bottom to top, and the order of the table association is associated from top to bottom according to the hierarchy;

[0028] S3-3, for the association and filtering operation, the logical hierarchy and the combination structure of the filtering condition or the association condition are obtained according to the information of the relationship table.

[0029] The interactive visual construction method of the rule engine disclosed by some embodiments is characterized in that the field table includes:

[0030] The field information is stored in the JSON format, and the specific format is: [{"table A alias": ["field 1"]}, {"table A alias": ["field 2"]}, {"table B alias": ["field 3"]}]; and

[0031] The format of the operation function is stored in the form of a string, and the specific format is: ’function(x01, x02, x03)’, wherein function is the function name;

[0032] The returned result of the field in the engine after compilation is ’function(table A. field 1, table A. field 2, table B. field 3)’;

[0033] If no operation is required, the specific format of the field information is [{"table A alias": ["field 1"]}]; the value of the operation function is ’x01’; and the returned result of the engine after compilation is ’table A. field 1’.

[0034] The interactive visual construction method of the rule engine disclosed by some embodiments includes the following steps:

[0035] The rule number is used for associating the configuration table and the engine table;

[0036] When the configuration type = ’filtering condition’ or the configuration type = ’association condition’, the field A information and the field B information are stored in the JSON format, and the specific format is: [{"table A alias": ["field 1"]}, {"table A alias": ["field 2"]}, {"table B alias": ["field 3"]}].

[0037] The field A operation function and the field B operation function are stored in the form of a string, and the specific format is: 'function(x01, x02, x03)', wherein function is the function name;

[0038] The return result of the field after the engine is compiled is 'function(table A. field 1, table A. field 2, table B. field 3)';

[0039] If no operation is required, the field information format is [{"table A alias": ["field 1"]}]; the operation function value is 'x01'; and the return result after the engine is compiled is 'table A. field 1';

[0040] The return results of the field A and the field B are connected by using the value of the 'operator';

[0041] When the configuration type is a correlation relationship, the field A information and the field B information are stored in the JSON format, and the values are respectively: [{"table A alias": ["table A"]}]; the field A operation function and the field B operation function values are both empty strings; and the 'operator' field value is the relationship name defined by the user; wherein the configuration type value is 'X correlation relationship', and X takes one of the four characters "left", "right", "inner" and "outer".

[0042] Some embodiments disclose an interactive visual construction method of a rule engine, and in the relationship table:

[0043] When the configuration type is'subquery', the first parent node number is empty, and the first parent node number is used as an entry to sequentially obtain each level of subquery; the table name of the subquery is the value of the rule name corresponding to the engine table; and the table alias of the subquery is automatically generated by the engine;

[0044] When the configuration type is 'X correlation relationship', wherein X takes one of the four characters "left", "right", "inner" and "outer", the first parent node number is the same as the value of'main table information' in the engine table; the numbers of subsequent nodes are taken from the 'configuration number' value of the configuration table with the configuration type being 'correlation relationship'; and the parent node level in the relationship table is the correlation order in the SQL and CQL statements;

[0045] When the configuration type is 'correlation condition' or the configuration type is 'filter condition', the numbers of the first parent nodes are the configuration numbers of the correlation relationship and the 'WHERE' keyword respectively; the parent node number, the parent node level and the child node number are described by using a recursive logic to describe a logic tree; the logic relationship is stored in the field 'parent node logic'; the child nodes under the same parent node are combined by using the same logic; and the logic splitting priority is a parenthesis, not, and and or.

[0046] In another aspect, some embodiments disclose a computer-readable medium containing computer-executable instructions that, when processed by a data processing apparatus, cause the data processing apparatus to perform the method of interactive visual construction of a rule engine.

[0047] The method of interactive visual construction of a rule engine disclosed by the embodiments of the present application extracts elements from SQL or CQL statements, and stores the extracted elements as table data based on the rigorous nature of SQL syntax specifications, which can facilitate and effectively perform subsequent analysis based on the table data, and also provides a basis for interactive configuration on the web page. The element information stored in the rule engine can be re-converted into a query script statement according to the SQL or CQL specifications of different databases. The interactive configuration provides a set of table fields in a check box manner for business personnel to select, which can simplify the operation difficulty of business personnel, and also can display a set of fields to personnel according to permission control. The method has the beneficial technical effects of simplifying operation difficulty, standardizing code format, and flexibly controlling permission. DETAILED DESCRIPTION

[0048] Herein the term "embodiment" as used in the specification is not necessarily an embodiment of the present application, unless the context clearly indicates otherwise. The performance index test in the embodiments of the present application is carried out by using the conventional test method in the art, unless otherwise specified. It should be understood that the terms described in the embodiments of the present application are only for the description of the specific embodiments, and are not used to limit the disclosure of the embodiments of the present application.

[0049] Unless otherwise defined, technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the embodiments of the present application belong; and the test methods and technical means not specifically noted in the embodiments of the present application refer to the experimental methods and technical means commonly used by those skilled in the art.

[0050] In this document, including the claims, the conjunctions such as "comprising", "including", "with", "having", "containing", "relating to", "accommodating" and the like are understood to be open, i.e. to mean "including but not limited to". Only the conjunctions "consisting of" and "consisting essentially of" are closed conjunctions.

[0051] In order to better illustrate the content of the present application, numerous specific details are given in the following specific embodiments. Those skilled in the art should understand that the present application can also be implemented without some specific details. In the embodiments, some methods, means, instruments, devices and the like which are well known to those skilled in the art are not described in detail, in order to highlight the main idea of the present application.

[0052] The technical features disclosed in the embodiments of the present application can be combined in any manner without conflict, and the resulting technical solutions belong to the disclosure of the present application.

[0053] In some embodiments, in view of the above, in one aspect, some embodiments disclose an interactive visual construction method of a rule engine, which comprises the following steps:

[0054] S1, constructing a metadata structure of a rule engine table;

[0055] S2, constructing a one-to-one reversible mapping relationship between the rule engine table and an SQL statement;

[0056] S3, constructing a one-to-one reversible mapping relationship between the rule engine table and a CQL statement;

[0057] S4, using the constructed rule engine table as a bridge, interactive configuration is performed through a visual interface of the front end of the rule engine, and mutual conversion of the SQL statement and the CQL statement is performed.

[0058] The interactive visual construction method of the rule engine can provide a basis for interactive rule configuration on a webpage, so that element information stored in the rule engine is re-converted into a query script statement according to SQL or CQL specifications of different databases. The interactive configuration provides a set of table fields in a check box manner for business personnel to select, which can simplify the operation difficulty of the business personnel and also can display a set of fields to the personnel according to permission control. Finally, the beneficial technical effects of simplifying operation difficulty, standardizing code format, and flexibly controlling permission are achieved.

[0059] In some embodiments, the metadata structure of the rule engine table comprises an engine table, a field table, a configuration table, and a relationship table, wherein:

[0060] The engine table contains attribute information of each rule in the rule engine;

[0061] The field table contains field information of each rule in the rule engine;

[0062] The configuration table contains condition information of each rule in the rule engine;

[0063] The relationship table contains all hierarchical relationships of rules.

[0064] In some embodiments, the core fields of the table structure of the engine table are: rule number, rule name, main table information, rule enable state, CQL statement, SQL statement, and whether it is a subquery, a total of seven fields; wherein, the rule enable state includes initialization, enable, and disable; whether it is a subquery includes yes and no;

[0065] The core fields of the table structure of the field table are: rule number, field name, operation function, field information, whether a primary key field, and field function, and there are six fields in total. The field function includes a return result, sorting, and aggregation.

[0066] The core fields of the table structure of the configuration table are: configuration number, rule number, configuration type, field A operation function, field A information, operator, field B operation function, and field B information, and there are eight fields in total. The configuration type includes a filtering condition, a correlation condition, a left correlation table relationship, a right correlation table relationship, an inner correlation table relationship, and an outer correlation table relationship.

[0067] The core fields of the table structure of the relationship table are: rule number, parent node number, parent node level, child node number, configuration type, and parent node logic, and there are six fields in total. The configuration type includes a subquery, a filtering condition, a correlation condition, and a correlation relationship. The parent node logic includes and, or, and not.

[0068] Some embodiments disclose an interactive visual construction method of a rule engine, and the field table has the following characteristics:

[0069] The field information is stored in a JSON format, and the specific format of the single-row data can be: [{"table A alias": ["field 1"]}, {"table A alias": ["field 2"]}, {"table B alias": ["field 3"]}]; and

[0070] The operation function is stored in a string format, and the specific format is: ’function(x01, x02, x03)’, where function is the function name.

[0071] After the engine is compiled, the return result of the field is ’function(table A. field 1, table A. field 2, table B. field 3)’; for example, the values of “field information” and “operation function” of the field table are respectively:

[0072] “field information”: [{"b": ["field 2"]}, {"b": ["field 3"]}]; and

[0073] “operation function”: (’x01’+’x02’) / ’x01’

[0074] Wherein, b is the table B alias; and the return result is (b. field 2+b. field 3) / b. field 2.

[0075] If no operation is required, the specific format of the field information is [{"table A alias": ["field 1"]}]; the value of the operation function is ’x01’; and the return result after the engine is compiled is ’table A. field 1’.

[0076] Some embodiments disclose an interactive visual construction method of a rule engine, a configuration table is provided:

[0077] Rule number is used to associate the configuration table and the engine table;

[0078] When the configuration type is 'filter condition' or the configuration type is 'association condition', the field A information and the field B information are stored in JSON format, for example, the specific format of a single row of data is: [{"table A alias":["field 1"]},{"table A alias":["field 2"]},{"table B alias":["field 3"]}];

[0079] The field A operation function and the field B operation function are stored in the form of a string, and the specific format is: 'function(x01,x02,x03)', wherein function is the function name;

[0080] The return result of the field in the engine after compilation is 'function(table A.field 1,table A.field 2,table B.field 3)';

[0081] If no operation is required, the field information format is [{"table A alias":["field 1"]}], the operation function value is 'x01', and the return result of the engine after compilation is 'table A.field 1';

[0082] The return results of the field A and the field B are connected using the value of the 'operator'; for example, the "field A information", the "field B information", the "field A operation function", the "field B operation function", and the "operator" values are respectively:

[0083] "field A information": [{"a":["field 1"]}]

[0084] "field B information": [{"b":["field 2"]},{"b":["field 3"]}]

[0085] "field A operation function": 'x01'

[0086] "field B operation function": ('x01'+'x02') / 'x01'

[0087] "operator": '>'

[0088] Wherein, a is the table A alias, and b is the table B alias

[0089] The result is a.field 1>(b.field 2+b.field 3) / b.field 2;

[0090] When the configuration type is a join relationship, for example, configuration type = 'left join table relationship', or configuration type = 'right join table relationship', or configuration type = 'inner join table relationship', or configuration type = 'outer join table relationship', the field A information and the field B information are stored in JSON format, and the values are respectively: [{"table A alias":["table A"]}]. It should be ensured that each time an association relationship is added, the alias of table A or table B and its corresponding table name are selected from the tables used in the rule, and the other table name can be selected arbitrarily. The arbitrarily selected alias is automatically generated by the system, and only needs to ensure that the newly generated alias has not been used in the rule; the field A operation function and the field B operation function take empty strings as values; when the configuration type is a join relationship, the join keyword of the SQL statement is selected according to the configuration type, and the value of the 'operator' field is the relationship name defined by the user, which is used for the CQL statement.

[0091] Some embodiments disclose an interactive visual construction method of a rule engine, and the relationship table includes:

[0092] When the configuration type is'subquery', the first parent node or root node number is empty, which is used as an entry to obtain each level of subquery in turn. The table name of the subquery is the rule name corresponding to the engine table, and the table alias of the subquery is automatically generated by the engine;

[0093] For example: tables sub1 and sub2 are subqueries of table A, and table subsub1 is a subquery of table sub1. The rules with rule names sub1, sub2 and subsub1 in the engine table contain the information required to construct three subqueries. The value of 'is subquery' of the three rules is 'yes'. For this subquery structure, the relationship table takes the following values:

[0094] The first parent node (root node) number is empty, and the leaf node numbers are sub1 and sub2. The parent node level is 0.

[0095] The second parent node number is sub1, and the leaf node number is subsub1. The parent node level is 1.

[0096] The subquery does not need logic, and the parent node logic is an empty string.

[0097] When the configuration type = 'association relationship', the number of the first parent node or root node is the same as the value of the'main table information' field of the engine table, and the number of each subsequent node is taken from the 'configuration number' value of the configuration table with the configuration type = 'association relationship'. The parent node level in the relationship table is the association order in the SQL and CQL statements. The main table information defines the first table in the association relationship. Since the configuration table is for the relationship between two tables, the order of the association of all tables can be known by transitivity. For example, when the association order is table A -> table B -> table C, the 'parent node number' value is [{"table A alias": ["table A"]} ] when the 'parent node level' is 0, and the 'child node number' is the same as the 'configuration number' of the configuration table defining the AB table relationship. The 'parent node number' value is also the same as the 'configuration number' of the configuration table defining the AB table relationship when the 'parent node level' is 1, and the 'child node number' is the same as the 'configuration number' of the configuration table defining the BC table relationship.

[0098] The association relationship does not require logic, and the parent node logic is an empty string.

[0099] For example, when the'main table information' in the engine table is [{"table A alias": ["table A"]} ], the 'table A field information' value in the data of the configuration table with the configuration number = 001 is [{"table A alias": ["table A"]} ], the 'table B field information' value is [{"table B alias": ["table B"]} ], the 'configuration type' value is 'X association table relationship', and the 'operator' value is'relationship AB'. The 'table A field information' value in the data of the configuration table with the configuration number = 002 is [{"table B alias": ["table B"]} ], the 'table B field information' value is [{"table C alias": ["table C"]} ], the 'configuration type' value is 'X association table relationship', and the 'operator' value is'relationship BC'. The 'parent node number' value from top to bottom of the relationship table is [{"table A alias": ["table A"]} ], 001, and 002. Then table A, B, and C are associated in turn, the association keywords of the SQL statement are selected according to the configuration type, and the relationship name used in the association of the CQL statement is the same as the value of the corresponding 'operator' field.

[0100] When the configuration type = 'association condition' or the configuration type = 'filter condition', the number of the first parent node or root node is the configuration number and the 'WHERE' keyword of the association relationship, respectively. The parent node number, parent node level, and child node number describe a logical tree through recursive logic, and the logical relationship is stored in the field 'parent node logic'. The child nodes under the same parent node are combined by the same logic, and the logical splitting priority is parentheses (), not, and, and or. The leaf node value is the required configuration number. The leaf node is a node without child nodes.

[0101] For example, for the associated condition logic ((basic condition A or basic condition B or basic condition C) and basic condition D), the value of 'parent node number' of 'parent node level' = 0 in the relationship table is the configuration number of the associated relationship to which the condition belongs, the parent node logic is and, and the child node numbers are '001' and the configuration number corresponding to 'basic condition D' in the configuration table, which are stored in two rows; the value of 'parent node number' of 'parent node level' = 1 is '001', the parent node logic is or, and the child node numbers are the configuration numbers corresponding to 'basic condition A', 'basic condition B' and 'basic condition C' in the configuration table, which are stored in three rows; wherein the basic condition configuration number can be found in the configuration table, and the basic condition refers to an undetachable condition that can be directly defined in a single row in the configuration table.

[0102] Some embodiments disclose an interactive visualization construction method of a rule engine. The one-to-one reversible mapping relationship between the rule engine table and the SQL statement constructed in step S2 includes:

[0103] S2-1, for the returned field, sorting, and aggregation operation, add a keyword in front of the returned field according to the value of 'field function' in the field table, for example, add the keyword SELECT when the field function ='return result'; add the keyword ORDER BY when the field function ='sorting'; add the keyword GROUP BY when the field function = 'aggregation'; if there are multiple returned fields, separate them with commas;

[0104] In some embodiments, the field table includes two fields, and the values of 'field information' and 'operation function' of the first field are respectively:

[0105] 'Field information': [{"a": ["field1"]}]

[0106] 'Operation function': 'x01'

[0107] The returned result is a. field1, where a is the alias of table A;

[0108] The values of 'field information' and 'operation function' of the second field are respectively:

[0109] 'Field information': [{"b": ["field2"]}, {"b": ["field3"]}]

[0110] 'Operation function': ( 'x01' + 'x02' ) / 'x01'

[0111] The returned result is (b. field2 + b. field3) / b. field2, where b is the alias of table B.

[0112] If field 1 is a primary key field, field 1 is arranged in front, and the final returned result is:

[0113] "key words (SELECT, ORDER BY, GROUP BY)

[0114] a. field 1

[0115] , (b. field 2 + b. field 3) / b. field 2";

[0116] S2-2, for subquery, get the level of subquery and the order of table association according to the information of the relationship table; when generating SQL, define from bottom to top according to the level of subquery;

[0117] For example, tables sub1 and sub2 are subqueries of table A, and table subsub1 is a subquery of table sub1. The rules with rule names sub1, sub2 and subsub1 in the engine table contain the information required to build three subqueries. The value of the 'whether it is a subquery' of the three rules is 'yes'. For the subquery, the value in the relationship table is:

[0118] The first parent node number is empty, and the leaf node numbers are sub1 and sub2. The parent node level is 0;

[0119] The second parent node number is sub1, and the leaf node number is subsub1. The parent node level is 1;

[0120] For subquery, the generated SQL format is:

[0121] with subsub1 as (subsub1 query statement)

[0122] , sub1 as (sub1 query statement)

[0123] , sub2 as (sub2 query statement)

[0124] Table A query statement;

[0125] S2-3, for association operation, the table association order is associated in turn from top to bottom according to the level;

[0126] For example, the keyword of left association relationship in SQL is LEFT JOIN, the keyword of right association relationship is RIGHT JOIN, the keyword of inner association relationship is INNER JOIN, and the keyword of outer association relationship is OUTER JOIN. The result of left association of tables A, B and C in turn is "table A LEFT JOIN table B table B alias on 'table A table B association condition' LEFT JOIN table C table C alias on 'table B table C association condition'";

[0127] For example, when the'main table information' in the engine table is [{"table A alias": ["table A"]}]; the value of 'table A field information' in the data corresponding to configuration number = 001 in the configuration table is [{"table A alias": ["table A"]}]; the value of 'table B field information' is [{"table B alias": ["table B"]}]; the value of 'configuration type' is 'X associated table relationship'; the value of 'operator' is'relationship AB'; the value of 'table A field information' in the data corresponding to configuration number = 002 in the configuration table is [{"table B alias": ["table B"]}]; the value of 'table B field information' is [{"table C alias": ["table C"]}]; the value of 'configuration type' is 'X associated table relationship'; the value of 'operator' is'relationship BC'; the 'parent node number' values from top to bottom of the relationship table parent node hierarchy are [{"table A alias": ["table A"]}]; 001; and 002; then table A, B, and C are associated in turn, and the association keywords of the SQL statement are selected according to the configuration type;

[0128] When 'X = 'left' in 'X associated table relationship', the generated SQL format is:

[0129] From Aa

[0130] LEFT JOIN B b ON 'table A table B association condition'

[0131] LEFT JOIN C c ON 'table B table C association condition'

[0132] Where a is the alias of A, b is the alias of B, and c is the alias of C;

[0133] S2-4, obtain the logical level and combination structure of the screening condition or the association condition according to the information of the relationship table; the row information of the relationship table can be combined through recursion;

[0134] When the configuration type ='screening condition', add the keyword WHERE and place it at the end of the SQL statement; when the configuration type = 'association condition', add the keyword ON and place it at the association condition of the corresponding associated table;

[0135] For example, for the association condition logic ((basic condition A or basic condition B) and basic condition C), the 'parent node number' value of 'parent node level' = 0 in the relationship table is the configuration number of the association relationship to which the condition belongs, the parent node logic is and, and the child node numbers are '001' and the configuration number corresponding to 'basic condition C' in the configuration table, which are stored in two rows; the 'parent node number' value of 'parent node level' = 1 is '001', the parent node logic is or, and the child node numbers are the configuration number corresponding to 'basic condition A' in the configuration table and the configuration number corresponding to 'basic condition B' in the configuration table, which are stored in two rows;

[0136] The basic condition C is defined as follows, and in the field table, the values of "field A information", "field B information", "field A operation function", "field B operation function", and "operator" are respectively:

[0137] "field A information": [{"a": ["field 1"]} ]

[0138] "field B information": [{"b": ["field 2"]}, {"b": ["field 3"]} ]

[0139] "field A operation function": 'x01'

[0140] "field B operation function": ( 'x01' + 'x02' ) / 'x01'

[0141] "operator": '>'

[0142] Wherein, a is an alias of table A, and b is an alias of table B.

[0143] The result of the basic condition C is a. field 1 > (b. field 2 + b. field 3) / b. field 2.

[0144] If the basic condition A is 'b. field 3 < 0', and the basic condition B is 'b. field 3 > 10', the output condition content is "(b. field 3 < 0 or b. field 3 > 10) and (a. field 1 > (b. field 2 + b. field 3) / b. field 2)".

[0145] If the condition is used as a filtering condition, "WHERE (b. field 3 < 0 or b. field 3 > 10) and (a. field 1 > (b. field 2 + b. field 3) / b. field 2)" is placed at the end of the SQL statement, and if the condition is a table A and table B association condition, the table A and table B association statement is "From Aa LEFT JOIN B b ON 'table A and table B association condition'".

[0146] Some embodiments disclose an interactive visual construction method of a rule engine, and the one-to-one reversible mapping relationship between the rule engine table and the CQL statement in step S3 includes:

[0147] S3-1, for the return field, sorting, aggregation operation, according to the value of 'field role' in the field table, add the keyword in front of the returned field, for example, add the keyword SELECT when the field role ='return result'; add the keyword ORDER BY when the field role ='sorting'; when the field role = 'aggregation', since the aggregation syntax of CQL is to take the field without aggregation function as the grouping field by default, there is no need to add GROUP BY processing additionally; the aggregation function includes but is not limited to MAX, SUM, AVG, MIN; if there are multiple returned fields, separate them with commas;

[0148] For example, in the field table containing two fields, the values of 'field information' and 'operation function' of the first field are respectively:

[0149] 'Field information': [{"a": ["field1"]}]

[0150] 'Operation function': 'x01'

[0151] The returned result is a. field1, where a is the alias of table A;

[0152] The values of 'field information' and 'operation function' of the second field are respectively:

[0153] 'Field information': [{"b": ["field2"]}, {"b": ["field3"]}]

[0154] 'Operation function': min(( 'x01' + 'x02' ) / 'x01')

[0155] The returned result is min((b. field2 + b. field3) / b. field2), where b is the alias of table B;

[0156] Since the first field does not have an aggregation function, and the second field has an aggregation function min, the first field is used by default when grouping, and the final returned result is:

[0157] 'Keyword (SELECT, ORDER BY)

[0158] a. field1

[0159] , min((b. field2 + b. field3) / b. field2)";

[0160] S3-2, for subquery, get the level of subquery and the order of table association according to the information of relationship table; define from bottom to top when generating CQL; since the graph database is a non-relational database, the entity association in CQL needs to establish the relationship in advance on the existing entity, so the entity of subquery needs to be established in advance, and the subsequent S3-3 association operation is performed after the establishment of the subquery entity;

[0161] S3-3, for association operation, the table association order is associated from top to bottom in turn according to the level;

[0162] For example, when the'main table information' in the engine table is [{"table A alias": ["table A"]}], the value of 'table A field information' in the data corresponding to the configuration number = 001 in the configuration table is [{"table A alias": ["table A"]}], the value of 'table B field information' is [{"table B alias": ["table B"]}]; the value of 'configuration type' is 'X associated table relationship', and the value of 'operator' is'relationship AB'; the value of 'table A field information' in the data corresponding to the configuration number = 002 is [{"table B alias": ["table B"]}]; the value of 'table B field information' is [{"table C alias": ["table C"]}]; the value of 'configuration type' is 'X associated table relationship', and the value of 'operator' is'relationship BC'; the value of 'parent node number' of the relationship table parent node from top to bottom is [{"table A alias": ["table A"]}], 001, 002; then the table A, B and C are associated in turn, and the relationship name used in the CQL statement association is the same as the value of the corresponding 'operator' field; the keyword of inner association in CQL is "MATCH", the keyword of outer association is "OPTIONAL MATCH", the implementation method of left association is "outer association relationship + left table primary key non-empty filtering condition", the keyword of right association relationship is "outer association relationship + right table primary key non-empty filtering condition", and the table primary key can be obtained from the field table; the primary key non-empty filtering condition is spliced behind the filtering condition of the first level with "and" logic, such as the statement of the inner association of table A, B and C in turn is "match (table A alias:`table A`)-[relationship AB alias: relationship AB]->(table B alias:`table B`), (table B alias:`table B`)-[relationship BC alias: relationship BC]->(table C alias:`table C`)", wherein the table name, table alias, relationship name, relationship alias and their corresponding relationship can be obtained from the configuration table;

[0163] When "X = 'inner'" in "X associated table relationship": the generated CQL format is:

[0164] match(a:A)-[ab:AB]->(b:B),(b:B)-[bc:BC]->(c:C)

[0165] Where a is the alias of A, b is the alias of B, c is the alias of C, ab is the alias of AB, bc is the alias of BC; in front of the RETURN keyword, when the configuration type = 'association condition', since the association syntax of CQL uses the relation name, the value of the 'operator' field in the corresponding row of the required association relation in the configuration table is directly used here.

[0166] For example, for the association condition logic ((basic condition A or basic condition B) and basic condition C), the 'parent node number' value of 'parent node level' = 0 in the relation table is the configuration number of the association relation to which the condition belongs, the parent node logic is and, and the child node numbers are '001' and the corresponding configuration number of 'basic condition C' in the configuration table, which are stored in two rows; the 'parent node number' value of 'parent node level' = 1 is '001', the parent node logic is or, and the child node numbers are the corresponding configuration numbers of 'basic condition A' and 'basic condition B' in the configuration table, which are stored in two rows;

[0167] The basic condition C is defined as follows, and the values of 'field A information', 'field B information', 'field A operation function', 'field B operation function', and 'operator' in the field table are respectively:

[0168] "Field A information": [{"a": ["field1"]} ]

[0169] "Field B information": [{"b": ["field2"]}, {"b": ["field3"]} ]

[0170] "Field A operation function": 'x01'

[0171] "Field B operation function": ( 'x01' + 'x02' ) / 'x01'

[0172] "Operator": '>'

[0173] Where a is the alias of table A, and b is the alias of table B.

[0174] Then the result of basic condition C is a. field1 > (b. field2 + b. field3) / b. field2.

[0175] If basic condition A is 'b. field3 < 0' and basic condition B is 'b. field3 > 10', the output condition content is "(b. field3 < 0 or b. field3 > 10) and (a. field1 > (b. field2 + b. field3) / b. field2)", and when the condition is a screening condition, "WHERE (b. field3 < 0 or b. field3 > 10) and (a. field1 > (b. field2 + b. field3) / b. field2)" should be placed in front of the RETURN keyword of the CQL statement.

[0176] In another aspect, some embodiments disclose a computer-readable medium containing computer-executable instructions that, when processed by a data processing apparatus, the data processing apparatus performs an interactive visual construction method of a rules engine. Generally, computer program instructions or code for a programmable processor-based system, appliance, or device are written in any form of programming language, including compiled or interpreted languages, and include computer program, routines, subroutines, programs, modules, microcode, etc. These computer program instructions may be provided to the processor-based system, appliance, or device via one or more any form of memory medium of the device, or external memory medium, media, or storage, including, for example, a magnetic or optical storage media, a magneto-optical storage media, a CD-ROM, a DVD, a RAM, a ROM, a flash memory, a phase-change memory, and the like. Any of the foregoing memory media or storage media, or others that become available after the present disclosure, can be utilized in the exemplary embodiments. The computer program instructions may, for example, be downloaded to a computer or other processor-based system from the Internet and an authoring tool used to produce the program instructions.

[0177] The following further illustrates the interactive visual construction method of a rules engine with the following examples.

[0178] Example 1

[0179] In Example 1, the rules engine table includes an engine table, a field table, a configuration table, and a relationship table; wherein the engine table is shown in Table 1, the field table is shown in Table 2, the configuration table is shown in Table 3, and the relationship table is shown in Table 4. In the tables, the lower case letters represent the aliases of the corresponding upper case table, such as a is the alias of Table A and b is the alias of Table B.

[0180] Table 1 Engine Table

[0181]

[0182] Table 2 Field Table

[0183]

[0184] Table 3 Configuration Table

[0185]

[0186]

[0187] Table 4 Relationship Table

[0188]

[0189] The alias of the subquery SUB_1 is sub_1, and its SQL statement is obtained from the line with rule number 0 in Table 1 and Table 2 above:

[0190] WITH SUB_1 AS (

[0191] SELECT

[0192] a.zd_1 AS zd_a -- obtained from the field table line 5, with the primary key on top;

[0193] , POWER(a.zd_1, 2) as zd_4 -- obtained from the field table line 6;

[0194] FROM Aa -- obtained from the engine table line 1 "main table information" field; );

[0196] The SQL statement corresponding to the line with rule number 0 above is marked as formula (1);

[0197] The SQL statement of rule 1 is obtained from the line with rule number 1 in Table 1 and Table 2 above:

[0198] SELECT

[0199] a.zd_1 AS zd_a -- obtained from the field table line 2, with the primary key on top;

[0200] , min((b.zd_2 + b.zd_3) / b.zd_2) AS zd_b -- obtained from the field table line 1;

[0201] FROM Aa -- obtained from the engine table line 2 "main table information" field;

[0202] LEFT JOIN B b -- obtained from the configuration table line 3 and the relationship table line 2;

[0203] ON a.zd_1 = b.zd_3 -- obtained from the configuration table line 6 and the relationship table line 5;

[0204] AND ((1 + a.zd_1) = b.zd_2 -- obtained from the configuration table line 5 and the relationship table line 6;

[0205] OR 1 + b.zd_2 = 5) -- obtained from the configuration table line 4 and the relationship table line 7;

[0206] INNER JOIN SUB_1 sub_1 -- obtained from the configuration table line 7 and the relationship table line 3;

[0207] ON a.zd_1 = sub_1.zd_a -- from config table row number 8 and relationship table row number 10;

[0208] WHERE a.zd_1 < 6 -- from config table row number 1 and relationship table row number 8;

[0209] AND (a.zd_1 / 2) < b.zd_3 -- from config table row number 2 and relationship table row number 9;

[0210] GROUP BY a.zd_1 -- from field table row number 3;

[0211] ORDER BY sub_1.zd_4 -- from field table row number 4;

[0212] The SQL statement corresponding to the above rule number 1 row is marked as equation (2);

[0213] The alias of the subquery SUB_1 is sub_1 from the rule number 0 row in the above table 1 and table 2, so the newly created subquery entity should be named SUB_1, and the initial data for establishing the subquery entity can be obtained by the following CQL statement:

[0214] MATCH (a:A) -- from engine table row number 1 "main table information" field;

[0215] RETURN

[0216] a.zd_1 AS zd_a -- from field table row number 5, the primary key is placed above;

[0217] , POWER(a.zd_1, 2) as zd_4 -- from field table row number 6;

[0218] The CQL statement corresponding to the above rule number 0 row is marked as equation (3);

[0219] The CQL statement of rule 1 from the rule number 1 row in the above table 1 and table 2 is:

[0220] OPTIONAL MATCH (a:A)-[ab:A_B relationship]->(b:B) -- from engine table row number 2 "main table information" field, config table row number 3 and relationship table row number 2;

[0221] MATCH (a:A)-[ab:A_SUB relationship]->(sub_1:SUB_1) -- from config table row number 7 and relationship table row number 3;

[0222] WHERE a.zd_1 < 6 -- from config table row number 1 and relationship table row number 8;

[0223] AND (a.zd_1 / 2) < b.zd_3 -- from config table row number 2 and relation table row number 9;

[0224] AND a.zd_1 is not null -- from config table row number 3 and field table row number 2 to get the left associated left table A table's primary key not null;

[0225] RETURN

[0226] a.zd_1 AS zd_a -- from field table row number 2 to get the primary key on top and row number 3 without aggregate function to get the grouping field;

[0227] , min((b.zd_2 + b.zd_3) / b.zd_2) AS zd_b -- from field table row number 1;

[0228] ORDER BY sub_1.zd_4 -- from field table row number 4.

[0229] The CQL statement corresponding to the above row related to rule number 1 is marked as formula (4).

[0230] The rule engine interactive visualization construction method disclosed in the embodiment of the application extracts elements from the SQL or CQL statement, and converts the extracted elements into table data for storage in dependence on the rigorous nature of the SQL syntax specification. The table data can be more convenient and effective for subsequent analysis, and also provides a basis for interactive configuration on the webpage. The element information stored in the rule engine can be re-converted into a query script statement according to the SQL or CQL specification of different databases. The interactive configuration provides a set of table fields, and lets the business personnel select in a check manner, which can simplify the operation difficulty of the business personnel, and can also display the set of fields to the personnel according to the permission control. The method has the beneficial technical effects of simplifying the operation difficulty, standardizing the code format, and flexibly controlling the permission.

[0231] The technical solutions disclosed in the embodiments of the application and the technical details disclosed in the embodiments are only exemplary to illustrate the inventive concept of the application, and do not constitute a limitation on the technical solutions of the embodiments of the application. Any conventional change, replacement or combination of the technical details disclosed in the embodiments of the application has the same inventive concept as the application, and is within the protection scope of the claims of the application.

Claims

1. A method for interactive visual construction of a rule engine, characterized in that, The method comprises the steps of: S1, constructing a metadata structure of a rule engine table; the metadata structure comprises an engine table, a field table, a configuration table and a relationship table, wherein: The engine table contains attribute information of each rule in the rule engine; the core fields of the table structure of the engine table are: rule number, rule name, main table information, rule activation state, CQL statement, SQL statement, and whether it is a subquery; The field table contains field information of each rule in the rule engine; the core fields of the table structure of the field table are: rule number, field name, operation function, field information, whether it is a primary key field, and field function; wherein the field information is stored in JSON format, and the specific format is: [{"table A alias": ["field 1"]}, {"table A alias": ["field 2"]}, {"table B alias": ["field 3"]}]; the format of the operation function is stored in the form of a string, and the specific format is: 'function(x01, x02, x03)', wherein function is the function name; the return result of the field after engine compilation is 'function(table A.field 1, table A.field 2, table B.field 3)'; if no operation is required, the specific format of the field information is [{"table A alias": ["field 1"]}]; the operation function takes the value of 'x01', and the return result after engine compilation is 'table A.field 1'; The configuration table contains condition information of each rule in the rule engine; the core fields of the table structure of the configuration table are: configuration number, rule number, configuration type, field A operation function, field A information, operator, field B operation function, and field B information; The relationship table contains all hierarchical relationships of rule dependencies; the core fields of the table structure of the relationship table are: rule number, parent node number, parent node level, child node number, configuration type, and parent node logic; S2, constructing a one-to-one reversible mapping relationship between the rule engine table and the SQL statement; S3, constructing a one-to-one reversible mapping relationship between the rule engine table and the CQL statement; S4, using the constructed rule engine table as a bridge, interactive configuration is performed through the visual interface of the rule engine front end, and the SQL statement and the CQL statement are converted to each other.

2. The method for interactive visual construction of a rules engine according to claim 1, characterized in that, The step S2 of constructing a one-to-one reversible mapping relationship between the rule engine table and the SQL statement comprises: S2-1, for the returned field, sorting and aggregation operation, according to the value of 'field function' in the field table, a keyword is added in front of the returned field; if there are multiple returned fields, they are separated by commas; S2-2, for the subquery and the association operation, the level of the subquery and the order of the table association are obtained according to the information of the relationship table; when generating the SQL, the subquery is defined from inside to outside, that is, the level from bottom to top, and the table association order is associated in turn from top to bottom according to the level; S2-3, for the association and filtering operation, the logical level and combination structure of the filtering condition or the association condition are obtained according to the information of the relationship table.

3. The method for interactive visual construction of a rules engine according to claim 2, characterized in that, The step S2-3 further comprises: The row information of the relationship table is combined by recursion. When the configuration type is ’filter condition’, the keyword WHERE is added and placed at the end of the SQL statement. When the configuration type is ’correlation condition’, the keyword ON is added and placed at the correlation condition of the corresponding correlation table.

4. The method for interactive visual construction of a rules engine of claim 1, wherein, The step S3, constructing a one-to-one reversible mapping relationship between the rule engine table and the CQL statement, comprises: S3-1, for the returned field, sorting and aggregation operation, the keyword is added in front of the returned field according to the value of ’field role’ in the field table. If there are multiple returned fields, they are separated by commas. S3-2, for the subquery and the association operation, the hierarchy of the subquery and the order of the table association are obtained according to the information of the relationship table. The CQL is generated by defining from inside to outside, that is, from bottom to top, and the table association order is associated in turn from top to bottom according to the hierarchy. S3-3, for the association and filtering operation, the logical hierarchy and combination structure of the filtering condition or the correlation condition are obtained according to the information of the relationship table.

5. The method for interactive visual construction of a rules engine of claim 1, wherein, In the configuration table: The rule number is used for the association between the configuration table and the engine table. When the configuration type is ’filter condition’ or ’correlation condition’, the field A information and the field B information are stored in JSON format. The specific format is: [{"table A alias": ["field 1"]}, {"table A alias": ["field 2"]}, {"table B alias": ["field 3"]}]. The field A operation function and the field B operation function are stored in the form of a string. The specific format is: ’function(x01, x02, x03)’, where function is the function name. The return result of the field in the engine after compilation is ’function(table A. field 1, table A. field 2, table B. field 3)’. If no operation is required, the field information format is [{"table A alias": ["field 1"]}]. The operation function value is ’x01’. The return result of the engine after compilation is ’table A. field 1’. The return results of the field A and the field B are connected using the value of the ’operator’. When the configuration type is a correlation relationship, the field A information and the field B information are stored in JSON format. The values are: [{"table A alias": ["table A"]}]. The field A operation function and the field B operation function values are both empty strings ’’. The ’operator’ field value is the user-defined relationship name. When the configuration type value is ’X correlation relationship’, X takes one of the four characters ”left, right, inner, and outer”. In the relationship table:

6. The method for interactive visual construction of a rules engine of claim 1, wherein, When the configuration type is ’subquery’, the first parent node number is empty. The corresponding rule name of the engine table is used as the table name of the subquery. The table alias of the subquery is automatically generated by the engine. ​ When the configuration type is 'X association', wherein X is one of 'left inside', 'left outside', 'right inside' and 'right outside', the first parent node number is the same as the'main table information' in the engine table, and the subsequent node numbers are taken from the 'configuration number' of the configuration type = 'association' in the configuration table, and the parent node level in the relationship table is the association order in the SQL and CQL statements. When the configuration type is 'association condition' or 'filter condition', the first parent node number is the configuration number of the association and the 'WHERE' keyword respectively, the parent node number, the parent node level and the child node number describe a logical tree through recursive logic, the logical relationship is stored in the field 'parent node logic', the child nodes under the same parent node are combined by the same logic, and the logical splitting priority is a parenthesis ( ), not, and and or.

7. A computer readable medium containing computer-executable instructions, wherein: When the computer executes the instructions via a data processing device, the data processing device executes the interactive visual construction method of the rule engine according to any one of claims 1-6.

Citation Information

Patent Citations

  • Schemaless to relational representation conversion

    US10552443B1

  • Distributed system generating rule compiler engine apparatuses, methods, systems and media

    WO2020185988A1