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

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   
   ### Paimon version
   
   1.14
   
   ### Compute Engine
   
   flink 1.18
   
   ### Minimal reproduce step
   
   ```java
   @Test
       public void testMetaSelectorWithEmptyStringKey() {
           // Simulate the real NPE scenario: btree index file with empty 
string as firstKey
           KeySerializer stringSerializer = KeySerializer.create(new 
VarCharType());
           byte[] emptyKey = 
stringSerializer.serialize(BinaryString.EMPTY_UTF8);
           byte[] normalKey = 
stringSerializer.serialize(BinaryString.fromString("www.example.com"));
   
           BTreeIndexMeta metaWithEmptyFirstKey = new BTreeIndexMeta(emptyKey, 
normalKey, false);
           BTreeIndexMeta metaWithNormalKeys =
                   new BTreeIndexMeta(
                           
stringSerializer.serialize(BinaryString.fromString("aaa.com")),
                           
stringSerializer.serialize(BinaryString.fromString("zzz.com")),
                           false);
           BTreeIndexMeta metaOnlyNulls = new BTreeIndexMeta(null, null, true);
   
           List<GlobalIndexIOMeta> files =
                   Arrays.asList(
                           new GlobalIndexIOMeta(
                                   new Path("file_empty"), 1, 
metaWithEmptyFirstKey.serialize()),
                           new GlobalIndexIOMeta(
                                   new Path("file_normal"), 1, 
metaWithNormalKeys.serialize()),
                           new GlobalIndexIOMeta(
                                   new Path("file_nulls"), 1, 
metaOnlyNulls.serialize()));
   
           FieldRef ref = new FieldRef(1, "page_host", new VarCharType());
           BTreeFileMetaSelector selector = new BTreeFileMetaSelector(files, 
stringSerializer);
   
           // visitEqual should not throw NPE
           Optional<List<GlobalIndexIOMeta>> result =
                   selector.visitEqual(ref, 
BinaryString.fromString("www.example.com"));
           Assertions.assertThat(result).isNotEmpty();
           assertFiles(result.get(), Arrays.asList("file_empty", 
"file_normal"));
   
           // visitLessThan should not throw NPE
           result = selector.visitLessThan(ref, 
BinaryString.fromString("bbb.com"));
           Assertions.assertThat(result).isNotEmpty();
           assertFiles(result.get(), Arrays.asList("file_empty", 
"file_normal"));
   
           // visitGreaterThan should not throw NPE
           result = selector.visitGreaterThan(ref, 
BinaryString.fromString("www.example.com"));
           Assertions.assertThat(result).isNotEmpty();
   
           // visitIn should not throw NPE
           result =
                   selector.visitIn(
                           ref,
                           Arrays.asList(
                                   BinaryString.fromString("www.example.com"),
                                   BinaryString.fromString("zzz.com")));
           Assertions.assertThat(result).isNotEmpty();
   
           // visitBetween should not throw NPE
           result =
                   selector.visitBetween(
                           ref, BinaryString.EMPTY_UTF8, 
BinaryString.fromString("zzz.com"));
           Assertions.assertThat(result).isNotEmpty();
       }
   ```
   
   ### What doesn't meet your expectations?
   
   When querying a table with a btree global index on a STRING/VARCHAR column, 
a NullPointerException is thrown: 
   <img width="2674" height="1932" alt="Image" 
src="https://github.com/user-attachments/assets/a0c76990-dd78-4dda-a413-653f7c4288ee";
 />
   
   ### Anything else?
   
   _No response_
   
   ### 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