vpeddada opened a new issue, #20275: URL: https://github.com/apache/pulsar/issues/20275
### Search before asking - [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar. ### Version Java Client(2.11.0)-->broker(2.11.0) Broker instance OS: Amazon Linux 2023 Java App running OS : Windows 10 ### Minimal reproduce step - Using the RecordSchemaBuilder API I couldn't add any nested elements. - Refer to the following code snippet which has nested records and array elements in the Schema definition. - Using the record schema builder I couldn't find a way to add nested records or arrays. - This applicable for both Avro as well as JSON. Hence request you to provide recommendations on how to achieve such use cases. ``` String avroSchemaDef= "{ "namespace": "my.com.ns", "name": "myrecord", "type": "record", "fields": [{ "name": "uid", "type": "int" }, { "name": "Product", "type": "string" }, { "name": "options", "type": { "type": "array", "items": { "type": "record", "name": "lvl2_record", "fields": [{ "name": "item1_lvl2", "type": "string" }, {"name": "additional", "type": {"type": "map", "values": "string"}}, { "name": "item2_lvl2", "type": { "type": "array", "items": { "type": "record", "name": "lvl3_record", "fields": [{ "name": "item1_lvl3", "type": "string" }, { "name": "item2_lvl3", "type": ["string", "null"] }, { "name": "item_status", "type": { "name": "item_status", "type": "enum", "symbols": ["AVAILABLE", "OUT_OF_STOCK", "ONLY_FEW_LEFT"] }, "default": "AVAILABLE" } ] } } } ] } } } ] }"; JSONObject schemaDefObj = new JSONObject(avroSchemaDef); JSONArray fArray = schemaDefObj.getJSONArray("fields"); RecordSchemaBuilder recordSchemaBuilder = SchemaBuilder.record(schemaName); for(int i=0;i<fieldArray.length();i++) { JSONObject fieldObj = fieldArray.getJSONObject(i); recordSchemaBuilder.field(fieldObj.getString("name")).type(SchemaType.valueOf(fieldObj.getString("type")type.toUpperCase())); // Create the record builder by parsing through a JSON String } SchemaInfo schemaInfo = recordSchemaBuilder.build(SchemaType.valueOf("AVRO")); // Same is applicable for JSON. ``` ### What did you expect to see? I expect to see a way to add nested records or arrays to the RecordSchemaBuilder. ### What did you see instead? I couldn't find Array or Object as a Enum in SchemaType to add to the record schema builder. ### Anything else? I wanted to check before creating a enhancement to check if there is a way to achieve this usecase. Please let us know if there is a way to achieve this else would like you to take this up as an enhancement. ### Are you willing to submit a PR? - [ ] 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]
