@@ -68,7 +68,12 @@ func (l *jaegerLogrus) Error(s string) {
68
68
l .Entry .Error (s )
69
69
}
70
70
71
- func NewDatabaseEngine (readonly bool , version string , parallelism int ) * sqle.Engine {
71
+ func NewDatabaseEngine (
72
+ readonly bool ,
73
+ version string ,
74
+ parallelism int ,
75
+ squash bool ,
76
+ ) * sqle.Engine {
72
77
catalog := sql .NewCatalog ()
73
78
ab := analyzer .NewBuilder (catalog )
74
79
if readonly {
@@ -79,6 +84,10 @@ func NewDatabaseEngine(readonly bool, version string, parallelism int) *sqle.Eng
79
84
ab = ab .WithParallelism (parallelism )
80
85
}
81
86
87
+ if squash {
88
+ ab = ab .AddPostAnalyzeRule (rule .SquashJoinsRule , rule .SquashJoins )
89
+ }
90
+
82
91
a := ab .Build ()
83
92
engine := sqle .New (catalog , a , & sqle.Config {
84
93
VersionPostfix : version ,
@@ -162,7 +171,12 @@ func (c *Server) Execute(args []string) error {
162
171
163
172
func (c * Server ) buildDatabase () error {
164
173
if c .engine == nil {
165
- c .engine = NewDatabaseEngine (c .ReadOnly , c .Version , int (c .Parallelism ))
174
+ c .engine = NewDatabaseEngine (
175
+ c .ReadOnly ,
176
+ c .Version ,
177
+ int (c .Parallelism ),
178
+ ! c .DisableSquash ,
179
+ )
166
180
}
167
181
168
182
c .pool = gitbase .NewRepositoryPool ()
@@ -183,12 +197,6 @@ func (c *Server) buildDatabase() error {
183
197
184
198
if ! c .DisableSquash {
185
199
logrus .Info ("squash tables rule is enabled" )
186
- a := analyzer .NewBuilder (c .engine .Catalog ).
187
- AddPostAnalyzeRule (rule .SquashJoinsRule , rule .SquashJoins ).
188
- Build ()
189
-
190
- a .CurrentDatabase = c .engine .Analyzer .CurrentDatabase
191
- c .engine .Analyzer = a
192
200
} else {
193
201
logrus .Warn ("squash tables rule is disabled" )
194
202
}
0 commit comments