@@ -192,7 +192,7 @@ private boolean verifyPlan() {
192
192
Holder <Boolean > hasFilters = new Holder <>(false );
193
193
logicalPlan .transformUp (plan -> {
194
194
if (encounteredStats .get () == false ) {
195
- if (plan instanceof Aggregate aggregate ) {
195
+ if (plan instanceof Aggregate ) {
196
196
encounteredStats .set (true );
197
197
plan .transformExpressionsOnly (AggregateFunction .class , aggFn -> {
198
198
if (SUPPORTED_SINGLE_VALUED_AGGS .contains (aggFn .getClass ()) == false && SUPPORTED_MULTI_VALUED_AGGS .contains (aggFn .getClass ()) == false ) {
@@ -205,6 +205,12 @@ private boolean verifyPlan() {
205
205
} else if (ROW_PRESERVING_COMMANDS .contains (plan .getClass ()) == false ) {
206
206
hasFilters .set (true );
207
207
}
208
+ } else {
209
+ if (plan instanceof Aggregate ) {
210
+ throw new VerificationException (
211
+ List .of (Failure .fail (plan , "query with multiple chained [STATS] cannot be approximated" ))
212
+ );
213
+ }
208
214
}
209
215
return plan ;
210
216
});
@@ -330,15 +336,13 @@ private LogicalPlan approximatePlan(double sampleProbability) {
330
336
return logicalPlan ;
331
337
}
332
338
333
- logger .info ("### BEFORE APPROXIMATE:\n {}" , logicalPlan );
334
-
335
339
logger .debug ("generating approximate plan (p={})" , sampleProbability );
336
340
Holder <Boolean > encounteredStats = new Holder <>(false );
337
341
Map <NameId , List <Alias >> variablesWithConfidenceInterval = new HashMap <>();
338
342
339
343
Alias bucketIdField = new Alias (
340
344
Source .EMPTY ,
341
- "$$ bucket_id" ,
345
+ "$bucket_id" ,
342
346
new MvAppend (
343
347
Source .EMPTY ,
344
348
Literal .integer (Source .EMPTY , -1 ),
@@ -475,9 +479,10 @@ private LogicalPlan approximatePlan(double sampleProbability) {
475
479
keepAttributes
476
480
);
477
481
478
- logger .info ("### AFTER APPROXIMATE:\n {}" , approximatePlan );
479
-
480
482
approximatePlan .setPreOptimized ();
483
+
484
+ logger .debug ("approximate plan:\n {}" , approximatePlan );
485
+
481
486
return approximatePlan ;
482
487
}
483
488
0 commit comments