rawsql-ts 0.28.0 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +2 -2
- package/dist/esm/index.min.js.map +4 -4
- package/dist/esm/transformers/ConditionDeduplicationOptimizer.d.ts +22 -0
- package/dist/esm/transformers/ConditionDeduplicationOptimizer.js +198 -0
- package/dist/esm/transformers/ConditionDeduplicationOptimizer.js.map +1 -0
- package/dist/esm/transformers/ConditionOptimization.d.ts +31 -1
- package/dist/esm/transformers/ConditionOptimization.js +321 -4
- package/dist/esm/transformers/ConditionOptimization.js.map +1 -1
- package/dist/esm/transformers/ParameterConditionPlacementOptimizer.d.ts +13 -0
- package/dist/esm/transformers/ParameterConditionPlacementOptimizer.js +238 -87
- package/dist/esm/transformers/ParameterConditionPlacementOptimizer.js.map +1 -1
- package/dist/esm/transformers/PredicateExpressionUtils.d.ts +16 -0
- package/dist/esm/transformers/PredicateExpressionUtils.js +74 -0
- package/dist/esm/transformers/PredicateExpressionUtils.js.map +1 -0
- package/dist/esm/transformers/PredicateReachabilityAnalyzer.d.ts +88 -0
- package/dist/esm/transformers/PredicateReachabilityAnalyzer.js +495 -0
- package/dist/esm/transformers/PredicateReachabilityAnalyzer.js.map +1 -0
- package/dist/esm/transformers/StaticPredicatePlacementOptimizer.d.ts +14 -0
- package/dist/esm/transformers/StaticPredicatePlacementOptimizer.js +344 -157
- package/dist/esm/transformers/StaticPredicatePlacementOptimizer.js.map +1 -1
- package/dist/esm/transformers/TopLevelAndConditionDeduper.d.ts +10 -0
- package/dist/esm/transformers/TopLevelAndConditionDeduper.js +66 -0
- package/dist/esm/transformers/TopLevelAndConditionDeduper.js.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +2 -2
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +1 -0
- package/dist/src/transformers/ConditionDeduplicationOptimizer.d.ts +22 -0
- package/dist/src/transformers/ConditionOptimization.d.ts +31 -1
- package/dist/src/transformers/ParameterConditionPlacementOptimizer.d.ts +13 -0
- package/dist/src/transformers/PredicateExpressionUtils.d.ts +16 -0
- package/dist/src/transformers/PredicateReachabilityAnalyzer.d.ts +88 -0
- package/dist/src/transformers/StaticPredicatePlacementOptimizer.d.ts +14 -0
- package/dist/src/transformers/TopLevelAndConditionDeduper.d.ts +10 -0
- package/dist/transformers/ConditionDeduplicationOptimizer.js +202 -0
- package/dist/transformers/ConditionDeduplicationOptimizer.js.map +1 -0
- package/dist/transformers/ConditionOptimization.js +324 -4
- package/dist/transformers/ConditionOptimization.js.map +1 -1
- package/dist/transformers/ParameterConditionPlacementOptimizer.js +261 -110
- package/dist/transformers/ParameterConditionPlacementOptimizer.js.map +1 -1
- package/dist/transformers/PredicateExpressionUtils.js +88 -0
- package/dist/transformers/PredicateExpressionUtils.js.map +1 -0
- package/dist/transformers/PredicateReachabilityAnalyzer.js +508 -0
- package/dist/transformers/PredicateReachabilityAnalyzer.js.map +1 -0
- package/dist/transformers/StaticPredicatePlacementOptimizer.js +366 -179
- package/dist/transformers/StaticPredicatePlacementOptimizer.js.map +1 -1
- package/dist/transformers/TopLevelAndConditionDeduper.js +72 -0
- package/dist/transformers/TopLevelAndConditionDeduper.js.map +1 -0
- package/dist/tsconfig.browser.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ export * from './transformers/SSSQLFilterBuilder';
|
|
|
80
80
|
export type { FormattableSqlComponent, SqlComponentFormatter, SqlComponentFormatOptions } from './transformers/SqlComponentFormatter';
|
|
81
81
|
export * from './transformers/ConditionOptimization';
|
|
82
82
|
export * from './transformers/ParameterConditionPlacementOptimizer';
|
|
83
|
+
export * from './transformers/PredicateReachabilityAnalyzer';
|
|
83
84
|
export * from './transformers/StaticPredicatePlacementOptimizer';
|
|
84
85
|
export * from './transformers/PruneOptionalConditionBranches';
|
|
85
86
|
export { SchemaInfo, optimizeUnusedLeftJoins, optimizeUnusedLeftJoinsToFixedPoint, optimizeUnusedCtes, optimizeUnusedCtesToFixedPoint } from './transformers/OptimizeUnusedLeftJoins';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SelectQuery } from "../models/SelectQuery";
|
|
2
|
+
import { SqlComponentFormatOptions } from "./SqlComponentFormatter";
|
|
3
|
+
export interface ConditionDeduplicationApplied {
|
|
4
|
+
kind: "dedupe_condition";
|
|
5
|
+
conditionSql: string;
|
|
6
|
+
scopeId: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ConditionDeduplicationResult {
|
|
10
|
+
/** API output shape review: this phase mutates and returns the model only; ConditionOptimization remains responsible for compatibility sql output. */
|
|
11
|
+
query: SelectQuery | null;
|
|
12
|
+
applied: readonly ConditionDeduplicationApplied[];
|
|
13
|
+
}
|
|
14
|
+
export declare class ConditionDeduplicationOptimizer {
|
|
15
|
+
private visited;
|
|
16
|
+
private applied;
|
|
17
|
+
optimize(query: SelectQuery | null, options: SqlComponentFormatOptions): ConditionDeduplicationResult;
|
|
18
|
+
private visitSelectQuery;
|
|
19
|
+
private visitSourceExpression;
|
|
20
|
+
private visitValueComponent;
|
|
21
|
+
private dedupeCondition;
|
|
22
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery";
|
|
2
2
|
import { ParameterConditionMove, ParameterConditionOptimizationError, ParameterConditionOptimizationOptions, ParameterConditionOptimizationWarning, ParameterConditionSkipped } from "./ParameterConditionPlacementOptimizer";
|
|
3
3
|
import { StaticPredicateMove, StaticPredicatePlacementError, StaticPredicatePlacementWarning, StaticPredicateSkipped } from "./StaticPredicatePlacementOptimizer";
|
|
4
|
+
import { ConditionDeduplicationApplied } from "./ConditionDeduplicationOptimizer";
|
|
4
5
|
import { OptionalConditionPruningParameters } from "./PruneOptionalConditionBranches";
|
|
5
6
|
export type ConditionOptimizationInput = string | SelectQuery | SimpleSelectQuery;
|
|
6
|
-
export type ConditionOptimizationPhaseKind = "sssql_optional_condition" | "parameter_condition_placement" | "static_predicate_placement";
|
|
7
|
+
export type ConditionOptimizationPhaseKind = "sssql_optional_condition" | "parameter_condition_placement" | "static_predicate_placement" | "condition_deduplication";
|
|
7
8
|
export interface ConditionOptimizationOptions extends ParameterConditionOptimizationOptions {
|
|
8
9
|
/**
|
|
9
10
|
* Explicit opt-in values for SSSQL optional branch pruning.
|
|
@@ -41,6 +42,8 @@ export type ConditionOptimizationApplied = SssqlOptionalConditionApplied | (Para
|
|
|
41
42
|
phaseKind: "parameter_condition_placement";
|
|
42
43
|
}) | (StaticPredicateMove & {
|
|
43
44
|
phaseKind: "static_predicate_placement";
|
|
45
|
+
}) | (ConditionDeduplicationApplied & {
|
|
46
|
+
phaseKind: "condition_deduplication";
|
|
44
47
|
});
|
|
45
48
|
export type ConditionOptimizationSkipped = SssqlOptionalConditionSkipped | (ParameterConditionSkipped & {
|
|
46
49
|
phaseKind: "parameter_condition_placement";
|
|
@@ -65,6 +68,31 @@ export interface ConditionOptimizationSafety {
|
|
|
65
68
|
dryRun: boolean;
|
|
66
69
|
formatterGeneratedSource: boolean;
|
|
67
70
|
}
|
|
71
|
+
export interface ConditionOptimizationSourceFilterProbe {
|
|
72
|
+
kind: "source_filter_probe";
|
|
73
|
+
source: string;
|
|
74
|
+
sourceAlias: string;
|
|
75
|
+
predicate: string;
|
|
76
|
+
suggestedSql: string;
|
|
77
|
+
reason: string;
|
|
78
|
+
}
|
|
79
|
+
export interface ConditionOptimizationSkippedProbe {
|
|
80
|
+
kind: "source_filter_probe_skipped";
|
|
81
|
+
source?: string;
|
|
82
|
+
sourceAlias?: string;
|
|
83
|
+
predicate: string;
|
|
84
|
+
code: string;
|
|
85
|
+
reason: string;
|
|
86
|
+
}
|
|
87
|
+
export interface ConditionOptimizationDiagnostics {
|
|
88
|
+
/**
|
|
89
|
+
* Probe diagnostics are collected after SSSQL optional pruning/refresh and
|
|
90
|
+
* before parameter/static placement phases, so they describe the pre-placement
|
|
91
|
+
* source-filter debugging snapshot rather than the final rewritten query.
|
|
92
|
+
*/
|
|
93
|
+
probes: readonly ConditionOptimizationSourceFilterProbe[];
|
|
94
|
+
skippedProbes: readonly ConditionOptimizationSkippedProbe[];
|
|
95
|
+
}
|
|
68
96
|
export interface ConditionOptimizationResult {
|
|
69
97
|
ok: boolean;
|
|
70
98
|
sql: string;
|
|
@@ -75,6 +103,8 @@ export interface ConditionOptimizationResult {
|
|
|
75
103
|
warnings: readonly ConditionOptimizationWarning[];
|
|
76
104
|
errors: readonly ConditionOptimizationError[];
|
|
77
105
|
safety: ConditionOptimizationSafety;
|
|
106
|
+
/** API output shape review: diagnostics is additive; sql/query keep their existing output shape for callers. */
|
|
107
|
+
diagnostics?: ConditionOptimizationDiagnostics;
|
|
78
108
|
}
|
|
79
109
|
export declare const planConditionOptimization: (input: ConditionOptimizationInput, options?: ConditionOptimizationOptions) => ConditionOptimizationResult;
|
|
80
110
|
export declare const optimizeConditions: (input: ConditionOptimizationInput, options?: ConditionOptimizationOptions) => ConditionOptimizationResult;
|
|
@@ -75,6 +75,8 @@ export declare class ParameterConditionPlacementOptimizer {
|
|
|
75
75
|
private resolveUpstreamQuery;
|
|
76
76
|
private resolveUnionTarget;
|
|
77
77
|
private resolveTargetColumns;
|
|
78
|
+
private resolveBaseTableJoinOnTarget;
|
|
79
|
+
private appendJoinOnCondition;
|
|
78
80
|
private resolveTargetColumnByOutputIndex;
|
|
79
81
|
private resolveDeepestBranchTarget;
|
|
80
82
|
private verifyColumnResolvableInQuery;
|
|
@@ -83,7 +85,10 @@ export declare class ParameterConditionPlacementOptimizer {
|
|
|
83
85
|
private resolveColumnSourceAlias;
|
|
84
86
|
private rebaseCondition;
|
|
85
87
|
private getSourceBindings;
|
|
88
|
+
private isBaseTableBinding;
|
|
89
|
+
private isInnerJoin;
|
|
86
90
|
private findNullableSideBoundary;
|
|
91
|
+
private hasLaterJoinThatNullsPriorSources;
|
|
87
92
|
private hasOuterJoin;
|
|
88
93
|
private hasDistinctOnBoundary;
|
|
89
94
|
private hasOrdinaryDistinct;
|
|
@@ -91,6 +96,14 @@ export declare class ParameterConditionPlacementOptimizer {
|
|
|
91
96
|
private collectUnionBranches;
|
|
92
97
|
private resolveUnionOutputIndex;
|
|
93
98
|
private collectSelectOutputs;
|
|
99
|
+
private collectDirectOutputMatches;
|
|
100
|
+
private hasExplicitOutputMatch;
|
|
101
|
+
private inferWildcardOutputMatches;
|
|
102
|
+
private inferWildcardTargetColumn;
|
|
103
|
+
private resolveWildcardColumnFromBinding;
|
|
104
|
+
private collectSourceOutputMatches;
|
|
105
|
+
private createColumnForBinding;
|
|
106
|
+
private createInferredOutputColumn;
|
|
94
107
|
private resolveSourceQueryForColumns;
|
|
95
108
|
private findCte;
|
|
96
109
|
private countTableSourceReferences;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { WhereClause } from "../models/Clause";
|
|
2
|
+
import { BinaryExpression, ColumnReference, ValueComponent } from "../models/ValueComponent";
|
|
3
|
+
import { SqlComponentFormatOptions } from "./SqlComponentFormatter";
|
|
4
|
+
export declare const normalizeIdentifier: (value: string) => string;
|
|
5
|
+
export declare const identifiersEqual: (left: string, right: string) => boolean;
|
|
6
|
+
export declare const unwrapParens: (expression: ValueComponent) => ValueComponent;
|
|
7
|
+
export declare const isBinaryOperator: (expression: ValueComponent, operator: string) => expression is BinaryExpression;
|
|
8
|
+
export declare const collectTopLevelAndTerms: (expression: ValueComponent) => ValueComponent[];
|
|
9
|
+
export declare const rebuildWhereWithoutTerms: (query: {
|
|
10
|
+
whereClause: WhereClause | null;
|
|
11
|
+
}, termsToRemove: ReadonlySet<ValueComponent>) => void;
|
|
12
|
+
export declare const cloneValueComponent: (expression: ValueComponent, options: SqlComponentFormatOptions) => ValueComponent;
|
|
13
|
+
export declare const cloneColumnReference: (reference: ColumnReference) => ColumnReference;
|
|
14
|
+
export declare const columnReferenceText: (reference: ColumnReference) => string;
|
|
15
|
+
export declare const sameColumnReference: (left: ColumnReference, right: ColumnReference) => boolean;
|
|
16
|
+
export declare const appendUnique: <T>(items: T[], value: T) => void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { SelectQuery, SimpleSelectQuery } from "../models/SelectQuery";
|
|
2
|
+
import { SqlComponentFormatOptions } from "./SqlComponentFormatter";
|
|
3
|
+
export type PredicateReachabilityInput = string | SelectQuery | SimpleSelectQuery;
|
|
4
|
+
export interface PredicateReachabilityOptions extends SqlComponentFormatOptions {
|
|
5
|
+
cloneInput?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface PredicateReachabilityWarning {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
detail?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface PredicateReachabilityError {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
detail?: unknown;
|
|
16
|
+
}
|
|
17
|
+
export type PredicateReachabilityMode = "rewrite_safe" | "debug_only";
|
|
18
|
+
export type PredicateReachabilityRelation = "origin" | "direct_output" | "join_equivalence";
|
|
19
|
+
export type PredicateReachabilityProbeKind = "count" | "sample";
|
|
20
|
+
export interface PredicateReachabilityScopeTarget {
|
|
21
|
+
kind: "scope" | "cte" | "table" | "subquery" | "source";
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PredicateReachabilityTarget {
|
|
25
|
+
scopeId: string;
|
|
26
|
+
relation: PredicateReachabilityRelation;
|
|
27
|
+
mode: PredicateReachabilityMode;
|
|
28
|
+
predicateSql: string;
|
|
29
|
+
via?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
export interface PredicateReachabilityBlocked {
|
|
32
|
+
scopeId: string;
|
|
33
|
+
relation: PredicateReachabilityRelation;
|
|
34
|
+
code: string;
|
|
35
|
+
reason: string;
|
|
36
|
+
via?: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
export interface PredicateReachabilityProbeTarget {
|
|
39
|
+
scopeId: string;
|
|
40
|
+
relation: PredicateReachabilityRelation;
|
|
41
|
+
mode: PredicateReachabilityMode;
|
|
42
|
+
predicateSql: string;
|
|
43
|
+
target: PredicateReachabilityScopeTarget;
|
|
44
|
+
probeKinds: readonly PredicateReachabilityProbeKind[];
|
|
45
|
+
caution?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface PredicateReachabilityPredicate {
|
|
48
|
+
predicateSql: string;
|
|
49
|
+
originScopeId: string;
|
|
50
|
+
columnReferences: readonly string[];
|
|
51
|
+
reaches: readonly PredicateReachabilityTarget[];
|
|
52
|
+
blocked: readonly PredicateReachabilityBlocked[];
|
|
53
|
+
probeTargets: readonly PredicateReachabilityProbeTarget[];
|
|
54
|
+
}
|
|
55
|
+
export interface PredicateReachabilitySafety {
|
|
56
|
+
mode: "debug_only";
|
|
57
|
+
sqlRewritten: false;
|
|
58
|
+
}
|
|
59
|
+
export interface PredicateReachabilityResult {
|
|
60
|
+
ok: boolean;
|
|
61
|
+
query: SelectQuery | null;
|
|
62
|
+
predicates: readonly PredicateReachabilityPredicate[];
|
|
63
|
+
warnings: readonly PredicateReachabilityWarning[];
|
|
64
|
+
errors: readonly PredicateReachabilityError[];
|
|
65
|
+
safety: PredicateReachabilitySafety;
|
|
66
|
+
}
|
|
67
|
+
export declare class PredicateReachabilityAnalyzer {
|
|
68
|
+
analyze(input: PredicateReachabilityInput, options?: PredicateReachabilityOptions): PredicateReachabilityResult;
|
|
69
|
+
private analyzeScope;
|
|
70
|
+
private buildProbeTargets;
|
|
71
|
+
private describeScopeTarget;
|
|
72
|
+
private resolveDirectOutputReach;
|
|
73
|
+
private resolveJoinEquivalenceReach;
|
|
74
|
+
private collectJoinEqualities;
|
|
75
|
+
private resolveSourceQuery;
|
|
76
|
+
private resolveDirectOutputColumn;
|
|
77
|
+
private collectSelectOutputs;
|
|
78
|
+
private findCte;
|
|
79
|
+
private resolveSourceBinding;
|
|
80
|
+
private resolveSourceBindingFromList;
|
|
81
|
+
private getSourceBindings;
|
|
82
|
+
private scopeIdForBinding;
|
|
83
|
+
private isInnerJoin;
|
|
84
|
+
private rebasePredicate;
|
|
85
|
+
private collectOuterColumnReferences;
|
|
86
|
+
private buildResult;
|
|
87
|
+
}
|
|
88
|
+
export declare const analyzePredicateReachability: (input: PredicateReachabilityInput, options?: PredicateReachabilityOptions) => PredicateReachabilityResult;
|
|
@@ -60,6 +60,7 @@ export interface StaticPredicatePlacementResult {
|
|
|
60
60
|
}
|
|
61
61
|
export declare class StaticPredicatePlacementOptimizer {
|
|
62
62
|
plan(input: StaticPredicatePlacementInput, options?: StaticPredicatePlacementOptions): StaticPredicatePlacementResult;
|
|
63
|
+
private placePredicatesInScopes;
|
|
63
64
|
optimize(input: StaticPredicatePlacementInput, options?: StaticPredicatePlacementOptions): StaticPredicatePlacementResult;
|
|
64
65
|
private parseInput;
|
|
65
66
|
private analyzeCandidate;
|
|
@@ -68,10 +69,13 @@ export declare class StaticPredicatePlacementOptimizer {
|
|
|
68
69
|
private resolveTarget;
|
|
69
70
|
private findRootQueryBoundary;
|
|
70
71
|
private resolveTargetPlacement;
|
|
72
|
+
private findNullableSideBoundaryForTargetColumns;
|
|
71
73
|
private resolveSourceBinding;
|
|
72
74
|
private resolveUpstreamQuery;
|
|
73
75
|
private resolveUnionTarget;
|
|
74
76
|
private resolveTargetColumns;
|
|
77
|
+
private resolveBaseTableJoinOnTarget;
|
|
78
|
+
private appendJoinOnPredicate;
|
|
75
79
|
private resolveDeepestBranchTarget;
|
|
76
80
|
private verifyColumnResolvableInQuery;
|
|
77
81
|
private isGroupKeyColumn;
|
|
@@ -79,6 +83,8 @@ export declare class StaticPredicatePlacementOptimizer {
|
|
|
79
83
|
private resolveColumnSourceAlias;
|
|
80
84
|
private rebasePredicate;
|
|
81
85
|
private getSourceBindings;
|
|
86
|
+
private isBaseTableBinding;
|
|
87
|
+
private isInnerJoin;
|
|
82
88
|
private findNullableSideBoundary;
|
|
83
89
|
private hasLaterJoinThatNullsPriorSources;
|
|
84
90
|
private hasOuterJoin;
|
|
@@ -89,6 +95,14 @@ export declare class StaticPredicatePlacementOptimizer {
|
|
|
89
95
|
private resolveUnionOutputIndex;
|
|
90
96
|
private resolveTargetColumnByOutputIndex;
|
|
91
97
|
private collectSelectOutputs;
|
|
98
|
+
private collectDirectOutputMatches;
|
|
99
|
+
private hasExplicitOutputMatch;
|
|
100
|
+
private inferWildcardOutputMatches;
|
|
101
|
+
private inferWildcardTargetColumn;
|
|
102
|
+
private resolveWildcardColumnFromBinding;
|
|
103
|
+
private collectSourceOutputMatches;
|
|
104
|
+
private createColumnForBinding;
|
|
105
|
+
private createInferredOutputColumn;
|
|
92
106
|
private resolveSourceQueryForColumns;
|
|
93
107
|
private findCte;
|
|
94
108
|
private countTableSourceReferences;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SimpleSelectQuery } from "../models/SelectQuery";
|
|
2
|
+
import { ValueComponent } from "../models/ValueComponent";
|
|
3
|
+
import { SqlComponentFormatOptions } from "./SqlComponentFormatter";
|
|
4
|
+
export interface TopLevelAndConditionDeduplicationResult {
|
|
5
|
+
expression: ValueComponent;
|
|
6
|
+
removedConditionSql: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export declare const dedupeTopLevelAndConditionsWithMetadata: (expression: ValueComponent, options: SqlComponentFormatOptions) => TopLevelAndConditionDeduplicationResult;
|
|
9
|
+
export declare const dedupeTopLevelAndConditions: (expression: ValueComponent, options: SqlComponentFormatOptions) => ValueComponent;
|
|
10
|
+
export declare const dedupeWhereTopLevelAndConditions: (query: SimpleSelectQuery, options: SqlComponentFormatOptions) => void;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConditionDeduplicationOptimizer = void 0;
|
|
4
|
+
const Clause_1 = require("../models/Clause");
|
|
5
|
+
const SelectQuery_1 = require("../models/SelectQuery");
|
|
6
|
+
const ValueComponent_1 = require("../models/ValueComponent");
|
|
7
|
+
const TopLevelAndConditionDeduper_1 = require("./TopLevelAndConditionDeduper");
|
|
8
|
+
class ConditionDeduplicationOptimizer {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.visited = new WeakSet();
|
|
11
|
+
this.applied = [];
|
|
12
|
+
}
|
|
13
|
+
optimize(query, options) {
|
|
14
|
+
this.visited = new WeakSet();
|
|
15
|
+
this.applied = [];
|
|
16
|
+
if (!query) {
|
|
17
|
+
return { query: null, applied: [] };
|
|
18
|
+
}
|
|
19
|
+
this.visitSelectQuery(query, "root", options);
|
|
20
|
+
return {
|
|
21
|
+
query,
|
|
22
|
+
applied: [...this.applied]
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
visitSelectQuery(query, scopeId, options) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
27
|
+
if (this.visited.has(query)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.visited.add(query);
|
|
31
|
+
if (query instanceof SelectQuery_1.BinarySelectQuery) {
|
|
32
|
+
this.visitSelectQuery(query.left, `${scopeId}.left`, options);
|
|
33
|
+
this.visitSelectQuery(query.right, `${scopeId}.right`, options);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!(query instanceof SelectQuery_1.SimpleSelectQuery)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
for (const cte of (_b = (_a = query.withClause) === null || _a === void 0 ? void 0 : _a.tables) !== null && _b !== void 0 ? _b : []) {
|
|
40
|
+
const cteQuery = cte.query;
|
|
41
|
+
if (cteQuery instanceof SelectQuery_1.SimpleSelectQuery || cteQuery instanceof SelectQuery_1.BinarySelectQuery) {
|
|
42
|
+
this.visitSelectQuery(cteQuery, `${scopeId}.cte:${cte.getSourceAliasName()}`, options);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
for (const item of query.selectClause.items) {
|
|
46
|
+
this.visitValueComponent(item.value, `${scopeId}.select`, options);
|
|
47
|
+
}
|
|
48
|
+
if (query.fromClause) {
|
|
49
|
+
this.visitSourceExpression(query.fromClause.source, `${scopeId}.from`, options);
|
|
50
|
+
for (const join of (_c = query.fromClause.joins) !== null && _c !== void 0 ? _c : []) {
|
|
51
|
+
const joinScope = `${scopeId}.join:${(_d = join.source.getAliasName()) !== null && _d !== void 0 ? _d : "unknown"}`;
|
|
52
|
+
this.visitSourceExpression(join.source, joinScope, options);
|
|
53
|
+
if (join.condition instanceof Clause_1.JoinOnClause) {
|
|
54
|
+
join.condition.condition = this.dedupeCondition(join.condition.condition, `${joinScope}.on`, "Removed a duplicate top-level AND condition from a JOIN ON clause.", options);
|
|
55
|
+
this.visitValueComponent(join.condition.condition, `${joinScope}.on`, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (query.whereClause) {
|
|
60
|
+
query.whereClause = new Clause_1.WhereClause(this.dedupeCondition(query.whereClause.condition, `${scopeId}.where`, "Removed a duplicate top-level AND condition from a WHERE clause.", options));
|
|
61
|
+
this.visitValueComponent(query.whereClause.condition, `${scopeId}.where`, options);
|
|
62
|
+
}
|
|
63
|
+
if (query.havingClause) {
|
|
64
|
+
query.havingClause = new Clause_1.HavingClause(this.dedupeCondition(query.havingClause.condition, `${scopeId}.having`, "Removed a duplicate top-level AND condition from a HAVING clause.", options));
|
|
65
|
+
this.visitValueComponent(query.havingClause.condition, `${scopeId}.having`, options);
|
|
66
|
+
}
|
|
67
|
+
for (const item of (_f = (_e = query.groupByClause) === null || _e === void 0 ? void 0 : _e.grouping) !== null && _f !== void 0 ? _f : []) {
|
|
68
|
+
this.visitValueComponent(item, `${scopeId}.group_by`, options);
|
|
69
|
+
}
|
|
70
|
+
for (const item of (_h = (_g = query.orderByClause) === null || _g === void 0 ? void 0 : _g.order) !== null && _h !== void 0 ? _h : []) {
|
|
71
|
+
if (item instanceof Clause_1.OrderByItem) {
|
|
72
|
+
this.visitValueComponent(item.value, `${scopeId}.order_by`, options);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.visitValueComponent(item, `${scopeId}.order_by`, options);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
visitSourceExpression(source, scopeId, options) {
|
|
80
|
+
const datasource = source.datasource;
|
|
81
|
+
if (datasource instanceof Clause_1.SubQuerySource) {
|
|
82
|
+
this.visitSelectQuery(datasource.query, `${scopeId}.subquery`, options);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (datasource instanceof Clause_1.ParenSource) {
|
|
86
|
+
const nested = datasource.source;
|
|
87
|
+
if (nested instanceof Clause_1.SubQuerySource) {
|
|
88
|
+
this.visitSelectQuery(nested.query, `${scopeId}.subquery`, options);
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (datasource instanceof Clause_1.FunctionSource && datasource.argument) {
|
|
93
|
+
this.visitValueComponent(datasource.argument, `${scopeId}.function`, options);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
visitValueComponent(value, scopeId, options) {
|
|
97
|
+
if (this.visited.has(value)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
this.visited.add(value);
|
|
101
|
+
if (value instanceof ValueComponent_1.InlineQuery) {
|
|
102
|
+
this.visitSelectQuery(value.selectQuery, `${scopeId}.inline_query`, options);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (value instanceof ValueComponent_1.ArrayQueryExpression) {
|
|
106
|
+
this.visitSelectQuery(value.query, `${scopeId}.array_query`, options);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (value instanceof ValueComponent_1.ParenExpression) {
|
|
110
|
+
this.visitValueComponent(value.expression, scopeId, options);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (value instanceof ValueComponent_1.BinaryExpression) {
|
|
114
|
+
this.visitValueComponent(value.left, scopeId, options);
|
|
115
|
+
this.visitValueComponent(value.right, scopeId, options);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (value instanceof ValueComponent_1.UnaryExpression) {
|
|
119
|
+
this.visitValueComponent(value.expression, scopeId, options);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (value instanceof ValueComponent_1.FunctionCall) {
|
|
123
|
+
if (value.argument) {
|
|
124
|
+
this.visitValueComponent(value.argument, scopeId, options);
|
|
125
|
+
}
|
|
126
|
+
if (value.filterCondition) {
|
|
127
|
+
this.visitValueComponent(value.filterCondition, `${scopeId}.filter`, options);
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (value instanceof ValueComponent_1.CastExpression) {
|
|
132
|
+
this.visitValueComponent(value.input, scopeId, options);
|
|
133
|
+
if (value.castType.argument) {
|
|
134
|
+
this.visitValueComponent(value.castType.argument, scopeId, options);
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (value instanceof ValueComponent_1.CaseExpression) {
|
|
139
|
+
if (value.condition) {
|
|
140
|
+
this.visitValueComponent(value.condition, scopeId, options);
|
|
141
|
+
}
|
|
142
|
+
for (const item of value.switchCase.cases) {
|
|
143
|
+
this.visitValueComponent(item.key, scopeId, options);
|
|
144
|
+
this.visitValueComponent(item.value, scopeId, options);
|
|
145
|
+
}
|
|
146
|
+
if (value.switchCase.elseValue) {
|
|
147
|
+
this.visitValueComponent(value.switchCase.elseValue, scopeId, options);
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (value instanceof ValueComponent_1.BetweenExpression) {
|
|
152
|
+
this.visitValueComponent(value.expression, scopeId, options);
|
|
153
|
+
this.visitValueComponent(value.lower, scopeId, options);
|
|
154
|
+
this.visitValueComponent(value.upper, scopeId, options);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (value instanceof ValueComponent_1.JsonPredicateExpression) {
|
|
158
|
+
this.visitValueComponent(value.expression, scopeId, options);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (value instanceof ValueComponent_1.ArrayExpression) {
|
|
162
|
+
this.visitValueComponent(value.expression, scopeId, options);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (value instanceof ValueComponent_1.ArrayIndexExpression) {
|
|
166
|
+
this.visitValueComponent(value.array, scopeId, options);
|
|
167
|
+
this.visitValueComponent(value.index, scopeId, options);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (value instanceof ValueComponent_1.ArraySliceExpression) {
|
|
171
|
+
this.visitValueComponent(value.array, scopeId, options);
|
|
172
|
+
if (value.startIndex) {
|
|
173
|
+
this.visitValueComponent(value.startIndex, scopeId, options);
|
|
174
|
+
}
|
|
175
|
+
if (value.endIndex) {
|
|
176
|
+
this.visitValueComponent(value.endIndex, scopeId, options);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (value instanceof ValueComponent_1.ValueList || value instanceof ValueComponent_1.TupleExpression) {
|
|
181
|
+
value.values.forEach(item => this.visitValueComponent(item, scopeId, options));
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (value instanceof ValueComponent_1.TypeValue && value.argument) {
|
|
185
|
+
this.visitValueComponent(value.argument, scopeId, options);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
dedupeCondition(condition, scopeId, reason, options) {
|
|
189
|
+
const result = (0, TopLevelAndConditionDeduper_1.dedupeTopLevelAndConditionsWithMetadata)(condition, options);
|
|
190
|
+
for (const conditionSql of result.removedConditionSql) {
|
|
191
|
+
this.applied.push({
|
|
192
|
+
kind: "dedupe_condition",
|
|
193
|
+
conditionSql,
|
|
194
|
+
scopeId,
|
|
195
|
+
reason
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return result.expression;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.ConditionDeduplicationOptimizer = ConditionDeduplicationOptimizer;
|
|
202
|
+
//# sourceMappingURL=ConditionDeduplicationOptimizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionDeduplicationOptimizer.js","sourceRoot":"","sources":["../../src/transformers/ConditionDeduplicationOptimizer.ts"],"names":[],"mappings":";;;AAAA,6CAS0B;AAC1B,uDAA0F;AAC1F,6DAkBkC;AAElC,+EAAwF;AAexF,MAAa,+BAA+B;IAA5C;QACY,YAAO,GAAG,IAAI,OAAO,EAAU,CAAC;QAChC,YAAO,GAAoC,EAAE,CAAC;IA6O1D,CAAC;IA3OU,QAAQ,CACX,KAAyB,EACzB,OAAkC;QAElC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAElB,IAAI,CAAC,KAAK,EAAE,CAAC;YACT,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,OAAO;YACH,KAAK;YACL,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;SAC7B,CAAC;IACN,CAAC;IAEO,gBAAgB,CACpB,KAAkB,EAClB,OAAe,EACf,OAAkC;;QAElC,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO;QACX,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,KAAK,YAAY,+BAAiB,EAAE,CAAC;YACrC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,OAAO,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9D,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