twalthr commented on code in PR #1:
URL:
https://github.com/apache/flink-connector-mongodb/pull/1#discussion_r1052181728
##########
flink-connector-mongodb/src/main/java/org/apache/flink/connector/mongodb/table/MongoDynamicTableFactory.java:
##########
@@ -151,16 +146,11 @@ public DynamicTableSink createDynamicTableSink(Context
context) {
MongoConfiguration config = new
MongoConfiguration(helper.getOptions());
helper.validate();
- ResolvedSchema schema = context.getCatalogTable().getResolvedSchema();
- SerializableFunction<RowData, BsonValue> keyExtractor =
- MongoKeyExtractor.createKeyExtractor(schema);
-
return new MongoDynamicTableSink(
getConnectionOptions(config),
getWriteOptions(config),
config.getSinkParallelism(),
- context.getPhysicalRowDataType(),
- keyExtractor);
+ context.getCatalogTable().getResolvedSchema());
Review Comment:
Personally, I would keep out the catalog's schema from the sink. The sink
has no schema but a data type. Let's use a boolean flag in the constructor
`isUpsert`.
##########
flink-connector-mongodb/src/test/java/org/apache/flink/connector/mongodb/table/converter/MongoConvertersTest.java:
##########
@@ -146,28 +146,31 @@ public void testConvertBsonToRowData() {
GenericRowData.of(
StringData.fromString(oid.toHexString()),
StringData.fromString("string"),
- StringData.fromString(uuid.toString()),
+ StringData.fromString(
+ "{\"_value\": {\"$binary\": {\"base64\":
\"gR+qXamERr+L0IyxvO9daQ==\", \"subType\": \"04\"}}}"),
2,
3L,
4.1d,
DecimalData.fromBigDecimal(new BigDecimal("5.1"), 10,
2),
false,
TimestampData.fromEpochMillis(now.getEpochSecond() *
1000),
+ TimestampData.fromEpochMillis(now.toEpochMilli()),
StringData.fromString(
- OffsetDateTime.ofInstant(
-
Instant.ofEpochMilli(now.toEpochMilli()),
- ZoneOffset.UTC)
- .format(ISO_OFFSET_DATE_TIME)),
- StringData.fromString("/^9$/i"),
- StringData.fromString("function() { return 10; }"),
- StringData.fromString("function() { return 11; }"),
- StringData.fromString("12"),
- StringData.fromString(oid.toHexString()),
+ "{\"_value\": {\"$regularExpression\":
{\"pattern\": \"^9$\", \"options\": \"i\"}}}"),
Review Comment:
The question whether we need to customize a JsonWriter depends on the
round-trip story. Is it possible to read a RegExp as string and write it out as
a string again that MongoDB could correctly classify as RegExp again?
--
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]