Closed piyush2206 closed 5 years ago
I am also facing the same issue, I tried using SMT functions but it didn't help out. @hpgrahsl Can you please help me here?
Thx @piyush2206 and @NikhilManapure for reporting this. In the current version of my sink connector it is not supported to use "." as a field name for several reasons. Very briefly this is why:
1) JSON allows several field name characters which are either only partially supported or not valid to be used in MongoDB documents at all. By that I mean that while it would be possible to convince the db to store field names containing "." anyway, it is IMHO not recommended to do so... at least not at the moment since you cannot query such fields properly in order to read your data back. probably the best source to read about this which is also reflecting my personal opinion why there is no support for this can be found in related tickets at the official project:
2) Kafka Connect and hence my sink connector support also AVRO encoded records besides JSON. and the AVRO spec is much more restrictive with regard to field names - so it didn't make too much sense for me to support things for one encoding which isn't possible within another. read the relevant section in the AVRO spec in case you want to dig deeper here https://avro.apache.org/docs/1.8.1/spec.html#names
3) other than the mere writing of documents with "." characters in field names, there are a lot of configuration properties for my sink connector which are using "." as special character e.g. in order to navigate the nesting of the document structure itself - this would clash and become unusable with field names containing "." at the moment. while this might change in future releases it most likely won't before an officially supported solution has been found for the mongodb server and the drivers respectively.
I hope this clarifies the considerations that went into the current "design" in the first place. Given this the best way to go IMHO is to solve this "upstream" e.g. during a stream processing step or trying to use SMT and replace all "." dots in your field names (recursively) so that your documents are "clean" before they are handed to the sink connector.
Happy to hear your thoughts!
Hello, Not able to insert records whose field contains '.' (dot) in it.
java.lang.IllegalArgumentException: Invalid BSON field name kubernetes.io/config.source
Since MongoDB 3.6, support for key names with dot and dollar sign is allowed. https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names
Also tried to work around this by using "post processor - mongodb.field.renamer.regexp" but the post processor (as the name says) does this processing after converting the record to BSON so it breaks before the post-processor itself.
Connector config -
Full stack trace -