dssysolyatin commented on code in PR #4001:
URL: https://github.com/apache/calcite/pull/4001#discussion_r1801784439


##########
mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoEnumerator.java:
##########
@@ -119,8 +127,34 @@ static Function1<Document, Object> getter(
             : (Function1) listGetter(fields);
   }
 
+  /**
+   * Converts the given object to a specific runtime type based on the 
provided class.
+   *
+   * @param fieldName The name of the field being processed, used for error 
reporting if
+   *                  conversion fails.
+   * @param o The object to be converted. If `null`, the method returns `null` 
immediately.
+   * @param clazz The target class to which the object `o` should be converted.
+   * @return The converted object as an instance of the specified `clazz`, or 
`null` if `o` is
+   * `null`.
+   *
+   * @throws IllegalArgumentException if the object `o` cannot be converted to 
the desired
+   * `clazz` type, including a message indicating the field name, expected 
data type, and the
+   * invalid value.
+   *
+   * <h3>Conversion Details</h3>:
+   *
+   * <p>If the target type is one of the following, the method performs 
specific conversions:
+   * <ul>
+   *   <li>`Long`: Converts a `Date` or `BsonTimestamp` object into the 
respective epoch time
+   *   (milliseconds).
+   *   <li>`BigDecimal`: Converts a `Decimal128` object into a `BigDecimal` 
instance.
+   *   <li>`String`: Converts arrays to string and uses `String.valueOf(o)` 
for other objects.
+   *   <li>`ByteString`: Converts a `Binary` object into a `ByteString` 
instance.

Review Comment:
   @mihaibudiu 
   This code is not related to RexLiteral; it is related to plan execution. 
When Calcite receives objects from the MongoDB client, it should convert them 
to calcite runtime object.
   
   I also added a section to the documentation about converting primitive types 
and boxed primitives.



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