Commit 318a350
authored
Rename scalar function strictness contract (#8930)
Changes `is_null_sensitive` to `is_strict` and flips all current
implementations (as `is_strict` implies `!is_null_sensitive`).
A function is strict only when any null input forces a null output and
its return dtype propagates that nullability.
Also fixes `Between` and `Dynamic` scalar functions as they were both
set to strict when they should have been non-strict, so now they are
`is_strict = false`.
## Rationale for this change
Dictionary pushdown rewrites `f(dict(codes, values), constant)` as
`dict(codes, f(values, constant))`. At a null code, the original
evaluates `f(null, constant)`, while the rewritten dictionary is always
null. This is only sound when nulling any one argument forces a null
result while the other arguments remain unchanged.
`is_null_sensitive` documented the unary case but left this
multi-argument contract ambiguous. Kleene `AND`/`OR` show the
difference: masking both inputs produces null, but `false AND null =
false` and `true OR null = true`. That ambiguity caused the bug fixed in
#8929.
Additionally, we have noticed that a large majority of our scalar
functions have strict semantics, and so in the future (hopefully soon)
we can lift out a lot of the shared null logic.
## What changes are included in this PR?
<details>
<summary>Functions that are strict, previously treated as
non-strict</summary>
<br>
These functions are strict, so the old null-sensitivity classification
was overly conservative:
- `ArrayExpr` and `RowIdx` inherited the old conservative default. These
functions take no arguments, so the strictness condition does not apply.
- `Mask` inherited the old conservative default, but a null input
remains null and its mask argument is required to be non-nullable.
- `VariantGet` inherited the old conservative default, but a null
Variant input produces a null output.
- `GetItem` and `Select` preserve the parent struct validity and
propagate its nullability.
- `Merge` only accepts non-nullable inputs, so the strictness law is
vacuously satisfied for well-typed arguments.
</details>
<details>
<summary>Functions that are non-strict, previously treated as
strict</summary>
<br>
These functions are non-strict, so the old classification allowed
unsound dictionary pushdown:
- `Between`: its comparisons are combined with Kleene `AND`; for
example, `10 BETWEEN null AND 5` is `false`, not null.
- `DynamicComparison`: when the dynamic RHS is absent, it returns its
configured default even when the LHS is null.
</details>
<details>
<summary>Remaining non-strict functions</summary>
<br>
- `Binary` for Kleene `AND`/`OR`
- `CaseWhen` and `Zip`
- `Cast`
- `FillNull`, `IsNull`, and `IsNotNull`
- `ForeignScalarFnVTable`
- `ListContains`
- `Pack`
- `RowEncode` and `RowSize`
- `StatFn`
</details>
<details>
<summary>Remaining strict functions</summary>
<br>
- `Binary` for all operators except `AND`/`OR`
- `ByteLength`, `ExtStorage`, `Like`, `ListLength`, `ListSum`, and `Not`
- `Literal`, `Root`, and `RowCount` (nullary)
- `JsonToVariant`
- `GeoContains`, `GeoDistance`, `GeoEnvelope`, and `GeoIntersects`
- `CosineSimilarity`, `InnerProduct`, `L2Denorm`, and `L2Norm`
</details>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>1 parent 1c58493 commit 318a350
53 files changed
Lines changed: 280 additions & 181 deletions
File tree
- docs/concepts
- encodings/parquet-variant/src
- vortex-array/src
- arrays
- dict/compute
- scalar_fn/vtable
- expr
- analysis
- scalar_fn
- fns
- between
- binary
- cast
- fill_null
- like
- list_contains
- mask
- not
- variant_get
- zip
- internal
- vortex-geo/src/scalar_fn
- vortex-json/src
- vortex-layout/src/layouts
- dict
- row_idx
- vortex-row/src
- vortex-tensor/src/scalar_fns
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | | - | |
| 163 | + | |
163 | 164 | | |
164 | 165 | | |
165 | 166 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
337 | 337 | | |
338 | 338 | | |
339 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
340 | 344 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | 8 | | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | 15 | | |
| 16 | + | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
309 | | - | |
| 309 | + | |
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
346 | 361 | | |
347 | 362 | | |
348 | 363 | | |
| |||
0 commit comments