Field construction type grammar verification method and device and storage medium

By performing field construction-based syntax verification outside the data analysis platform, the error report problem caused by syntax exceptions during field construction in the database is solved, the readability and user experience of the error report are improved, and the normal operation of the database is ensured.

CN119127907APending Publication Date: 2024-12-13GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411015036.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-26
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The existing data analysis platform is prone to syntax exceptions during field construction, resulting in database errors reporting, affecting normal operation, and poor readability of errors reporting, which is difficult to understand and process.

Method used

Perform field construction syntax verification outside the database, pre-process and verify the field construction through preset syntax verification rules, generate prompt information, avoid error construction directly input to the database, and improve the readability of errors and User experience.

Benefits of technology

It effectively avoids frequent database error reporting, simplifies error positioning and processing, and improves user data processing efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119127907A_ABST
    Figure CN119127907A_ABST
Patent Text Reader

Abstract

The invention relates to a grammar verification method and device for a field construction formula and a storage medium, and the method comprises the steps: obtaining the field construction formula for a database, and carrying out the grammar verification of the field construction formula based on a preset grammar verification rule; and sending the field construction formula passing the grammar verification to the database for field construction. According to the method provided by the invention, the grammar legality verification of the field construction formula is carried out before the database executes the specific field construction, so that database errors caused by frequent execution of the wrong construction formula can be avoided, and meanwhile, the problem of difficulty in understanding and processing brought to a user by the database errors is avoided. According to the method, data verification is carried out in advance outside the database, and error reasons are classified, so that the readability of error reporting can be effectively enhanced, a user can conveniently and rapidly position error positions for processing, the data processing efficiency of the user is improved, and the use experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing technology, and in particular to a field construction type syntax checking method, device and storage medium. Background Art

[0002] There are various types of data analysis platforms with many functions. Users can use different data analysis platforms to implement data source analysis, data reconstruction, and other operations. In the process of using data sources, there are often situations where the existing data cannot meet the actual needs of users. At this time, new fields can be generated based on user needs. For example, if a user wants to view the remaining working hours data, but the existing data source only has total working hours and used working hours, the remaining working hours data can be calculated from the total working hours and used working hours, and a new field can be generated for the user to use. However, in actual applications, the user's needs may not meet the field syntax requirements, and the database is prone to exceptions, affecting normal use. Summary of the invention

[0003] The present disclosure provides a syntax checking method, device and storage medium for a field construction formula, so as to perform syntax checking on the field construction formula outside a database, so as to avoid the field construction formula that does not meet the requirements from being directly input into the database and affecting normal operation.

[0004] In a first aspect, the present disclosure provides a syntax verification method for a field construction formula, comprising:

[0005] Obtaining a field construction formula for a database, and performing syntax verification on the field construction formula based on a preset syntax verification rule;

[0006] The field construction formula that passes the syntax check is sent to the database for field construction.

[0007] In some embodiments, obtaining a field construction formula for a database includes:

[0008] Obtaining and displaying the existing field information of the database;

[0009] A field construction formula input by a user based on the existing field information is received; the field construction formula includes an operation relationship of the existing fields in the database.

[0010] In some embodiments, before performing syntax checking on the field construction formula based on a preset syntax checking rule, the method further includes:

[0011] Preprocessing the field construct based on a preset preprocessing rule;

[0012] The preprocessing includes at least one of function-function relationship replacement processing, field-digital distinguishing mark processing, and field-type-string relationship replacement;

[0013] The function-function relationship replacement process is used to replace the function in the field construction formula with a specified format, wherein the specified format includes a Math.floor format;

[0014] The field-number distinguishing mark processing is used to replace the field named by the number;

[0015] The field-type-string relationship replacement is used to replace the indicator field and the record number field in the field construction formula.

[0016] In some embodiments, before performing syntax checking on the field construction formula based on a preset syntax checking rule, the method further includes:

[0017] Pre-checking the field construction formula based on preset pre-checking rules;

[0018] When the field construction formula fails to pass the pre-verification, generating corresponding prompt information based on the result of the pre-verification;

[0019] The pre-check includes at least one of a first word check, a mixed check of aggregation and non-aggregation, and an illegal character check;

[0020] The first word check is used to determine whether the first word of the field construction formula is a positive or negative sign;

[0021] The mixed aggregation-non-aggregation check is used to determine whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0022] The illegal character check is used to determine whether the field construction formula includes a preset illegal character.

[0023] In some embodiments, the performing syntax checking on the field construction formula based on a preset syntax checking rule includes:

[0024] Performing syntax check on the field construction formula based on the EVAL function;

[0025] When the field construction formula fails to pass the syntax check based on the EVAL function, a corresponding prompt message is generated based on the result of the syntax check.

[0026] In some embodiments, after performing syntax checking on the field construction formula based on a preset syntax checking rule, the method further includes:

[0027] Post-checking the field construction formula based on a preset post-check rule;

[0028] When the field construction formula does not announce the post-verification, generating corresponding prompt information based on the result of the post-verification;

[0029] The post-check includes at least one of isNaN check, aggregate-non-aggregate mixed check, aggregate nested check, special character check, and Chinese character check;

[0030] The isNaN check is used to check whether the field construction formula is a meaningless construction formula;

[0031] The aggregation-non-aggregation mixed check is used to check whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0032] The aggregation nesting check is used to check whether the aggregation function has nested aggregation values;

[0033] The special character check is used to determine whether the field construction formula includes a preset special character;

[0034] The Chinese character check is used to perform Chinese character check on the field construction formula through a regular expression.

[0035] In some embodiments, the prompt information includes at least one of abnormal location, abnormal event and modification suggestion.

[0036] In a second aspect, the present disclosure provides a field construction type syntax checking device, comprising:

[0037] A construction formula verification module, used to obtain a field construction formula for a database, and perform syntax verification on the field construction formula based on preset syntax verification rules;

[0038] The construction formula sending module is used to send the field construction formula that passes the syntax check to the database for field construction.

[0039] In a third aspect, the present disclosure provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the above aspects.

[0040] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method described in the above aspects when executed by a processor.

[0041] In a fifth aspect, the present disclosure provides a computer program product, including a computer program / instructions, which implements the steps of the method described in the above aspects when the computer program is executed by a processor.

[0042] The present disclosure provides a method, device, equipment and storage medium for syntax verification of a field construction formula, the method comprising obtaining a field construction formula for a database, performing syntax verification on the field construction formula based on preset syntax verification rules; and sending the field construction formula that passes the syntax verification to the database for field construction. The method provided by the embodiment of the present invention performs syntax legality verification on the field construction formula before the database executes a specific field construction, which can avoid database errors caused by frequent execution of incorrect construction formulas, and at the same time avoid the problem of difficulty in understanding and handling caused by database errors to users. The present application performs data verification in advance outside the database and classifies the causes of errors, which can effectively enhance the readability of the error report, facilitate users to quickly locate the error location for processing, improve the user's data processing efficiency, and improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The present disclosure will be described in more detail below based on embodiments and with reference to the accompanying drawings:

[0044] Figure 1 A flowchart of a field construction syntax verification method provided by an embodiment of the present disclosure;

[0045] Figure 2 A schematic diagram of an interface for obtaining a field construction formula in a syntax verification method for a field construction formula provided in an embodiment of the present disclosure.

[0046] Figure 3 Another flowchart of a field construction syntax verification method provided by an embodiment of the present disclosure;

[0047] Figure 4 A schematic diagram of a prompt information interface of a field construction type grammar checking method provided in an embodiment of the present disclosure;

[0048] Figure 5 A schematic diagram of another prompt information interface of a field construction type grammar checking method provided by an embodiment of the present disclosure;

[0049] Figure 6 A schematic diagram of another prompt information interface of a field construction syntax verification method provided by an embodiment of the present disclosure;

[0050] Figure 7 A schematic diagram of another prompt information interface of a field construction type grammar checking method provided by an embodiment of the present disclosure;

[0051] Figure 8 A schematic diagram of the structure of a field-building syntax checking device provided in an embodiment of the present disclosure;

[0052] Fig. 9A schematic diagram of an interface showing a field construction formula passing syntax verification in a syntax verification method for a field construction formula provided in an embodiment of the present disclosure.

[0053] In the drawings, the same reference numerals are used for the same components, and the drawings are not drawn to scale. DETAILED DESCRIPTION

[0054] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, and to fully understand and implement how the present disclosure applies technical means to solve technical problems and achieve the corresponding technical effects, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only embodiments of a part of the present disclosure, not all of the embodiments. The embodiments of the present disclosure and the various features in the embodiments can be combined with each other without conflict, and the technical solutions formed are all within the scope of protection of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present disclosure.

[0055] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0056] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0057] A calculated field is a new field that is generated by combining operators and functions with existing fields in the data source and successfully executing the formula in the database. Different data analysis platforms use different formula structures, including but not limited to SQL statements and arithmetic expression statements. SQL statements and arithmetic expressions have their own syntax structures. Only by executing formulas with composite syntax structures can the correct calculated fields be obtained, otherwise a database error will be triggered.

[0058] The existing syntax checking method for constructs usually can only return the native error prompt of the database, which has poor readability and makes it difficult for developers to understand the cause of the error. Frequent database errors will also have a negative impact on the normal operation of the database.

[0059] The present invention provides a syntax checking method, device, equipment and storage medium for a field construction formula, so as to perform syntax checking on the field construction formula outside a database, so as to avoid the field construction formula that does not meet the requirements from being directly input into the database and affecting normal operation.

[0060] Embodiment 1

[0061] Figure 1 A flowchart of a field construction syntax verification method provided in an embodiment of the present disclosure.

[0062] Reference Figure 1 As shown, the syntax verification method of the field construction formula provided by the embodiment of the present invention includes steps 01 to 02.

[0063] Step 01: Obtain a field construction formula for a database, and perform a syntax check on the field construction formula based on a preset syntax check rule.

[0064] The method provided by the embodiment of the present invention performs syntax verification on the field construction formula outside the database in advance, so as to avoid the unverified field construction formula being directly input into the database to affect the normal operation of the database.

[0065] Step 02: Send the field construction formula that passes the syntax check to the database for field construction.

[0066] Since the legality of the arithmetic construction formula directly determines whether the database reports an error, in order to optimize the performance of the database, the present application implements the provided method to verify the construction formula outside the database. Furthermore, the abnormal reasons that appear in the verification process can be classified, and real-time feedback can be given to the user with concise prompts. After passing the verification, the construction formula is passed to the backend, which is converted into an SQL statement and executed in the database.

[0067] If the calculated field or calculation formula is directly executed in the database, the content submitted by the user will trigger the database verification, which may cause frequent database errors and affect database performance. In addition, the readability of direct database errors is poor. For example, the database error "Cannot deserialize value of type java.util.Date from String2023-05-29T18:02:02.000Z" is difficult for users to understand and cannot be modified.

[0068] The method provided in the embodiment of the present invention performs a syntax validity check on the calculation field construction formula before executing a specific field construction in the database, which can avoid database errors caused by frequent execution of incorrect construction formulas, and at the same time avoid the problems of understanding and handling difficulties caused by database errors to users. Data verification is performed in advance outside the database, and the causes of errors are classified, which can effectively enhance the readability of the error report and facilitate users to quickly locate the error location for processing.

[0069] Embodiment 2

[0070] Based on the above embodiment, step 01 of obtaining a field construction formula for a database may include:

[0071] Obtain and display the existing field information of the database.

[0072] In some embodiments, existing field information of the target database, such as the existing field name, the included data type, the included data format, and the included data value range, is provided to the user for display for the user's use.

[0073] A field construction formula input by a user based on the existing field information is received; the field construction formula includes an operation relationship of the existing fields in the database.

[0074] In some embodiments, the user inputs a field construction formula based on existing field information and current actual needs.

[0075] Optionally, the field construction formula is an operation formula for an existing field, such as adding the data of field A in the database to the data contained in field B.

[0076] The method provided by the embodiment of the present invention can generate an arithmetic expression or other types of expressions based on a visual interface with related elements, and a new field can be generated in the database after the expression passes verification.

[0077] Optionally, a new field is generated based on an existing field in the database, for example, a new field is generated based on an expression matched by a user and verified.

[0078] In a specific example, the main operation objects of the calculation field generation tool are fields, functions, and operators, which can generate arithmetic construction formulas. Fields are composed of two data types: indicators and records. Indicators include all existing fields of numeric type in the data source, and the number of records belongs to derived fields, which is a count of the same type of data in the data source. Functions include AVG and SUM, where AVG is the aggregated average and SUM is the aggregated sum. Operators can include four arithmetic operators and English brackets. Users can obtain the arithmetic construction formula of the calculated field by matching the three operation objects, such as AVG(`name`)+`age`*`number`.

[0079] Figure 2 A schematic diagram of calculating field generation in the method provided in an embodiment of the present invention is shown.

[0080] Reference Figure 2 In a specific example, the user uses the existing fields, functions and operators of the database in the visual interface to obtain a calculation formula for a new field. After the user clicks Submit, the front end performs a syntax check on the calculation formula outside the database using the verification rules provided in this application. When the syntax check passes, it is transmitted to the database for execution, and then a new field is generated based on the data.

[0081] In the method provided in the embodiment of the present invention, the construction process of the arithmetic expression is relatively simple and applicable to various users, while the SQL statement can only be used by relevant technical personnel and is difficult for other users to use.

[0082] The database field construction formula acquisition method provided in the embodiment of the present invention can provide users with existing field information of the database, that is, the basis for users to input field construction formulas, making it convenient for users to input required field construction formulas based on actual needs, and can fully meet the needs of users.

[0083] Embodiment 3

[0084] Based on the above embodiment, before step 01 performs syntax checking on the field construction formula based on preset syntax checking rules, the method further includes:

[0085] Preprocessing the field construct based on a preset preprocessing rule;

[0086] The preprocessing includes at least one of function-function relationship replacement processing, field-digital distinguishing mark processing, and field-type-string relationship replacement;

[0087] The function-function relationship replacement process is used to replace the function in the field construction formula with a specified format, wherein the specified format includes a Math.floor format;

[0088] The field-number distinguishing mark processing is used to replace the field named by the number;

[0089] The field-type-string relationship replacement is used to replace the indicator field and the record number field in the field construction formula.

[0090] Based on the above embodiment, before step 01 performs syntax checking on the field construction formula based on preset syntax checking rules, the method further includes:

[0091] Pre-checking the field construction formula based on preset pre-checking rules;

[0092] When the field construction formula fails to pass the pre-verification, corresponding prompt information is generated based on the result of the pre-verification, and the prompt information includes at least one of an abnormal position, an abnormal matter, and a modification suggestion;

[0093] The pre-check includes at least one of a first word check, a mixed check of aggregation and non-aggregation, and an illegal character check;

[0094] The first word check is used to determine whether the first word of the field construction formula is a positive or negative sign;

[0095] The mixed aggregation-non-aggregation check is used to determine whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0096] The illegal character check is used to determine whether the field construction formula includes a preset illegal character.

[0097] Based on the above embodiment, step 01 performs syntax checking on the field construction formula based on preset syntax checking rules, including:

[0098] Performing syntax check on the field construction formula based on the EVAL function;

[0099] When the field construction formula fails to pass the syntax check based on the EVAL function, a prompt message is generated based on the result of the syntax check, and the prompt message includes at least one of an abnormal position, an abnormal matter, and a modification suggestion.

[0100] In some embodiments, before and after step 01 of performing syntax checking on the field construction formula based on a preset syntax checking rule, the method further includes:

[0101] Post-checking the field construction formula based on a preset post-check rule;

[0102] When the field construction formula does not announce the post-verification, generating prompt information based on the result of the post-verification, the prompt information includes at least one of an abnormal position, an abnormal matter, and a modification suggestion;

[0103] The post-check includes at least one of isNaN check, aggregate-non-aggregate mixed check, aggregate nested check, special character check, and Chinese character check;

[0104] The isNaN check is used to check whether the field construction formula is a meaningless construction formula;

[0105] The aggregation-non-aggregation mixed check is used to check whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0106] The aggregation nesting check is used to check whether the aggregation function has nested aggregation values;

[0107] The special character check is used to determine whether the field construction formula includes a preset special character;

[0108] The Chinese character check is used to perform Chinese character check on the field construction formula through a regular expression.

[0109] Existing construction-based verification mostly performs a single verification on collocation rules, such as setting multiple rules such as the expression that the operation object must exist on the left and right of the operator to be qualified, and the judgment efficiency is low. The method provided by the embodiment of the present invention can filter out most illegal construction expressions based on the EVAL function, and further for illegal construction phenomena that cannot be filtered, it can be further matched with custom rules for identification, greatly shortening the syntax verification time and reducing the complexity of the syntax verification rules.

[0110] In a specific example, the method provided by the embodiment of the present invention first replaces the part of the calculation field construction formula that the EVAL function cannot recognize with a recognizable function or value, and then uses EVAL to calculate the new construction formula after the replacement. If it can be executed normally, it means that the construction formula syntax is correct, otherwise there is an illegal use.

[0111] Furthermore, since there are certain discrepancies between the verification rules provided by the embodiment of the present invention and the EVAL operation rules, further supplementary judgments can be made on other verification contents that cannot be covered based on the EVAL calculation.

[0112] The method provided in the embodiment of the present invention can verify the calculation field expression constructed by indicators, record numbers, functions and operators, use JaveScript as the implementation method, mainly use EVAL operation, and other supplementary verification as symbols. It combines methods such as character replacement, symbol verification and function replacement to implement syntax verification of the expression outside the database, classify the illegal reasons that appear in the verification process and provide real-time feedback, which can improve the efficiency of field verification, avoid interference with database operation, provide users with effective abnormal alarms, and improve user experience.

[0113] The method provided by the embodiment of the present invention can realize the verification of the calculation field construction formula. Based on JaveScript, it combines character replacement, symbol verification and EVAL operation to realize the syntax verification of the construction formula containing indicators or record numbers, functions and operators. The illegal reasons appearing in the verification process are classified and fed back in real time. The construction formula is not passed to the back end until it passes the verification. The back end converts it into an SQL statement and executes it in the database, thereby avoiding the execution of the wrong construction formula causing a database error, and further optimizing the performance of the database.

[0114] Embodiment 4

[0115] Figure 3 A schematic diagram of another implementation flow of the syntax checking method for field construction provided by an embodiment of the present invention is shown.

[0116] Reference Figure 3 In a specific example, the implementation process of the method is as follows.

[0117] The calculation field is subjected to data source selection 101, first word judgment 102, function-function relationship replacement 103, field-number distinguishing mark 104, field-type-string relationship replacement 105, aggregate-non-aggregate mixed check 106, illegal character check 107, and EVAL operation 108.

[0118] In some embodiments, data source selection 101 includes selecting a data source to provide fields that can be used to construct an expression.

[0119] In some embodiments, the first word judgment 102 includes judging whether the first word of the constructed formula is "+" or "-". Since EVAL will recognize "+" and "-" as positive and negative signs, which are inconsistent with the verification rules, an additional judgment is added. If the first word is "+" or "-", the verification result is displayed as "Syntax error_missing identifier".

[0120] Figure 4 The figure shows the prompt information issued by the first word judgment in the method provided by the embodiment of the present invention.

[0121] In some embodiments, the function-function relationship replacement step 103 is to replace the function in the expression with the Math.floor format, eliminate the AVG and SUM functions that EVAL cannot recognize, and ensure the normal calculation of the final EVAL function.

[0122] In some embodiments, the field-number distinguishing mark 104 is for some fields in the data source that may be named with numbers, which makes it impossible to distinguish the type of this type of field when it appears in the expression at the same time as the number. The fields in the construction formula need to be wrapped with ``. When identifying the fields in the construction formula, the `field name` is used as the main body for comparison and replacement. The strings without `` in the outer layer are all recognized as ordinary strings or numbers, and no numerical replacement is performed, and they are directly involved in the final EVAL calculation.

[0123] In some embodiments, step 105 of replacing the field-type-string relationship includes replacing the indicator field appearing in the expression with (10+Math.random()).toString()+", and replacing the record number field with '(-10)'. Since the indicator belongs to an unaggregated field, the record number is a count of the same type of data in the data source, which belongs to an aggregated field, and the aggregated field and the unaggregated field cannot be mixed, the two types of fields are replaced with different strings for distinction, the indicator is replaced with a decimal, and the record number is replaced with an integer; a space is added at the end of the replacement string, and a check is performed for errors in the use of fields.

[0124] In some embodiments, step 106, the aggregate-non-aggregate mixed check is used to synchronously count whether there are both indicators and record numbers that do not use aggregate functions in the statistical expression when replacing numerical values. If both exist, the check result is "Logical error_aggregate functions and non-aggregate functions cannot be mixed."

[0125] In some embodiments, the illegal symbol check in step 107 is used to separately detect illegal symbols that can be calculated normally in EVAL but do not conform to the check rules, including some consecutive symbol cases, and the specific detection range is ['%', '&', '^', '|', ',', '<', '>', '`', '**', ' / / ', '++', '--', '+-', '-+', ' / -', ' / +', '*+', '*-', ';']. If the above symbols exist in the construction formula, the check result is "Syntax Error_Illegal Field / Symbol".

[0126] Figure 5 The figure shows the prompt information issued by the illegal character check in the method provided by the embodiment of the present invention.

[0127] In some embodiments, step 108 is to perform an EVAL operation on the replaced calculation field construct.

[0128] Furthermore, the calculated fields after the EVAL operation are subjected to isNaN check 109 , aggregate-non-aggregate mixed check 110 , and aggregate nested check 111 .

[0129] In some embodiments, step 109 isNaN check includes performing isNaN check on the calculation result after the EVAL calculation is passed. If it is true, it means that the replaced expression is a meaningless string, and the check result is "Syntax Error_Illegal Field / Symbol".

[0130] In some embodiments, step 110 of the aggregate-non-aggregate mixed verification includes performing a decimal judgment on the calculation result. If the judgment result is a decimal, it proves that there is an indicator value in the construction formula that does not use an aggregate function. If Math.floor also exists in the construction formula at this time, the verification result is "Logical error_Aggregate functions and non-aggregate functions cannot be mixed". In order to exclude the possibility of using division operations to obtain decimal results, all " / " in the construction formula are replaced with "+" before decimal judgment.

[0131] Figure 6 The figure shows the prompt information issued by the aggregation-non-aggregation mixed verification in the method provided by the embodiment of the present invention.

[0132] In some embodiments, step 111 aggregation nesting check is for aggregate functions that cannot be nested, but EVAL can calculate values ​​nested by multiple layers of Math.floor, so additional checks are required. The aggregate value mainly includes the number of records and the index using the aggregate function. Find the subscript where Math.floor is located in the construction formula, and further take out the parameters contained in Math.floor. If the parameter contains '(-10)' or Math.floor, the check result is "Logical error_Aggregation function cannot be nested".

[0133] Figure 7 The diagram shows the prompt information issued by the aggregate nested check in the method provided by the embodiment of the present invention.

[0134] Furthermore, the fields after the EVAL operation are subjected to Error information capture 112, and the data after the Error information is captured is subjected to Reference or Type processing 113. On the other hand, the data after the Error information is captured is subjected to Syntax processing 114, special character checking 115, and Chinese character checking 116.

[0135] In some embodiments, step 112 captures Error information of the field after the EVAL operation, including if the EVAL calculation fails and an error occurs, capturing the error information Error to analyze the specific situation and further returning the corresponding verification result.

[0136] In some embodiments, for step 113, when the error type is ReferenceError or TypeError, if the error contains 'is not a function', the verification result is "Syntax error_missing identifier", otherwise it is "Syntax error_illegal field / symbol".

[0137] In some embodiments, for step 114, if the error type is SyntaxError, it is further determined whether the error cause is an illegal field or a missing identifier.

[0138] In some embodiments, in the special character check in step 115, the set of special characters that will cause EVAL to report an error is ['(','**','++','--',' / *','+*','+ / ','-*','- / ','* / ','@','`','!','#','$','&','=','_','%','^','[',']','{','}','?','.',':','\\','"',"'",'~','·'], and when the constructed formula contains the above symbols, the check result is "Syntax error_illegal field / symbol".

[0139] In some embodiments, the Chinese character verification process in step 116 includes performing Chinese character verification on the constructed formula through a regular expression. When the Chinese character regular judgment is met or the error contains 'Invalid', the verification result is "Syntax error_Illegal field / symbol". Otherwise, it is an identifier error and the verification result is "Syntax error_Missing identifier".

[0140] Finally, based on the results of the aggregate nested verification, the Reference Or Type judgment results, and the results of the Chinese character verification, the final verification result 117 is obtained.

[0141] In some embodiments, the final verification result is fed back to the operator. When the verification result shows that the formula is legal, the construction formula is passed to the backend, converted into an SQL statement by the backend, and the construction of the calculation field is executed in the database.

[0142] Figure 8 A schematic diagram of an interface showing a field construction formula passing syntax verification in the method provided in an embodiment of the present application is shown.

[0143] The method provided in the embodiment of the present invention can be implemented through JaveScript to judge the grammatical legality of the calculation field construction formula, and can also be implemented through other programming languages ​​that support EVAL such as Python, PHP, etc. For languages ​​that do not support EVAL such as Jave, etc., it can be implemented through a third-party library or JaveScript engine.

[0144] Embodiment 5

[0145] Fig. 9 A schematic diagram of the structure of a field construction type grammar checking device provided in an embodiment of the present invention is shown.

[0146] Reference Fig. 9 , a field-constructed syntax checking device provided by an embodiment of the present invention includes:

[0147] A construction formula verification module 910 is used to obtain a field construction formula for a database and perform syntax verification on the field construction formula based on a preset syntax verification rule;

[0148] The construction formula sending module 920 is used to send the field construction formula that passes the syntax check to the database for field construction.

[0149] In some embodiments, the constructed verification module 910 includes a constructed acquisition unit, which is used to:

[0150] Obtaining and displaying the existing field information of the database;

[0151] A field construction formula input by a user based on the existing field information is received; the field construction formula includes an operation relationship of the existing fields in the database.

[0152] In some embodiments, the constructed verification module 910 includes a pre-processing unit for:

[0153] Preprocessing the field construct based on a preset preprocessing rule;

[0154] The preprocessing includes at least one of function-function relationship replacement processing, field-number distinguishing mark processing, and field-type-string relationship replacement;

[0155] The function-function relationship replacement process is used to replace the function in the field construction formula with a specified format, wherein the specified format includes a Math.floor format;

[0156] The field-number distinguishing mark processing is used to replace the field named by the number;

[0157] The field-type-string relationship replacement is used to replace the indicator field and the record number field in the field construction formula.

[0158] In some embodiments, the built-in verification module 910 includes a pre-verification unit for:

[0159] Pre-checking the field construction formula based on preset pre-checking rules;

[0160] When the field construction formula fails to pass the pre-verification, generating corresponding prompt information based on the result of the pre-verification;

[0161] The pre-check includes at least one of a first word check, a mixed check of aggregation and non-aggregation, and an illegal character check;

[0162] The first word check is used to determine whether the first word of the field construction formula is a positive or negative sign;

[0163] The mixed aggregation-non-aggregation check is used to determine whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0164] The illegal character check is used to determine whether the field construction formula includes a preset illegal character.

[0165] In some embodiments, the constructed verification module includes an EVAL function verification unit for:

[0166] Performing syntax check on the field construction formula based on the EVAL function;

[0167] When the field construction formula fails to pass the syntax check based on the EVAL function, a corresponding prompt message is generated based on the result of the syntax check.

[0168] In some embodiments, the built-in verification module 910 includes a post-verification unit for:

[0169] Post-checking the field construction formula based on a preset post-check rule;

[0170] When the field construction formula does not announce the post-verification, generating corresponding prompt information based on the result of the post-verification;

[0171] The post-check includes at least one of isNaN check, aggregate-non-aggregate mixed check, aggregate nested check, special character check, and Chinese character check;

[0172] The isNaN check is used to check whether the field construction formula is a meaningless construction formula;

[0173] The aggregation-non-aggregation mixed check is used to check whether there are data using aggregation functions and data not using aggregation functions in the field construction formula;

[0174] The aggregation nesting check is used to check whether the aggregation function has nested aggregation values;

[0175] The special character check is used to determine whether the field construction formula includes a preset special character;

[0176] The Chinese character check is used to perform Chinese character check on the field construction formula through a regular expression.

[0177] In some embodiments, the prompt information includes at least one of an abnormal location, an abnormal event, and a modification suggestion.

[0178] The grammatical verification device for the field construction formula provided in the embodiment of the present invention can perform grammatical validity verification of the field construction formula before executing specific field construction in the database, thereby avoiding database errors caused by frequent execution of incorrect construction formulas, and at the same time avoiding the problem of difficulty in understanding and handling caused by database errors to users.

[0179] Embodiment 6

[0180] On the basis of the above embodiments, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the above embodiments.

[0181] In some implementations of this embodiment, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that when the computer program is executed by a processor, the steps of the method described in the above embodiment are implemented.

[0182] In some implementations of this embodiment, a computer program product is provided, including a computer program / instructions, characterized in that when the computer program is executed by a processor, the steps of the method described in the above embodiment are implemented.

[0183] The processor may include, but is not limited to, one or more processors or microprocessors. Each processor may be an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components to execute the method in the above embodiments.

[0184] The computer-readable storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof. The computer-readable storage medium may include, but is not limited to, for example, random access memory (RAM), read-only memory (ROM), flash memory, EPROM memory, EEPROM memory, registers, computer storage media (e.g., hard disk, floppy disk, solid-state drive, removable disk, CDROM, DVDROM, Blu-ray disc, etc.).

[0185] The computer-readable storage medium may also store at least one computer executable program / instruction, which may be, for example, a computer-readable instruction. The computer-readable storage medium includes, but is not limited to, for example, a volatile memory and / or a non-volatile memory. The volatile memory may include, for example, a random access memory (RAM) and / or a cache memory (cache), etc. The computer-readable storage medium may include, for example, a read-only memory (ROM), a hard disk, a flash memory, etc. For example, a non-transitory computer-readable storage medium may be connected to a computing device such as a computer, and then, when the computing device runs the computer-readable instructions stored on the computer-readable storage medium, the various methods described above may be performed.

[0186] In addition, the computer device may also include (but not limited to) a data bus, an input / output (I / O) bus, a display, and input / output devices (eg, keyboard, mouse, speaker, etc.), etc.

[0187] The processor may communicate with external devices via an I / O bus via a wired or wireless network.

[0188] In one embodiment, the at least one computer executable instruction may also be compiled into or constitute a software product / computer program product, wherein one or more computer executable instructions are executed by a processor to perform the various functions and / or method steps in the embodiments described in the present technology.

[0189] In the embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0190] It should be noted that in the present disclosure, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element limited by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0191] Although the embodiments disclosed in the present disclosure are as above, the above contents are only embodiments adopted for facilitating the understanding of the present disclosure and are not intended to limit the present disclosure. Any technician in the technical field to which the present disclosure belongs can make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in the present disclosure, but the scope of patent protection of the present disclosure shall still be subject to the scope defined in the attached claims.

Claims

1. A syntax checking method for field construction, characterized in that: include: Obtaining a field construction formula for a database, and performing syntax verification on the field construction formula based on a preset syntax verification rule; The field construction formula that passes the syntax check is sent to the database for field construction.

2. The method according to claim 1, characterized in that The step of obtaining a field construction formula for a database includes: Obtaining and displaying the existing field information of the database; A field construction formula input by a user based on the existing field information is received; the field construction formula includes an operation relationship of the existing fields in the database.

3. The method according to claim 1, characterized in that Before performing syntax checking on the field construction formula based on the preset syntax checking rule, the method further includes: Preprocessing the field construct based on a preset preprocessing rule; The preprocessing includes at least one of function-function relationship replacement processing, field-number distinguishing mark processing, and field-type-string relationship replacement; The function-function relationship replacement process is used to replace the function in the field construction formula with a specified format, wherein the specified format includes a Math.floor format; The field-number distinguishing mark processing is used to replace the field named by the number; The field-type-string relationship replacement is used to replace the indicator field and the record number field in the field construction formula.

4. The method according to claim 1, characterized in that Before performing syntax checking on the field construction formula based on the preset syntax checking rule, the method further includes: Pre-checking the field construction formula based on preset pre-checking rules; When the field construction formula fails to pass the pre-verification, generating corresponding prompt information based on the result of the pre-verification; The pre-check includes at least one of a first word check, a mixed check of aggregation and non-aggregation, and an illegal character check; The first word check is used to determine whether the first word of the field construction formula is a positive or negative sign; The mixed aggregation-non-aggregation check is used to determine whether there are data using aggregation functions and data not using aggregation functions in the field construction formula; The illegal character check is used to determine whether the field construction formula includes a preset illegal character.

5. The method according to claim 1, characterized in that The performing grammar checking on the field construction formula based on a preset grammar checking rule includes: Performing syntax check on the field construction formula based on the EVAL function; When the field construction formula fails to pass the syntax check based on the EVAL function, a corresponding prompt message is generated based on the result of the syntax check.

6. The method according to claim 1, characterized in that After the syntax check of the field construction formula is performed based on the preset syntax check rule, the method further includes: Post-checking the field construction formula based on a preset post-check rule; When the field construction formula is not post-checked, generating corresponding prompt information based on the result of the post-check; The post-check includes at least one of isNaN check, aggregate-non-aggregate mixed check, aggregate nested check, special character check, and Chinese character check; The isNaN check is used to check whether the field construction formula is a meaningless construction formula; The aggregation-non-aggregation mixed check is used to check whether there are data using aggregation functions and data not using aggregation functions in the field construction formula; The aggregation nesting check is used to check whether the aggregation function has nested aggregation values; The special character check is used to determine whether the field construction formula includes a preset special character; The Chinese character check is used to perform Chinese character check on the field construction formula through a regular expression.

7. The method according to any one of claims 4 to 6, characterized in that: The prompt information includes at least one of an abnormal location, an abnormal event, and a modification suggestion.

8. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.