odbozhou commented on issue #385:
URL: 
https://github.com/apache/rocketmq-connect/issues/385#issuecomment-1354403153

   > hi,我大概整理出了一个设计流程图,想和您讨论一下: ![Schema Inferencing for 
JsonConverter](https://user-images.githubusercontent.com/52153761/206893015-dc5e386d-a649-4175-89be-52af21250928.png)
   > 
   > 由于单纯的json数据中所携带的信息量比较少,只能通过人为制定规则来进行填充schema;我制定了一些规则:
   > 
   > 1. 对于schema里的optional字段,直接置为false
   > 2. 对于schema的name字段,默认置为“default”或者null
   > 3. 
当原json中有多个数据的时候,schema的type置为“struct”;当json中只有一个数据时,schema的type使用json数据的type
   > 4. 对于schema中的name、version等字段,不好进行推断,不知道您是否有一些建议
   > 5. 对于某个数据字段的type,我只能通过JSONObject.value的所属类来判断,例如{"id": 10000}中的value 
instanceof 
Integer,因此认为schema.type=int32。这样做的弊端在于比较粗略,不能保证推断出来的type是完全正确的,同时对于一些特殊的字段类型如struct、map、date等处理起来可能会比较麻烦
   
   很详细。由于我对这个问题理解的一些偏差,可能前面描述有一些误差。schemaEnabled 
true或者false,只要schema缺失都可以对json数据进行类型推断。
   
   另外我仔细看了下这块代码,之前社区同学已经把这块逻辑实现了。
   可以看一下  
org.apache.rocketmq.connect.runtime.converter.record.json.JsonConverter#convertToConnect
   可以在看看还有哪块特性感兴趣


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