Query transformation
First Claim
1. A method of transforming an unsupported database query into a supported database query that can be fully computed by a target database, the unsupported database query comprising a select list including a plurality of expressions, the plurality of expressions each having a control break, the plurality of expressions including an expression that cannot be directly computed by the target database, the method comprising:
- constructing a derived table from the unsupported database query, wherein constructing the derived table comprises;
constructing a new select list of the derived table;
traversing the plurality of expressions of the select list of the unsupported database query and for each of the expressions;
determining a corresponding expression to add to the new select list, wherein determining the corresponding expression to add to the new select list comprises determining an aggregate of the expression and determining a control break of the aggregate;
adding the corresponding expression to the new select list;
adding the control break of the expression to an ordered list of control breaks, wherein the ordered list is ordered from a shortest control break with a fewest number of columns to a longest control break with a highest number of columns; and
when the control break of the aggregate has fewer columns than the longest control break of the order list of control breaks, and the aggregate of the expression is of the form AGG(C0);
replacing the expression AGG(C0) OVER (PARTITION BY C1, C2, . . . , Ck) with an expression of the form AGG(AGG(C0)) OVER(PARTITION C1, C2, . . . , Ck), where each C is a column, where n is a number of columns in the longest control break, and where k is a number of columns in the other control break; and
adding a GROUP BY expression to the derived table based on the new select list of the derived table;
determining the unsupported database query can be transformed into a supported database query, wherein determining the unsupported database query can be transformed into the supported database query comprises determining all control breaks of the unsupported database query are compatible based on the ordered list; and
constructing the supported database query using the unsupported database query and the derived table.
2 Assignments
0 Petitions
Accused Products
Abstract
A mechanism is provided for transforming an original database query into a supported database query that can be fully computed by a target database. The original database query comprising a select list including a plurality of expressions, the plurality of expressions having a control break. The plurality of expressions includes an expression that cannot be directly computed by the target database. The mechanism constructs a derived table from the unsupported database query comprising constructing a new select list of the derived table, traversing the plurality of expressions of the select list of the unsupported database query, and adding a GROUP BY expression to the derived table based on the new select list of the derived table. The mechanism constructs the supported database query using the unsupported database query and the derived table.
-
Citations
19 Claims
-
1. A method of transforming an unsupported database query into a supported database query that can be fully computed by a target database, the unsupported database query comprising a select list including a plurality of expressions, the plurality of expressions each having a control break, the plurality of expressions including an expression that cannot be directly computed by the target database, the method comprising:
-
constructing a derived table from the unsupported database query, wherein constructing the derived table comprises; constructing a new select list of the derived table; traversing the plurality of expressions of the select list of the unsupported database query and for each of the expressions; determining a corresponding expression to add to the new select list, wherein determining the corresponding expression to add to the new select list comprises determining an aggregate of the expression and determining a control break of the aggregate; adding the corresponding expression to the new select list; adding the control break of the expression to an ordered list of control breaks, wherein the ordered list is ordered from a shortest control break with a fewest number of columns to a longest control break with a highest number of columns; and when the control break of the aggregate has fewer columns than the longest control break of the order list of control breaks, and the aggregate of the expression is of the form AGG(C0);
replacing the expression AGG(C0) OVER (PARTITION BY C1, C2, . . . , Ck) with an expression of the form AGG(AGG(C0)) OVER(PARTITION C1, C2, . . . , Ck), where each C is a column, where n is a number of columns in the longest control break, and where k is a number of columns in the other control break; andadding a GROUP BY expression to the derived table based on the new select list of the derived table; determining the unsupported database query can be transformed into a supported database query, wherein determining the unsupported database query can be transformed into the supported database query comprises determining all control breaks of the unsupported database query are compatible based on the ordered list; and constructing the supported database query using the unsupported database query and the derived table. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8, 9, 10)
-
-
11. A computer program product comprising a computer readable memory having computer readable code embodied therein for use in the execution in a computer of a method of transforming an unsupported database query into a supported database query that can be fully computed by a target database, the unsupported database query comprising a select list including a plurality of expressions, the plurality of expressions each having a control break, the plurality of expressions including an expression that cannot be directly computed by the target database, the computer comprising a processor coupled to the computer storage medium for executing the computer readable code, the method comprising:
-
constructing a derived table from the unsupported database query, wherein constructing a derived table from the unsupported database query comprises; constructing a new select list of the derived table; traversing the plurality of expressions of the select list of the unsupported database query and for each of the expressions; determining a corresponding expression to add to the new select list, wherein determining the corresponding expression to add to the new select list comprises determining an aggregate of the expression and determining the control break of the aggregate; adding the corresponding expression to the new select list; adding the control break of the expression to an ordered list of control breaks, wherein the ordered list is ordered from a shortest control break with a fewest number of columns to a longest control break with a highest number of columns; and when the control break of the aggregate has fewer columns than the longest control break of the order list of control breaks, and the aggregate of the expression is of the form AGG(C0);
replacing the expression AGG(C0) OVER (PARTITION BY C1, C2, . . . , Ck) with an expression of the form AGG(AGG(C0)) OVER (PARTITION C1, C2, . . . , Ck), where each C is a column, where n is a number of columns in the longest control break, and where k is a number of columns in the other control break; andadding a GROUP BY expression to the derived table based on the new select list of the derived table; determining the unsupported database query can be transformed into a supported database query, wherein determining the unsupported database query can be transformed into a supported database query comprises determining all control breaks of the unsupported database query are compatible based on the ordered list; and constructing the supported database query using the unsupported database query and the derived table. - View Dependent Claims (12, 13, 14, 15)
-
-
16. A computer comprising:
-
a processor; and a computer readable memory having computer readable code embodied therein for use in the execution by the processor of a method of transforming an unsupported database query into a supported database query that can be fully computed by a target database, the unsupported database query comprising a select list including a plurality of expressions, the plurality of expressions each having a control break, the plurality of expressions including an expression that cannot be directly computed by the target database, the method comprising; constructing a derived table from the unsupported database query, wherein constructing a derived table from the unsupported database query comprises; constructing a new select list of the derived table; traversing the plurality of expressions of the select list of the unsupported database query and for each of the expressions; determining a corresponding expression to add to the new select list, wherein determining the corresponding expression to add to the new select list comprises determining an aggregate of the expression and determining the control break of the aggregate; adding the corresponding expression to the new select list; adding the control break of the expression to an ordered list of control breaks, wherein the ordered list is ordered from a shortest control break with a fewest number of columns to a longest control break with a highest number of columns; when the control break of the aggregate has fewer columns than the longest control break of the order list of control breaks, and the aggregate of the expression is of the form AGG(C0);
replacing the expression AGG(C0) OVER (PARTITION BY C1, C2, . . . , Ck) with an expression of the form AGG(AGG(C0)) OVER (PARTITION C1, C2, . . . , Ck), where each C is a column, where n is a number of columns in the longest control break, and where k is a number of columns in the other control break; andadding a GROUP BY expression to the derived table based on the new select list of the derived table; determining the unsupported database query can be transformed into a supported database query, wherein determining the unsupported database query can be transformed into a supported database query comprises determining all control breaks of the unsupported database query are compatible based on the ordered list; and constructing the supported database query using the unsupported database query and the derived table. - View Dependent Claims (17, 18, 19)
-
Specification