# US 2021/0240455 A1 · Automatic Type Determination For Database Programming

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0240455 A1
- Document ID: US20210240455A1
- Status: Published application
- Kind: A1
- Application number: 16/780,706
- Filed: 2020-02-03
- Published: 2021-08-05
- Earliest claimed: 2020-02-03
- Assignees: Sap SE
- Applicants: Sap SE
- Inventors: Chanho Jeong; Boyeong Jeon; Kiyoung Kim
- Web page: https://patentgrep.com/patent/US20210240455A1

## CPC

- G06F 8/437: {Type checking}
- G06F 8/427: {Parsing}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## 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.

## Claims

### Claim 1

A method, comprising:
receiving a programming language statement comprising a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
processing the expression to deduce a data type of the 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.

### Claim 2 (depends on 1)

The method of claim 1, wherein said processing the expression includes:
parsing the expression into one or more nodes;
determining whether the expression comprises a scalar expression or a tabular expression;
if the expression comprises a scalar expression, using a scalar-type deductor to deduce the data type of the expression; and
if the expression comprises a tabular expression, using a table-type deductor to deduce the data type of the expression.

### Claim 3 (depends on 2)

The method of claim 2, 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.

### Claim 4 (depends on 3)

The method of claim 3, 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.

### Claim 5 (depends on 4)

The method of claim 4, wherein when the node is an integer, the constant mapping function analyzes ASCII code associated with the integer for mapping the integer to the integer data type.

### Claim 6 (depends on 3)

The method of claim 3, 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.

### Claim 7 (depends on 3)

The method of claim 3, wherein mapping a node of the one or more nodes comprises, when the node is a function, using a function table to look up a data type of the function based on one or more input types of the function.

### Claim 8 (depends on 3)

The method of claim 3, 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.

### Claim 9 (depends on 2)

The method of claim 2, wherein the expression comprises a select clause and a from clause, wherein using the table-type deductor includes:
processing the from clause to build an internal type map, the internal type map including a set of column names and a set of data types associated with the set of column names; and
processing the select clause based on the internal type map to deduce the data type of the expression.

### Claim 10 (depends on 9)

The method of claim 9, wherein processing the from clause to build the internal type map includes obtaining the set of column names and the set of data types associated with the set of column names from metadata associated with a set of tables specified in the from clause.

### Claim 11 (depends on 9)

The method of claim 9, wherein said processing the select clause includes processing a projection list specified within the select clause to retrieve at least one column name in the set of column names and at least one data type in the set of data types associated with the set of column names from the internal type map to deduce the data type of the expression.

### Claim 12 (depends on 11)

The method of claim 11, wherein when the projection list includes a set of scalar expressions, processing the select clause includes using the scalar type deductor to deduce the data type of the expression.

### Claim 13

A non-transitory machine-readable medium storing a program executable by at least one processing unit of a device, the program comprising sets of instructions for:
receiving a programming language statement comprising a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
processing the expression to deduce a data type of an 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.

### Claim 14 (depends on 13)

The non-transitory machine-readable medium of claim 13, wherein said processing the expression includes:
parsing the expression into one or more nodes;
determining whether the expression comprises a scalar expression or a tabular expression;
if the expression comprises a scalar expression, using a scalar-type deductor to deduce the data type of the expression; and
if the expression comprises a tabular expression, using a table-type deductor to deduce the data type of the expression.

### Claim 15 (depends on 14)

The non-transitory machine-readable medium of claim 14, 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.

### Claim 16 (depends on 15)

The non-transitory machine-readable medium of claim 15, 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.

### Claim 17 (depends on 14)

The non-transitory machine-readable medium of claim 14, wherein the expression comprises a select clause and a from clause, wherein using the table-type deductor includes:
processing the from clause to build an internal type map, the internal type map including a set of column names and a set of data types associated with the set of column names; and
processing the select clause based on the internal type map to deduce the data type of the expression.

### Claim 18 (depends on 17)

The non-transitory machine-readable medium of claim 17, wherein processing the from clause to build the internal type map includes obtaining the set of column names and the set of data types associated with the set of column names from metadata associated with a set of tables specified in the from clause, and wherein said processing the select clause includes processing a projection list specified within the select clause to retrieve at least one column name in the set of column names and at least one data type in the set of data types associated with the set of column names from the internal type map to deduce the data type of the expression.

### Claim 19

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 comprising a variable, an expression to which the variable is set, and a request to determine a data type of the variable;
process the expression to deduce a data type of the expression; and
assign 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.

### Claim 20 (depends on 19)

The system of claim 19, wherein said processing the expression includes:
parsing the expression into one or more nodes;
determining whether the expression comprises a scalar expression or a tabular expression;
if the expression comprises a scalar expression, using a scalar-type deductor to deduce the data type of the expression; and
if the expression comprises a tabular expression, using a table-type deductor to deduce the data type of the expression.
