You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a follow-up to PR duckdb#630.
It makes the following changes to newly added Scalar Functions Java
API:
- moves exception and registered shell classes into the
`DuckDBFunction.java`
- removes abstract classes for vector reader and writer
- renames `DuckDBScalarContext` into `DuckDBScalarFunctionCallData`
- removes `DuckDBScalarRow` in favour of streaming plain indices of the
input vector rows (as a `LongStream`); the row object inteface
appeared to have an unintended overhead of creating a Java object
for every input row that we would like to avoid.
-`Function` and `BiFunction` callbacks receive `null` for NULL inputs; implement null handling in Java callback logic.
52
+
- When `.withSpecialHandling()` is set (results in `duckdb_scalar_function_set_special_handling()` C API call),
53
+
then `Function` and `BiFunction` callbacks receive `null` for NULL inputs; null handling needs to be implemented in Java callback logic.
59
54
-`withIntFunction(...)`, `withLongFunction(...)`, and `withDoubleFunction(...)` run with null propagation enabled.
60
-
- For `withVectorizedFunction(...)`, use `ctx.propagateNulls(true)` when you want stream-level null skipping and automatic NULL output.
55
+
- For `withVectorizedFunction(...)`, use `data.propagateNulls(true)` when you want stream-level null skipping and automatic NULL output when **any** of input arguments is NULL.
61
56
- For `Supplier`, returning `null` writes NULL output.
62
57
-`Function` and `BiFunction` are fixed arity only (no varargs).
63
58
64
59
Runtime error model:
65
60
66
-
- Callback-time reader/writer/context type and value failures throw `DuckDBFunctionException`.
61
+
- Callback-time reader/writer/context type and value failures throw `DuckDBFunctions.CallException`.
-`SQLException` remains for registration-time API usage and type declaration/validation.
69
64
@@ -145,7 +140,11 @@ Notes:
145
140
146
141
## Registered Function Metadata And Registry
147
142
148
-
`DuckDBRegisteredFunction` exposes immutable metadata about the successful registration result:
143
+
Registered functions, returned from `.register()` call, are additionally tracked in a Java-side registry exposed by `DuckDBDriver.registeredFunctions()`.
144
+
This registry provides bookkeeping for functions registered through the JDBC API, not an authoritative view of the DuckDB catalog.
145
+
`DuckDBDriver.clearFunctionsRegistry()` clears only the Java-side registry and does not de-register functions from DuckDB.
146
+
147
+
`DuckDBFunctions.RegisteredFunction` exposes immutable metadata about the successful registration result:
-`DuckDBScalarContext`, `DuckDBScalarRow`, `DuckDBReadableVector`, and `DuckDBWritableVector` are valid only during callback execution.
200
-
-`DuckDBReadableVector` and `DuckDBWritableVector` are abstract callback runtime types (not interfaces).
201
-
- Write exactly one output value per input row for each callback invocation.
202
-
- With `propagateNulls(true)`, `DuckDBScalarContext.stream()` skips rows that contain NULL in any input column and writes NULL to the output for those rows.
203
+
-`DuckDBScalarFunctionCallData`, `DuckDBReadableVector`, and `DuckDBWritableVector` are valid only during callback execution.
204
+
- Write exactly one output value per input row for each callback invocation *on the same `rowIndex`*.
205
+
- With `propagateNulls(true)`, `DuckDBScalarFunctionCallData.stream()` skips rows that contain NULL in **any** input column and writes NULL to the output for those rows.
0 commit comments