|
| 1 | +Raw plan: |
| 2 | +Limit |
| 3 | +├── limit: [100] |
| 4 | +├── offset: [0] |
| 5 | +└── Sort |
| 6 | + ├── sort keys: [default.customer.c_customer_id (#79) ASC NULLS LAST] |
| 7 | + ├── limit: [NONE] |
| 8 | + └── EvalScalar |
| 9 | + ├── scalars: [customer.c_customer_id (#79) AS (#79)] |
| 10 | + └── Filter |
| 11 | + ├── filters: [gt(ctr1.ctr_total_return (#48), SUBQUERY), eq(store.s_store_sk (#49), ctr1.ctr_store_sk (#7)), eq(store.s_state (#73), 'TN'), eq(ctr1.ctr_customer_sk (#3), customer.c_customer_sk (#78))] |
| 12 | + ├── subquerys |
| 13 | + │ └── Subquery (Scalar) |
| 14 | + │ ├── output_column: derived.sum(ctr_total_return) / if(count(ctr_total_return) = 0, 1, count(ctr_total_return)) * 1.2 (#147) |
| 15 | + │ └── EvalScalar |
| 16 | + │ ├── scalars: [multiply(divide(sum(ctr_total_return) (#145), if(eq(count(ctr_total_return) (#146), 0), 1, count(ctr_total_return) (#146))), 1.2) AS (#147)] |
| 17 | + │ └── Aggregate(Initial) |
| 18 | + │ ├── group items: [] |
| 19 | + │ ├── aggregate functions: [sum(ctr_total_return) AS (#145), count(ctr_total_return) AS (#146)] |
| 20 | + │ └── EvalScalar |
| 21 | + │ ├── scalars: [ctr2.ctr_total_return (#144) AS (#144), ctr2.ctr_total_return (#144) AS (#144)] |
| 22 | + │ └── Filter |
| 23 | + │ ├── filters: [eq(ctr1.ctr_store_sk (#7), ctr2.ctr_store_sk (#103))] |
| 24 | + │ └── EvalScalar |
| 25 | + │ ├── scalars: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103), Sum(sr_return_amt) (#144) AS (#144)] |
| 26 | + │ └── Aggregate(Initial) |
| 27 | + │ ├── group items: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103)] |
| 28 | + │ ├── aggregate functions: [Sum(sr_return_amt) AS (#144)] |
| 29 | + │ └── EvalScalar |
| 30 | + │ ├── scalars: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103), store_returns.sr_return_amt (#107) AS (#107)] |
| 31 | + │ └── Filter |
| 32 | + │ ├── filters: [eq(store_returns.sr_returned_date_sk (#96), date_dim.d_date_sk (#116)), eq(date_dim.d_year (#122), 2001)] |
| 33 | + │ └── Join(Cross) |
| 34 | + │ ├── build keys: [] |
| 35 | + │ ├── probe keys: [] |
| 36 | + │ ├── other filters: [] |
| 37 | + │ ├── Scan |
| 38 | + │ │ ├── table: default.store_returns (#4) |
| 39 | + │ │ ├── filters: [] |
| 40 | + │ │ ├── order by: [] |
| 41 | + │ │ └── limit: NONE |
| 42 | + │ └── Scan |
| 43 | + │ ├── table: default.date_dim (#5) |
| 44 | + │ ├── filters: [] |
| 45 | + │ ├── order by: [] |
| 46 | + │ └── limit: NONE |
| 47 | + └── Join(Cross) |
| 48 | + ├── build keys: [] |
| 49 | + ├── probe keys: [] |
| 50 | + ├── other filters: [] |
| 51 | + ├── Join(Cross) |
| 52 | + │ ├── build keys: [] |
| 53 | + │ ├── probe keys: [] |
| 54 | + │ ├── other filters: [] |
| 55 | + │ ├── EvalScalar |
| 56 | + │ │ ├── scalars: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7), Sum(sr_return_amt) (#48) AS (#48)] |
| 57 | + │ │ └── Aggregate(Initial) |
| 58 | + │ │ ├── group items: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7)] |
| 59 | + │ │ ├── aggregate functions: [Sum(sr_return_amt) AS (#48)] |
| 60 | + │ │ └── EvalScalar |
| 61 | + │ │ ├── scalars: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7), store_returns.sr_return_amt (#11) AS (#11)] |
| 62 | + │ │ └── Filter |
| 63 | + │ │ ├── filters: [eq(store_returns.sr_returned_date_sk (#0), date_dim.d_date_sk (#20)), eq(date_dim.d_year (#26), 2001)] |
| 64 | + │ │ └── Join(Cross) |
| 65 | + │ │ ├── build keys: [] |
| 66 | + │ │ ├── probe keys: [] |
| 67 | + │ │ ├── other filters: [] |
| 68 | + │ │ ├── Scan |
| 69 | + │ │ │ ├── table: default.store_returns (#0) |
| 70 | + │ │ │ ├── filters: [] |
| 71 | + │ │ │ ├── order by: [] |
| 72 | + │ │ │ └── limit: NONE |
| 73 | + │ │ └── Scan |
| 74 | + │ │ ├── table: default.date_dim (#1) |
| 75 | + │ │ ├── filters: [] |
| 76 | + │ │ ├── order by: [] |
| 77 | + │ │ └── limit: NONE |
| 78 | + │ └── Scan |
| 79 | + │ ├── table: default.store (#2) |
| 80 | + │ ├── filters: [] |
| 81 | + │ ├── order by: [] |
| 82 | + │ └── limit: NONE |
| 83 | + └── Scan |
| 84 | + ├── table: default.customer (#3) |
| 85 | + ├── filters: [] |
| 86 | + ├── order by: [] |
| 87 | + └── limit: NONE |
| 88 | + |
| 89 | +Optimized plan: |
| 90 | +Limit |
| 91 | +├── limit: [100] |
| 92 | +├── offset: [0] |
| 93 | +└── Sort |
| 94 | + ├── sort keys: [default.customer.c_customer_id (#79) ASC NULLS LAST] |
| 95 | + ├── limit: [100] |
| 96 | + └── EvalScalar |
| 97 | + ├── scalars: [customer.c_customer_id (#79) AS (#79), ctr1.ctr_total_return (#48) AS (#154), scalar_subquery_147 (#147) AS (#155), store.s_store_sk (#49) AS (#156), ctr1.ctr_store_sk (#7) AS (#157), store.s_state (#73) AS (#158), ctr1.ctr_customer_sk (#3) AS (#159), customer.c_customer_sk (#78) AS (#160)] |
| 98 | + └── Join(Inner) |
| 99 | + ├── build keys: [sr_store_sk (#103)] |
| 100 | + ├── probe keys: [sr_store_sk (#7)] |
| 101 | + ├── other filters: [gt(ctr1.ctr_total_return (#48), scalar_subquery_147 (#147))] |
| 102 | + ├── Join(Inner) |
| 103 | + │ ├── build keys: [customer.c_customer_sk (#78)] |
| 104 | + │ ├── probe keys: [ctr1.ctr_customer_sk (#3)] |
| 105 | + │ ├── other filters: [] |
| 106 | + │ ├── Aggregate(Final) |
| 107 | + │ │ ├── group items: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7)] |
| 108 | + │ │ ├── aggregate functions: [Sum(sr_return_amt) AS (#48)] |
| 109 | + │ │ └── Aggregate(Partial) |
| 110 | + │ │ ├── group items: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7)] |
| 111 | + │ │ ├── aggregate functions: [Sum(sr_return_amt) AS (#48)] |
| 112 | + │ │ └── EvalScalar |
| 113 | + │ │ ├── scalars: [store_returns.sr_customer_sk (#3) AS (#3), store_returns.sr_store_sk (#7) AS (#7), store_returns.sr_return_amt (#11) AS (#11), store_returns.sr_returned_date_sk (#0) AS (#148), date_dim.d_date_sk (#20) AS (#149), date_dim.d_year (#26) AS (#150)] |
| 114 | + │ │ └── Join(Inner) |
| 115 | + │ │ ├── build keys: [date_dim.d_date_sk (#20)] |
| 116 | + │ │ ├── probe keys: [store_returns.sr_returned_date_sk (#0)] |
| 117 | + │ │ ├── other filters: [] |
| 118 | + │ │ ├── Scan |
| 119 | + │ │ │ ├── table: default.store_returns (#0) |
| 120 | + │ │ │ ├── filters: [] |
| 121 | + │ │ │ ├── order by: [] |
| 122 | + │ │ │ └── limit: NONE |
| 123 | + │ │ └── Scan |
| 124 | + │ │ ├── table: default.date_dim (#1) |
| 125 | + │ │ ├── filters: [eq(date_dim.d_year (#26), 2001)] |
| 126 | + │ │ ├── order by: [] |
| 127 | + │ │ └── limit: NONE |
| 128 | + │ └── Scan |
| 129 | + │ ├── table: default.customer (#3) |
| 130 | + │ ├── filters: [] |
| 131 | + │ ├── order by: [] |
| 132 | + │ └── limit: NONE |
| 133 | + └── Join(Inner) |
| 134 | + ├── build keys: [sr_store_sk (#103)] |
| 135 | + ├── probe keys: [store.s_store_sk (#49)] |
| 136 | + ├── other filters: [] |
| 137 | + ├── Scan |
| 138 | + │ ├── table: default.store (#2) |
| 139 | + │ ├── filters: [eq(store.s_state (#73), 'TN')] |
| 140 | + │ ├── order by: [] |
| 141 | + │ └── limit: NONE |
| 142 | + └── EvalScalar |
| 143 | + ├── scalars: [outer.sr_store_sk (#103) AS (#103), multiply(divide(sum(ctr_total_return) (#145), if(eq(count(ctr_total_return) (#146), 0), 1, count(ctr_total_return) (#146))), 1.2) AS (#147)] |
| 144 | + └── Aggregate(Final) |
| 145 | + ├── group items: [outer.sr_store_sk (#103) AS (#103)] |
| 146 | + ├── aggregate functions: [sum(ctr_total_return) AS (#145), count(ctr_total_return) AS (#146)] |
| 147 | + └── Aggregate(Partial) |
| 148 | + ├── group items: [outer.sr_store_sk (#103) AS (#103)] |
| 149 | + ├── aggregate functions: [sum(ctr_total_return) AS (#145), count(ctr_total_return) AS (#146)] |
| 150 | + └── Aggregate(Final) |
| 151 | + ├── group items: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103)] |
| 152 | + ├── aggregate functions: [Sum(sr_return_amt) AS (#144)] |
| 153 | + └── Aggregate(Partial) |
| 154 | + ├── group items: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103)] |
| 155 | + ├── aggregate functions: [Sum(sr_return_amt) AS (#144)] |
| 156 | + └── EvalScalar |
| 157 | + ├── scalars: [store_returns.sr_customer_sk (#99) AS (#99), store_returns.sr_store_sk (#103) AS (#103), store_returns.sr_return_amt (#107) AS (#107), store_returns.sr_returned_date_sk (#96) AS (#151), date_dim.d_date_sk (#116) AS (#152), date_dim.d_year (#122) AS (#153)] |
| 158 | + └── Join(Inner) |
| 159 | + ├── build keys: [date_dim.d_date_sk (#116)] |
| 160 | + ├── probe keys: [store_returns.sr_returned_date_sk (#96)] |
| 161 | + ├── other filters: [] |
| 162 | + ├── Scan |
| 163 | + │ ├── table: default.store_returns (#4) |
| 164 | + │ ├── filters: [] |
| 165 | + │ ├── order by: [] |
| 166 | + │ └── limit: NONE |
| 167 | + └── Scan |
| 168 | + ├── table: default.date_dim (#5) |
| 169 | + ├── filters: [eq(date_dim.d_year (#122), 2001)] |
| 170 | + ├── order by: [] |
| 171 | + └── limit: NONE |
| 172 | + |
0 commit comments