Akash3121 opened a new issue, #9984:
URL: https://github.com/apache/paimon/issues/9984

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   
   ### Paimon version
   
   master (1d368b4a5932f8221fd28e2555001abdb8fb12ee)
   
   ### Compute Engine
   
   Engine-independent paimon-format JSON writer. Reproducible through the Java 
API or any engine capable of passing a map with a null key.
   
   ### Minimal reproduce step
   
   Create a JSON-format table containing a  MAP<STRING, INT>  field and write a 
map containing  {null: 1}  with each of these configurations:
   
   ```java
    json.map-null-key-mode=FAIL
    json.map-null-key-mode=DROP
    json.map-null-key-mode=LITERAL
    json.map-null-key-literal=null-key
   ```
   
   The writer constructor currently retains only the line delimiter:
   ```java
    this.lineDelimiter = options.getLineDelimiter();
   
    JsonFormatWriter#convertRowMap  always executes:
   
    result.put(convertToString(key, keyType), convertedValue);
   ```
   For a null key,  convertToString  returns null. Jackson then fails because 
JSON object keys cannot be null.
   
   Relevant code:
    -  paimon-format/.../JsonOptions.java : defines the options
    -  paimon-format/.../JsonFormatWriter.java : does not read them
    -  paimon-format/.../JsonFileFormatTest.java : the tests named for the 
modes use only non-null keys
   
   ### What doesn't meet your expectations?
   
    The documented modes should behave as follows:
    
    - FAIL: reject the null key with a clear Paimon validation error.
    - DROP: omit the null-key entry.
    - LITERAL: serialize the configured json.map-null-key-literal as the object 
key.
    
    Currently DROP and LITERAL fail through the same unconditional Jackson 
path, and FAIL does not provide the documented mode-specific behavior.
   
   ### Anything else?
   
   The JSON writer should retain both null-key options and handle a null key 
before inserting it into the output map.
    
    Suggested tests:
    
    1. Raw serialized output for FAIL, DROP, and LITERAL
    2. Write/read tests for all three modes
    3. Custom literal values
    4. Nested map values
    5. Multiple null-key entries
    6. Collision between a literal replacement and a real key
    7. A descriptive exception for FAIL
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
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