github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/invertedexpr/testdata/expression (about) 1 new-span-leaf name=b tight=true span=b 2 ---- 3 tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 4 5 new-unknown-leaf name=u-tight tight=true 6 ---- 7 UnknownExpression: tight=true 8 9 new-unknown-leaf name=u-not-tight tight=false 10 ---- 11 UnknownExpression: tight=false 12 13 # ----------------------------------------------------- 14 # Tests involving UnknownExpression. 15 # ----------------------------------------------------- 16 17 # Or of tight [b, b] with tight UnknownExpression. They 18 # become the left and right child and the result is tight. 19 or result=bt left=b right=u-tight 20 ---- 21 tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 22 UNION 23 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 24 └── UnknownExpression: tight=true 25 26 # Same as previous with left and right reversed in the 27 # call to Or. 28 or result=bt left=u-tight right=b 29 ---- 30 tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 31 UNION 32 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 33 └── UnknownExpression: tight=true 34 35 # Or of tight [b, b] with non-tight UnknownExpression. 36 # Unlike bt, the result here is not tight. 37 or result=bnt left=b right=u-not-tight 38 ---- 39 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 40 UNION 41 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 42 └── UnknownExpression: tight=false 43 44 # And of tight [b, b] with tight UnknownExpression. 45 # No factoring is possible. 46 and result=b-and-unknown left=b right=u-tight 47 ---- 48 tight: true, toRead: ["b", "b"] unionSpans: empty 49 INTERSECTION 50 ├── tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 51 └── UnknownExpression: tight=true 52 53 # Similar and as previous but with non-tight UnknownExpression. 54 # Only output difference is that the result is not tight. 55 and result=b-and-unknown left=b right=u-not-tight 56 ---- 57 tight: false, toRead: ["b", "b"] unionSpans: empty 58 INTERSECTION 59 ├── tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 60 └── UnknownExpression: tight=false 61 62 # And of bt and bnt. Factoring is possible. The result is 63 # not tight. 64 and result=bt-and-bnt left=bt right=bnt 65 ---- 66 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 67 INTERSECTION 68 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 69 │ UNION 70 │ ├── tight: true, toRead: ["b", "b"] unionSpans: empty 71 │ └── UnknownExpression: tight=true 72 └── tight: false, toRead: ["b", "b"] unionSpans: empty 73 UNION 74 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 75 └── UnknownExpression: tight=false 76 77 # Or of bt and bnt. Similar to And in toRead and unionSpans. 78 or result=bt-or-bnt left=bnt right=bt 79 ---- 80 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 81 UNION 82 ├── tight: false, toRead: ["b", "b"] unionSpans: empty 83 │ UNION 84 │ ├── tight: true, toRead: ["b", "b"] unionSpans: empty 85 │ └── UnknownExpression: tight=false 86 └── tight: true, toRead: ["b", "b"] unionSpans: empty 87 UNION 88 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 89 └── UnknownExpression: tight=true 90 91 # ----------------------------------------------------- 92 # Tests involving NonInvertedColExpression. 93 # ----------------------------------------------------- 94 95 new-non-inverted-leaf name=niexpr 96 ---- 97 98 # And with a NonInvertedColExpression makes the result 99 # not tight. 100 and result=bt-and-niexpr left=bt right=niexpr 101 ---- 102 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 103 UNION 104 ├── tight: true, toRead: ["b", "b"] unionSpans: empty 105 └── UnknownExpression: tight=true 106 107 # Or with a NonInvertedColExpression results in a 108 # NonInvertedColExpression. 109 or result=bt-or-niexpr left=niexpr right=bt 110 ---- 111 {} 112 113 # ----------------------------------------------------- 114 # Tests involving only SpanExpressions. 115 # ----------------------------------------------------- 116 117 # Trivial union with self. 118 or result=b-or-b left=b right=b 119 ---- 120 tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 121 122 # Trivial intersection with self. 123 and result=b-and-b left=b right=b 124 ---- 125 tight: true, toRead: ["b", "b"] unionSpans: ["b", "b"] 126 127 new-span-leaf name=b-not-tight tight=false span=b 128 ---- 129 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 130 131 # Trivial union with tight and non-tight. 132 or result=_ left=b right=b-not-tight 133 ---- 134 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 135 136 # Trivial intersection with tight and non-tight. 137 and result=_ left=b-not-tight right=b 138 ---- 139 tight: false, toRead: ["b", "b"] unionSpans: ["b", "b"] 140 141 new-span-leaf name=ac tight=true span=a,c 142 ---- 143 tight: true, toRead: ["a", "c") unionSpans: ["a", "c") 144 145 # [b, b] or [a, c) = [a, c) 146 or result=_ left=b right=ac 147 ---- 148 tight: true, toRead: ["a", "c") unionSpans: ["a", "c") 149 150 # [b, b] and [a, c) = [b, b] 151 and result=_ left=b right=ac 152 ---- 153 tight: true, toRead: ["a", "c") unionSpans: ["b", "b"] 154 155 new-span-leaf name=bj tight=true span=b,j 156 ---- 157 tight: true, toRead: ["b", "j") unionSpans: ["b", "j") 158 159 # [b, b] or [b, j) = [b, j) 160 or result=_ left=bj right=b 161 ---- 162 tight: true, toRead: ["b", "j") unionSpans: ["b", "j") 163 164 # [b, b] and [b, j) = [b, b] 165 and result=_ left=b right=bj 166 ---- 167 tight: true, toRead: ["b", "j") unionSpans: ["b", "b"] 168 169 # [b, j) or [a, c) = [a, j) 170 or result=aj left=bj right=ac 171 ---- 172 tight: true, toRead: ["a", "j") unionSpans: ["a", "j") 173 174 # [b, j) and [a, c) 175 and result=bj-and-ac left=bj right=ac 176 ---- 177 tight: true, toRead: ["a", "j") unionSpans: ["b", "c") 178 INTERSECTION 179 ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 180 └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 181 182 # And of these expressions promotes the factored span [b, c) 183 and result=foo left=aj right=bj-and-ac 184 ---- 185 tight: true, toRead: ["a", "j") unionSpans: ["b", "c") 186 INTERSECTION 187 ├── tight: true, toRead: ["a", "j") unionSpans: ["a", "b") ["c", "j") 188 └── tight: true, toRead: ["a", "j") unionSpans: empty 189 INTERSECTION 190 ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 191 └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 192 193 # Same parameters reversed 194 and result=foo left=bj-and-ac right=aj 195 ---- 196 tight: true, toRead: ["a", "j") unionSpans: ["b", "c") 197 INTERSECTION 198 ├── tight: true, toRead: ["a", "j") unionSpans: empty 199 │ INTERSECTION 200 │ ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 201 │ └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 202 └── tight: true, toRead: ["a", "j") unionSpans: ["a", "b") ["c", "j") 203 204 # Or of these expressions causes the children of bj-and-ac to be 205 # promoted. Note that the unionSpans of the root subsume the 206 # ones of the children, which were originally the grandchildren. 207 # Further simplification is possible by transitively traversing 208 # the subtrees. 209 or result=bar left=aj right=bj-and-ac 210 ---- 211 tight: true, toRead: ["a", "j") unionSpans: ["a", "j") 212 INTERSECTION 213 ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 214 └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 215 216 and result=foo-and-bar left=foo right=bar 217 ---- 218 tight: true, toRead: ["a", "j") unionSpans: ["b", "c") 219 INTERSECTION 220 ├── tight: true, toRead: ["a", "j") unionSpans: empty 221 │ INTERSECTION 222 │ ├── tight: true, toRead: ["a", "j") unionSpans: empty 223 │ │ INTERSECTION 224 │ │ ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 225 │ │ └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 226 │ └── tight: true, toRead: ["a", "j") unionSpans: ["a", "b") ["c", "j") 227 └── tight: true, toRead: ["a", "j") unionSpans: ["a", "b") ["c", "j") 228 INTERSECTION 229 ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 230 └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 231 232 or result=foo-or-bar left=foo right=bar 233 ---- 234 tight: true, toRead: ["a", "j") unionSpans: ["a", "j") 235 UNION 236 ├── tight: true, toRead: ["a", "j") unionSpans: empty 237 │ INTERSECTION 238 │ ├── tight: true, toRead: ["a", "j") unionSpans: empty 239 │ │ INTERSECTION 240 │ │ ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 241 │ │ └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 242 │ └── tight: true, toRead: ["a", "j") unionSpans: ["a", "b") ["c", "j") 243 └── tight: true, toRead: ["a", "j") unionSpans: empty 244 INTERSECTION 245 ├── tight: true, toRead: ["b", "j") unionSpans: ["c", "j") 246 └── tight: true, toRead: ["a", "c") unionSpans: ["a", "b") 247 248 to-proto name=foo-and-bar 249 ---- 250 spans_to_read: < 251 start: "a" 252 end: "j" 253 > 254 node: < 255 factored_union_spans: < 256 start: "b" 257 end: "c" 258 > 259 operator: SetIntersection 260 left: < 261 operator: SetIntersection 262 left: < 263 operator: SetIntersection 264 left: < 265 factored_union_spans: < 266 start: "c" 267 end: "j" 268 > 269 > 270 right: < 271 factored_union_spans: < 272 start: "a" 273 end: "b" 274 > 275 > 276 > 277 right: < 278 factored_union_spans: < 279 start: "a" 280 end: "b" 281 > 282 factored_union_spans: < 283 start: "c" 284 end: "j" 285 > 286 > 287 > 288 right: < 289 factored_union_spans: < 290 start: "a" 291 end: "b" 292 > 293 factored_union_spans: < 294 start: "c" 295 end: "j" 296 > 297 operator: SetIntersection 298 left: < 299 factored_union_spans: < 300 start: "c" 301 end: "j" 302 > 303 > 304 right: < 305 factored_union_spans: < 306 start: "a" 307 end: "b" 308 > 309 > 310 > 311 > 312 313 to-proto name=foo-or-bar 314 ---- 315 spans_to_read: < 316 start: "a" 317 end: "j" 318 > 319 node: < 320 factored_union_spans: < 321 start: "a" 322 end: "j" 323 > 324 operator: SetUnion 325 left: < 326 operator: SetIntersection 327 left: < 328 operator: SetIntersection 329 left: < 330 factored_union_spans: < 331 start: "c" 332 end: "j" 333 > 334 > 335 right: < 336 factored_union_spans: < 337 start: "a" 338 end: "b" 339 > 340 > 341 > 342 right: < 343 factored_union_spans: < 344 start: "a" 345 end: "b" 346 > 347 factored_union_spans: < 348 start: "c" 349 end: "j" 350 > 351 > 352 > 353 right: < 354 operator: SetIntersection 355 left: < 356 factored_union_spans: < 357 start: "c" 358 end: "j" 359 > 360 > 361 right: < 362 factored_union_spans: < 363 start: "a" 364 end: "b" 365 > 366 > 367 > 368 > 369 370 # A nil *SpanExpression 371 to-proto name=none 372 ---- 373 <nil>