Repository navigation
Commit ce312cc
feat: handle mixed-type and NULL inputs for cosine_distance
Addresses round-2 review comments on #21542:
- Widen container variant in coerce_types when inputs mix List and
LargeList (or FixedSizeList), so mixed-type calls like
`cosine_distance([1.0, 0.0], arrow_cast([0.0, 1.0], 'LargeList(Float64)'))`
succeed. Follows the pattern from PR #21704 (ArrayConcat).
- Coerce bare NULL inputs to a matching list variant so
`cosine_distance(NULL, [1.0, 2.0])` returns NULL instead of erroring.
- Drop the `list_cosine_distance` alias — the base name is not
`array_cosine_distance`, so the `array_X` -> `list_X` convention does
not apply.
- Expand SLT coverage: mixed-type variants, FixedSizeList inputs,
Float32 and Int64 inner types, bare NULL in each position, NULL row
in a multi-row VALUES, and an unsupported-type plan error case.
Dispatch fallthrough in cosine_distance_inner is now unreachable after
the coerce_types widening, changed from exec_err! to internal_err!.
Part of #21536.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent fc3ee90 commit ce312cc
3 files changed
Lines changed: 105 additions & 45 deletions
File tree
- datafusion
- functions-nested/src
- sqllogictest/test_files
- docs/source/user-guide/sql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
34 | | - | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
82 | | - | |
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
106 | 127 | | |
107 | 128 | | |
108 | 129 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
116 | 139 | | |
117 | 140 | | |
118 | 141 | | |
119 | 142 | | |
120 | 143 | | |
121 | 144 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | 145 | | |
127 | 146 | | |
128 | 147 | | |
| |||
133 | 152 | | |
134 | 153 | | |
135 | 154 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
141 | 158 | | |
142 | 159 | | |
143 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | | - | |
| 44 | + | |
| 45 | + | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
47 | 49 | | |
48 | | - | |
49 | | - | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
74 | 84 | | |
75 | 85 | | |
76 | 86 | | |
77 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
78 | 130 | | |
79 | 131 | | |
80 | 132 | | |
81 | 133 | | |
82 | 134 | | |
83 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
84 | 140 | | |
85 | 141 | | |
86 | 142 | | |
87 | 143 | | |
88 | | - | |
| 144 | + | |
| 145 | + | |
89 | 146 | | |
90 | 147 | | |
91 | 148 | | |
92 | 149 | | |
93 | 150 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 151 | + | |
100 | 152 | | |
101 | 153 | | |
102 | 154 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3288 | 3288 | | |
3289 | 3289 | | |
3290 | 3290 | | |
3291 | | - | |
3292 | 3291 | | |
3293 | 3292 | | |
3294 | 3293 | | |
| |||
4467 | 4466 | | |
4468 | 4467 | | |
4469 | 4468 | | |
4470 | | - | |
4471 | | - | |
4472 | | - | |
4473 | | - | |
4474 | 4469 | | |
4475 | 4470 | | |
4476 | 4471 | | |
| |||
4573 | 4568 | | |
4574 | 4569 | | |
4575 | 4570 | | |
4576 | | - | |
4577 | | - | |
4578 | | - | |
4579 | | - | |
4580 | 4571 | | |
4581 | 4572 | | |
4582 | 4573 | | |
| |||
0 commit comments