chovy-3012 commented on issue #13378:
URL: https://github.com/apache/seatunnel/issues/13378#issuecomment-7079816342

   Thanks @DanielLeens — all three revisions are accepted, and I've already run 
the feasibility check you asked for. Results below.
   
   **1. Deterministic charset validation**
   
   Agreed: reusing `EncodingUtils.tryParseCharset()` unchanged would make the 
six-name contract platform-dependent and silently turn a blank name into a 
successful UTF-8 call. v1 will validate against an explicit allowlist of 
exactly the six documented names, case-insensitive; no aliases are documented 
in v1, so the accepted set is exactly those six. Blank or unsupported names 
produce a clear error, and null propagation applies only to an actual SQL NULL 
argument, checked before that validation. The existing 
`String.getBytes(charset)` / `new String(bytes, charset)` conversion path is 
still reused for the byte-level work — only the charset gate is new.
   
   **2. Feasibility result for the Calcite binary path**
   
   Verified feasible through the real SPI path, with no framework changes 
needed. I registered two probe UDFs through the `CalciteUdf` ServiceLoader, 
declaring the proposed signatures (`eval(String, String) -> byte[]` and 
`eval(byte[], String) -> String`), and drove `CalciteSQLEngine` end-to-end; 4/4 
probe tests pass:
   
   - `ENCODE(name, 'UTF-16BE')` returns the exact expected bytes, and the 
output column is derived as the binary (`BYTES`) type, not a string;
   - `DECODE` consumes a binary input column via `eval(byte[], String)` and 
returns the exact original string;
   - a nested round trip `DECODE(ENCODE(name, 'ISO-8859-1'), 'ISO-8859-1')` 
passes, so a `byte[]` result can feed a `byte[]` parameter directly;
   - NULL propagation holds in both directions — the bridge registers UDFs with 
a strict null policy, so a NULL argument short-circuits to NULL before the 
function is invoked.
   
   Two facts that make this low-risk: the `byte[]`/`ByteString` bridge is 
existing production code — the shipped `VECTOR_NORMALIZE` and `VECTOR_REDUCE` 
UDFs already declare `byte[]` parameters and `byte[]` return values through it 
— and the probe run above exercised the binary column typing (`BYTES` ↔ 
`VARBINARY`) on both the input and output sides.
   
   With this, the Zeta-only fallback is withdrawn: the PR will register both 
functions on both engines with the same argument validation and result 
semantics.
   
   **3. Test plan**
   
   The matrix gets the engine-parity assertions you listed — direct binary 
values, the exact six-name allowlist, blank/unsupported names, null 
propagation, wrong types/counts, and the documented replacement behavior for 
malformed byte sequences — asserted identically on Zeta and Calcite. Base64 and 
Oracle-style conditional `DECODE` stay independent as proposed.
   
   I'll open the implementation PR against this contract.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to