tedyu commented on PR #48441:
URL: https://github.com/apache/spark/pull/48441#issuecomment-2411154153
In which directory should I put the following test ?
```
import static org.junit.Assert.*;
import org.apache.spark.unsafe.types.UTF8String;
import org.apache.spark.sql.catalyst.util.GenericArrayData;
import org.junit.Test;
import java.io.IOException;
public class JsonParserTest {
@Test
public void testJsonObjectKeysWithNullAndNonNullKeys() throws
IOException {
// JSON string that has a sequence where the parser will encounter
null, then non-null keys
String jsonString = "{\"key1\":null,
\"key2\":{\"nestedKey1\":\"value1\"}, \"key3\":\"value2\"}";
UTF8String json = UTF8String.fromString(jsonString);
GenericArrayData result = JsonExpressionUtils.jsonObjectKeys(json);
UTF8String[] expectedKeys = {
UTF8String.fromString("key1"),
UTF8String.fromString("key2"),
UTF8String.fromString("key3")
};
assertNotNull("Result should not be null", result);
assertEquals("Length of keys array should be 3", 3,
result.numElements());
assertArrayEquals("Keys should match expected values", expectedKeys,
(UTF8String[]) result.array());
}
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]