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
- removes `DuckDBScalarContext` and `DuckDBScalarRow` in favour of
streaming plain indices (as a `LongStream`) from the input data
chunk; 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. And without it the context abstraction appeared to be
unnecessary
Null-propagation handling is changed the following way:
- null propagation on Java side is enabled only for primitive callbacks
(set automatically) and not exposed to the user, null propagation
support for object callbacks is removed
- null propagation on DuckDB engine side (
`duckdb_scalar_function_set_special_handling` C API call skip) is also
enabled automatically only for primitive callbacks, but it is
additionally exposed to users as `withNullInNullOut()` builder call
(replaces awkwardly named `withSpecialHandling()`); in some cases NULLs
still can be passed to callbacks wheh `withNullInNullOut()` is
set so callback still must check for nulls
Testing: more tests added aroung the null handling
-`SQLException`remains for registration-time API usage and type declaration/validation.
66
+
-`SQLException`is used for registration-time API usage and type declaration/validation.
69
67
70
68
## Type declaration and mapping
71
69
72
70
`withParameter(...)` and `withReturnType(...)` accept:
73
71
74
-
-`Class<?>`
72
+
-`Class<?>` (Object or primitive class, like `int.class` or `Integer.TYPE`)
75
73
-`DuckDBColumnType`
76
74
-`DuckDBLogicalType`
77
75
78
76
Common class mappings include:
79
77
80
-
-`Integer` -> `INTEGER`
81
-
-`Long` -> `BIGINT`
78
+
-`int` -> `INTEGER`
79
+
-`long` -> `BIGINT`
80
+
-`float` -> `FLOAT`
81
+
-`double` -> `DOUBLE`
82
82
-`String` -> `VARCHAR`
83
83
-`BigDecimal` -> `DECIMAL`
84
84
-`BigInteger` -> `HUGEINT`
@@ -140,12 +140,16 @@ Notes:
140
140
-`withVarArgsFunction(Function<Object[], ?>)`
141
141
-`withVectorizedFunction(DuckDBScalarFunction)`
142
142
-`withVolatile()`
143
-
-`withSpecialHandling()`
143
+
-`withNullInNullOut()`
144
144
-`register(java.sql.Connection)`
145
145
146
146
## Registered Function Metadata And Registry
147
147
148
-
`DuckDBRegisteredFunction` exposes immutable metadata about the successful registration result:
148
+
Registered functions, returned from `.register()` call, are additionally tracked in a Java-side registry exposed by `DuckDBDriver.registeredFunctions()`.
149
+
This registry provides bookkeeping for functions registered through the JDBC API, not an authoritative view of the DuckDB catalog.
150
+
`DuckDBDriver.clearFunctionsRegistry()` clears only the Java-side registry and does not de-register functions from DuckDB.
151
+
152
+
`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.
0 commit comments