IP Library Granted Patent US 12,235,839
Granted Patent B2
US 12,235,839 · App. 17/983,589 · Granted Feb 25, 2025

Processing correlated calculated fields in correlated subqueries

Inventors: Yinghua Ouyang (Xi'an, CN); Zhen Tian (Xi'an, CN)
Assignee: SAP SE
G06F16/24535G06F16/244
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,235,839
App. No.
17/983,589
Granted
Feb 25, 2025
Kind
B2
Abstract

The present disclosure involves systems, software, and computer implemented methods for processing correlated calculated fields in correlated subqueries. One example method includes receiving a request to process a database query that includes at least one subquery and processing each subquery. A determination is made as to whether each subquery includes a correlated calculated field that is a calculated field that is not included in a first datasource queried by the subquery but is included in a second datasource queried by an outer query that includes the subquery. If the subquery does not include a correlated calculated field, the subquery is processed without modification. If the subquery includes a correlated calculated field, metadata is retrieved for the outer query of the subquery that queries the second datasource and includes the correlated calculated field. The subquery is rewritten using the metadata and the rewritten subquery is processed.

Claims (49)

1. A computer-implemented method comprising:

receiving a request to process a database query that includes at least one subquery; and

processing each subquery included in the database query, including:

determining whether the subquery includes any correlated calculated fields, wherein a correlated calculated field is a calculated field that is not included in a first datasource queried by the subquery but is included in a second datasource queried by an outer query that includes the subquery;

in response to determining that the subquery does not include any correlated calculated fields, processing the subquery without modification; and

in response to determining that the subquery includes a first correlated calculated field:

identifying the outer query of the subquery that queries the second datasource that includes the first correlated calculated field;

retrieving metadata associated with the outer query and the first correlated calculated field;

rewriting the subquery using the metadata to generate a rewritten subquery that no longer includes the first correlated calculated field; and

processing the rewritten subquery.

2. The computer-implemented method of claim 1 , wherein the first correlated calculated field includes an operation involving at least one field of the second datasource.

3. The computer-implemented method of claim 2 , wherein the metadata includes information about the operation and schema and datasource qualifications for each field of the second datasource involved in the operation.

4. The computer-implemented method of claim 3 , wherein rewriting the subquery using the metadata comprises including the operation in the subquery.

5. The computer-implemented method of claim 4 , wherein rewriting the subquery using the metadata comprises qualifying, in the rewritten subquery, each field of the second datasource involved in the operation with respective schema and datasource qualifications.

6. The computer-implemented method of claim 1 , wherein the database query includes multiple subqueries that include respective correlated calculated fields.

7. The computer-implemented method of claim 6 , wherein processing each subquery includes rewriting each subquery of the multiple subqueries that includes a respective correlated calculated field.

8. The computer-implemented method of claim 1 , wherein the outer query is an immediately-adjacent query to the subquery.

9. The computer-implemented method of claim 1 , wherein the outer query is not an immediately-adjacent query to the subquery and identifying the outer query comprises evaluating multiple levels of outer queries of the subquery to identify the outer query.

10. A system comprising:

one or more computers; and

a computer-readable medium coupled to the one or more computers having instructions stored thereon which, when executed by the one or more computers, cause the one or more computers to perform operations comprising:

receiving a request to process a database query that includes at least one subquery; and

processing each subquery included in the database query, including:

determining whether the subquery includes any correlated calculated fields, wherein a correlated calculated field is a calculated field that is not included in a first datasource queried by the subquery but is included in a second datasource queried by an outer query that includes the subquery;

in response to determining that the subquery does not include any correlated calculated fields, processing the subquery without modification; and

in response to determining that the subquery includes a first correlated calculated field:

identifying the outer query of the subquery that queries the second datasource that includes the first correlated calculated field;

retrieving metadata associated with the outer query and the first correlated calculated field;

rewriting the subquery using the metadata to generate a rewritten subquery that no longer includes the first correlated calculated field; and

processing the rewritten subquery.

11. The system of claim 10 , wherein the first correlated calculated field includes an operation involving at least one field of the second datasource.

12. The system of claim 11 , wherein the metadata includes information about the operation and schema and datasource qualifications for each field of the second datasource involved in the operation.

13. The system of claim 12 , wherein rewriting the subquery using the metadata comprises including the operation in the subquery.

14. The system of claim 13 , wherein rewriting the subquery using the metadata comprises qualifying, in the rewritten subquery, each field of the second datasource involved in the operation with respective schema and datasource qualifications.

15. The system of claim 10 , wherein the database query includes multiple subqueries that include respective correlated calculated fields.

16. A computer program product encoded on a non-transitory storage medium, the product comprising non-transitory, computer readable instructions for causing one or more processors to perform operations comprising:

receiving a request to process a database query that includes at least one subquery; and

processing each subquery included in the database query, including:

determining whether the subquery includes any correlated calculated fields, wherein a correlated calculated field is a calculated field that is not included in a first datasource queried by the subquery but is included in a second datasource queried by an outer query that includes the subquery;

in response to determining that the subquery does not include any correlated calculated fields, processing the subquery without modification; and

in response to determining that the subquery includes a first correlated calculated field:

identifying the outer query of the subquery that queries the second datasource that includes the first correlated calculated field;

retrieving metadata associated with the outer query and the first correlated calculated field;

rewriting the subquery using the metadata to generate a rewritten subquery that no longer includes the first correlated calculated field; and

processing the rewritten subquery.

17. The computer program product of claim 16 , wherein the first correlated calculated field includes an operation involving at least one field of the second datasource.

18. The computer program product of claim 17 , wherein the metadata includes information about the operation and schema and datasource qualifications for each field of the second datasource involved in the operation.

19. The computer program product of claim 18 , wherein rewriting the subquery using the metadata comprises including the operation in the subquery.

20. The computer program product of claim 19 , wherein rewriting the subquery using the metadata comprises qualifying, in the rewritten subquery, each field of the second datasource involved in the operation with respective schema and datasource qualifications.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 9, 2022
From: OUYANG, YINGHUA; TIAN, ZHEN
To: SAP SE
Reel/Frame 061704/0950 →
Continuity (1)
Related Publication 20240152513A1 · May 9, 2024
References Cited (19)
US 8521723B1 · Ahmed · 2013 [cited by examiner]
US 9665619B1 · Cole · 2017 [cited by examiner]
US 10102248B2 · Kang · 2018 [cited by examiner]
US 10545984B2 · Zhang et al. · 2020 [cited by applicant]
US 11061927B2 · Ouyang et al. · 2021 [cited by applicant]
US 11379477B2 · Ouyang et al. · 2022 [cited by applicant]
US 11423024B2 · Ouyang et al. · 2022 [cited by applicant]
US 11429610B2 · Cheng et al. · 2022 [cited by applicant]
US 20040153448A1 · Cheng · 2004 [cited by examiner]
US 20080162412A1 · Ireland · 2008 [cited by examiner]
US 20100005077A1 · Krishnamurthy · 2010 [cited by examiner]
US 20150112965A1 · Tokuda · 2015 [cited by examiner]
US 20150142775A1 · Kang · 2015 [cited by examiner]
US 20180107832A1 · Ouyang et al. · 2018 [cited by applicant]
US 20200301901A1 · Hao et al. · 2020 [cited by applicant]
US 20230289342A1 · Sun · 2023 [cited by examiner]
U.S. Appl. No. 17/462,121, filed Aug. 31, 2021, Ouyang. [cited by applicant]
Peruzal.com [online], “Calculated Fields” Jul. 2018, retrieved on Oct. 25, 2022, retrieved from URL <https://guides.peruzal.com/introduction-to-sql/calculated-fields/>, 1 page. [cited by applicant]
W3resource.com [online], “SQL Subqueries” Aug. 19, 2022, retrieved on Oct. 25, 2022, retrieved from URL <https://www.w3resource.com/sql/subqueries/understanding-sql-subqueries.php>, 13 pages. [cited by applicant]