Automatic type determination for database programming
AssigneeSap SE
InventorsChanho Jeong, Boyeong Jeon, Kiyoung Kim
Life of this patent
Estimating the term…
Abstract
In one embodiment, the present disclosure pertains to automated data type determination of variables that are written in a programming language. In one embodiment, a programming language statement is received. The programming language statement includes a variable, an expression to which the variable is set, and a request to determine a data type of the variable. The expression is processed to deduce a data type of the expression. In certain embodiments, the data type of the expression is then assigned as the data type of the variable such that the data type can be used when the programming language statement is compiled into machine executable code.
Claims15
A method comprising:
- receiving a programming language statement that includes a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
- deducing a data type of the expression by at least
- determining an element type for an individual element of the expression, and
- processing the individual element based on whether the element type determined corresponds to a scalar expression or a tabular expression;
- and
- assigning the data type of the expression as the data type of the variable, the data type of the variable for use when the programming language statement is compiled into machine executable code,
- wherein said deducing the data type of the expression includes:
- parsing the expression into one or more nodes;
- as a result of determining that the expression comprises a scalar expression, using a scalar-type deductor to deduce the data type of the expression;
- and
- as a result of determining that the expression comprises a tabular expression, using a table-type deductor to deduce the data type of the expression
- wherein using the scalar-type deductor includes:
- mapping each of the one or more nodes of the expression to respective data types;
- and
- determining the data type of the expression based on the respective data types of each of the one or more nodes of the expression,
- and wherein mapping a node of the one or more nodes comprises, when the node is a constant, using a constant mapping function to map the node to an integer data type, a decimal data type, or a string data type.
A non-transitory machine-readable medium storing instructions that, as a result of execution by at least one processing unit of a device, causes the device to perform operations comprising:
- receiving a programming language statement that includes a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
- deducing a data type of the expression, by at least
- determining an element type of an individual element of the expression, and
- processing the individual element based on whether the element type determined corresponds to a scalar expression or a tabular expression;
- and
- assigning the data type of the expression as the data type of the variable, the data type of the variable for use when the programming language is compiled into machine executable code,
- wherein said deducing the data type of the expression includes:
- parsing the expression into one or more nodes;
- as a result of determining that the expression comprises a scalar expression, using a scalar-type deductor to deduce the data type of the expression;
- and
- as a result of determining that the expression comprises a tabular expression,
- using a table-type deductor to deduce the data type of the expression,
- wherein using the scalar-type deductor includes:
- mapping each of the one or more nodes of the expression to respective data types;
- and
- determining the data type of the expression based on the respective data types of each of the one or more nodes of the expression,
- wherein mapping a node of the one or more nodes comprises, when the node is a constant, using a constant mapping function to map the node to an integer data type, a decimal data type, or a string data type,
- wherein mapping a node of the one or more nodes comprises, when the node is a variable, using a variable table to look up a data type of the variable,
- wherein mapping a node of the one or more nodes comprises, when the node is a subquery, using the table-type deductor to determine a data type of the result-set of the subquery.
A system comprising:
- a set of processing units;
- and
- a non-transitory machine-readable medium storing instructions that when executed by at least one processing unit in the set of processing units cause the at least one processing unit to:
- receive a programming language statement that includes a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
- deduce a data type of the expression by at least
- determining an element type for an individual element of the expression, and
- processing the individual element based on whether the element type determined corresponds to a scalar expression or a tabular expression;
- and
- assigning the data type of the expression as the data type of the variable, the data type of the variable for use when the programming language statement is compiled into machine executable code,
- wherein execution of said instructions cause the at least one processing unit to:
- parse the expression into one or more nodes;
- as a result of the expression including a scalar expression, use a scalar-type deductor to deduce the data type of the expression;
- and
- as a result of the expression including a tabular expression, use a table-type deductor to deduce the data type of the expression, and
- wherein using the scalar type deductor includes:
- mapping each of the one or more nodes of the expression to respective data types;
- and
- determining the data type of the expression based on the respective data types of each of the one or more nodes of the expression,
- wherein mapping a node of the one or more nodes comprises, when the node is a constant, using a constant mapping function to map the node to an integer data type, a decimal data type, or a string data type.
Dependencies are inferred from the claim text.