Commit 30341af
refactor(sources): share the UDTF string-argument extractor (#169)
* refactor(sources): share the UDTF string-argument extractor
Nine per-provider Expr-to-string extractors (lance knn/fts, sqlite,
seekdb, pg fts/knn, mongo, open_connector) had drifted in both error
wording ("sqlite: 'x'", "lance_knn: x", "mongo_fts: 'x' ... got {:?}")
and NULL handling — some accepted NULL as the pipeline schema-inference
placeholder, others rejected it, with the difference nowhere stated.
One shared module (providers/udtf_args.rs) now carries the three
deliberate semantics, named at each call site:
- string_arg: NULL is the pipeline {param} placeholder, yields "" (the
prior behavior of lance_fts / sqlite / seekdb / pg_fts / mongo);
- optional_string_arg: NULL means "argument not provided" (lance_fts's
or-null variant);
- strict_string_arg: NULL rejected, for arguments that determine the
planned schema where a placeholder cannot produce a plan (lance_knn,
pg_knn, and the open_connector UDTFs keep their prior strictness).
Error wording is uniform ("{fn}: '{arg}' must be a string literal");
each provider keeps its exact prior NULL semantics, so this changes no
behavior beyond message text. Addresses the non-blocking cleanup note
from the #165 review. The ColumnarValue-based extractors in model/
(scalar-UDF context, different signature) are out of scope.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* refactor(sources): share the UDTF JSON-object argument parser
open_connector_query's resource_json and open_connector_scan's
input_json duplicated the serde_json::from_str + is_object() validation
with already-diverging messages ("of resource inputs" vs "of action
inputs"). One parse_json_object(fn_name, arg, raw) helper keeps the two
diagnostics in lockstep; tests pin the non-object rejection for both
functions. Addresses the second non-blocking cleanup note from the
#165 review.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(sources): drop the doc comment orphaned by the extract_string removal
Deleting sqlite's extract_string left its two doc-comment lines
attached to the unrelated quote_sqlite_table below it. The other
providers' section headers were checked and still head real content.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(sources): keep the per-argument context in the shared JSON-object error
Sharing parse_json_object flattened "of resource inputs" / "of action
inputs" into a generic "of input fields". Thread the caller's noun
through so the shared implementation and the specific diagnostic
coexist; the non-object tests now pin each function's full wording.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(sources): stop pg_knn swallowing malformed inline filters
The 6th argument was extracted with `.ok()` (pre-existing on main), so
any non-string filter was silently dropped and the query returned
unfiltered rows. Use optional_string_arg: NULL still means "no filter"
(the pipeline placeholder), everything else that isn't a string literal
now fails planning with the targeted message — matching lance_knn,
which always propagated. Tests pin both paths without needing a live
Postgres.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* style(sources): use the plan_err macro pair throughout parse_json_object
The parse-failure branch built DataFusionError::Plan(format!(...)) by
hand while the non-object branch used plan_err! — two construction
styles in one helper. Use DataFusion's pair as intended:
plan_datafusion_err! (constructs the error, for map_err) alongside
plan_err! (returns it). Note the review's literal suggestion,
.map_err(|e| plan_err!(...))??, does not compile — plan_err! expands to
a full Err(...) Result, which is why the *_datafusion_err! twin exists.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* test(sources): pin the optional happy path and typed-null boundaries
Per review: null_semantics_differ_by_variant now asserts
optional_string_arg returns Some for a real string, and a new test
locks Utf8(None)/LargeUtf8(None) — typed NULLs, e.g. from
CAST(NULL AS VARCHAR) — as rejections across all three variants: they
must be neither a valid empty string nor the untyped-Null placeholder,
matching every provider's pre-refactor behavior.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* test(sources): cover NULL arguments to open_connector_query at planning
Per review: the argument-rejection test covered non-string literals but
not SQL NULL. Add NULL for gateway, table_id, and resource_json,
asserting the strict_string_arg "must be a string literal, not NULL"
diagnostic — still inside the same test, whose trailing assertion
proves every rejection fires before any HTTP execute.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 4ea7d9f commit 30341af
14 files changed
Lines changed: 299 additions & 165 deletions
File tree
- crates/skardi/src/sources/providers
- lance
- mongo
- open_connector
- seekdb
- sqlite
- sqlx/pg
Lines changed: 4 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
309 | 310 | | |
310 | 311 | | |
311 | 312 | | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | 313 | | |
331 | 314 | | |
332 | 315 | | |
| |||
Lines changed: 4 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
58 | | - | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | | - | |
| 62 | + | |
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| |||
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | 234 | | |
242 | 235 | | |
243 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
Lines changed: 3 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
69 | | - | |
| 69 | + | |
| 70 | + | |
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| |||
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | 240 | | |
255 | 241 | | |
256 | 242 | | |
| |||
Lines changed: 70 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | | - | |
147 | | - | |
148 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
149 | 150 | | |
150 | 151 | | |
151 | | - | |
| 152 | + | |
152 | 153 | | |
153 | 154 | | |
154 | 155 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
179 | 175 | | |
180 | 176 | | |
181 | 177 | | |
| |||
242 | 238 | | |
243 | 239 | | |
244 | 240 | | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
249 | 245 | | |
250 | 246 | | |
251 | | - | |
| 247 | + | |
252 | 248 | | |
253 | 249 | | |
254 | 250 | | |
| |||
279 | 275 | | |
280 | 276 | | |
281 | 277 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
293 | 284 | | |
294 | 285 | | |
295 | 286 | | |
| |||
423 | 414 | | |
424 | 415 | | |
425 | 416 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
432 | 429 | | |
| 430 | + | |
433 | 431 | | |
434 | 432 | | |
435 | 433 | | |
| |||
746 | 744 | | |
747 | 745 | | |
748 | 746 | | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
749 | 753 | | |
750 | 754 | | |
751 | 755 | | |
| |||
755 | 759 | | |
756 | 760 | | |
757 | 761 | | |
758 | | - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
759 | 783 | | |
760 | 784 | | |
761 | 785 | | |
| |||
998 | 1022 | | |
999 | 1023 | | |
1000 | 1024 | | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
1001 | 1032 | | |
1002 | 1033 | | |
1003 | 1034 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | | - | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
96 | | - | |
| 96 | + | |
| 97 | + | |
97 | 98 | | |
98 | | - | |
| 99 | + | |
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | | - | |
813 | 796 | | |
814 | 797 | | |
815 | 798 | | |
| |||
0 commit comments