LadyForest commented on a change in pull request #64:
URL: https://github.com/apache/flink-table-store/pull/64#discussion_r836068093
##########
File path:
flink-table-store-core/src/main/java/org/apache/flink/table/store/file/predicate/PredicateConverter.java
##########
@@ -131,22 +139,28 @@ private Predicate visitBiFunction(
return Optional.empty();
}
- private Optional<Literal> extractLiteral(Expression expression) {
+ private Optional<Literal> extractLiteral(DataType expectedType, Expression
expression) {
+ Literal literal = null;
if (expression instanceof ValueLiteralExpression) {
ValueLiteralExpression valueExpression = (ValueLiteralExpression)
expression;
- DataType type = valueExpression.getOutputDataType();
- return supportsPredicate(type.getLogicalType())
- ? Optional.of(
- new Literal(
- type.getLogicalType(),
- getConverter(type)
- .toInternalOrNull(
- valueExpression
-
.getValueAs(type.getConversionClass())
- .get())))
- : Optional.empty();
+ LogicalType expectedLogicalType = expectedType.getLogicalType();
+ DataType actualType = valueExpression.getOutputDataType();
+ LogicalType actualLogicalType = actualType.getLogicalType();
+ DataStructureConverter<Object, Object> converter =
getConverter(expectedType);
+ Object value =
valueExpression.getValueAs(actualType.getConversionClass()).get();
+ if (!actualLogicalType.equals(expectedLogicalType)
+ && supportsImplicitCast(actualLogicalType,
expectedLogicalType)) {
+ try {
+ value = TypeUtils.castFromString(value.toString(),
expectedLogicalType);
+ } catch (UnsupportedOperationException e) {
Review comment:
finally got ya
--
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]