You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Our goal is to move the `id = 1` filter from the [`FilterExec`] node to the `DataSourceExec` node.
494
-
/// If this filter is selective it can avoid massive amounts of data being read from the source (the projection is `*` so all matching columns are read).
522
+
///
523
+
/// If this filter is selective pushing it into the scan can avoid massive
524
+
/// amounts of data being read from the source (the projection is `*` so all
525
+
/// matching columns are read).
526
+
///
495
527
/// In this simple case we:
496
528
/// 1. Enter the recursion with no filters.
497
529
/// 2. We find the [`FilterExec`] node and call [`ExecutionPlan::try_pushdown_filters`] on it.
/// Let's consider a more complex example involving a [`ProjectionExec`] node in betweeen the [`FilterExec`] and `DataSourceExec` nodes that creates a new column that the filter depends on.
553
+
/// # Example: Push filters with `ProjectionExec`
554
+
///
555
+
/// Let's consider a more complex example involving a [`ProjectionExec`]
556
+
/// node in between the [`FilterExec`] and `DataSourceExec` nodes that
557
+
/// creates a new column that the filter depends on.
522
558
///
523
559
/// ```text
524
-
// ┌──────────────────────┐
525
-
// │ CoalesceBatchesExec │
526
-
// └──────────────────────┘
527
-
// │
528
-
// ▼
529
-
// ┌──────────────────────┐
530
-
// │ FilterExec │
531
-
// │ filters = │
532
-
// │ [cost>50,id=1] │
533
-
// └──────────────────────┘
534
-
// │
535
-
// ▼
536
-
// ┌──────────────────────┐
537
-
// │ ProjectionExec │
538
-
// │ cost = price * 1.2 │
539
-
// └──────────────────────┘
540
-
// │
541
-
// ▼
542
-
// ┌──────────────────────┐
543
-
// │ DataSourceExec │
544
-
// │ projection = * │
545
-
// └──────────────────────┘
560
+
/// ┌──────────────────────┐
561
+
/// │ CoalesceBatchesExec │
562
+
/// └──────────────────────┘
563
+
/// │
564
+
/// ▼
565
+
/// ┌──────────────────────┐
566
+
/// │ FilterExec │
567
+
/// │ filters = │
568
+
/// │ [cost>50,id=1] │
569
+
/// └──────────────────────┘
570
+
/// │
571
+
/// ▼
572
+
/// ┌──────────────────────┐
573
+
/// │ ProjectionExec │
574
+
/// │ cost = price * 1.2 │
575
+
/// └──────────────────────┘
576
+
/// │
577
+
/// ▼
578
+
/// ┌──────────────────────┐
579
+
/// │ DataSourceExec │
580
+
/// │ projection = * │
581
+
/// └──────────────────────┘
546
582
/// ```
547
583
///
548
-
/// We want to push down the filters [id=1] to the `DataSourceExec` node, but can't push down `cost>50` because it requires the [`ProjectionExec`] node to be executed first.
549
-
/// A simple thing to do would be to split up the filter into two separate filters and push down the first one:
584
+
/// We want to push down the filters `[id=1]` to the `DataSourceExec` node,
585
+
/// but can't push down `cost>50` because it requires the [`ProjectionExec`]
586
+
/// node to be executed first. A simple thing to do would be to split up the
587
+
/// filter into two separate filters and push down the first one:
550
588
///
551
589
/// ```text
552
-
// ┌──────────────────────┐
553
-
// │ CoalesceBatchesExec │
554
-
// └──────────────────────┘
555
-
// │
556
-
// ▼
557
-
// ┌──────────────────────┐
558
-
// │ FilterExec │
559
-
// │ filters = │
560
-
// │ [cost>50] │
561
-
// └──────────────────────┘
562
-
// │
563
-
// ▼
564
-
// ┌──────────────────────┐
565
-
// │ ProjectionExec │
566
-
// │ cost = price * 1.2 │
567
-
// └──────────────────────┘
568
-
// │
569
-
// ▼
570
-
// ┌──────────────────────┐
571
-
// │ DataSourceExec │
572
-
// │ projection = * │
573
-
// │ filters = [ id=1] │
574
-
// └──────────────────────┘
590
+
/// ┌──────────────────────┐
591
+
/// │ CoalesceBatchesExec │
592
+
/// └──────────────────────┘
593
+
/// │
594
+
/// ▼
595
+
/// ┌──────────────────────┐
596
+
/// │ FilterExec │
597
+
/// │ filters = │
598
+
/// │ [cost>50] │
599
+
/// └──────────────────────┘
600
+
/// │
601
+
/// ▼
602
+
/// ┌──────────────────────┐
603
+
/// │ ProjectionExec │
604
+
/// │ cost = price * 1.2 │
605
+
/// └──────────────────────┘
606
+
/// │
607
+
/// ▼
608
+
/// ┌──────────────────────┐
609
+
/// │ DataSourceExec │
610
+
/// │ projection = * │
611
+
/// │ filters = [ id=1] │
612
+
/// └──────────────────────┘
575
613
/// ```
576
614
///
577
-
/// We can actually however do better by pushing down `price * 1.2 > 50` instead of `cost > 50`:
615
+
/// We can actually however do better by pushing down `price * 1.2 > 50`
0 commit comments