You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/03/28 05:25:21 UTC
[GitHub] [flink-table-store] LadyForest commented on a change in pull request #64: [FLINK-26877] Introduce auto type inference for filter push down
LadyForest commented on a change in pull request #64:
URL: https://github.com/apache/flink-table-store/pull/64#discussion_r836062965
##########
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:
> Let catch Exception ignore?
I don't think we want to throw an exception here no matter what the situation is.
the reason catching exception here is to let `PredicateTest#testUnsupportedExpression` pass. If not caught here, once the casting fails, it'll directly throw `UnsupportedOperationException`, other than `PredicateConverter.UnsupportedExpression`. I think it depends on whether we want an unified exception thrown by `PredicateConverter`
--
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: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org