Search in sources :

Example 1 with RowExpressionTreeTranslator

use of com.facebook.presto.expressions.translator.RowExpressionTreeTranslator in project presto by prestodb.

the class JdbcFilterToSqlTranslator method translateCall.

@Override
public TranslatedExpression<JdbcExpression> translateCall(CallExpression call, Map<VariableReferenceExpression, ColumnHandle> context, RowExpressionTreeTranslator<JdbcExpression, Map<VariableReferenceExpression, ColumnHandle>> rowExpressionTreeTranslator) {
    List<TranslatedExpression<JdbcExpression>> translatedExpressions = call.getArguments().stream().map(expression -> rowExpressionTreeTranslator.rewrite(expression, context)).collect(toImmutableList());
    FunctionMetadata functionMetadata = functionMetadataManager.getFunctionMetadata(call.getFunctionHandle());
    try {
        return functionTranslator.translate(functionMetadata, call, translatedExpressions);
    } catch (Throwable t) {
    // no-op
    }
    return untranslated(call, translatedExpressions);
}
Also used : TranslatedExpression.untranslated(com.facebook.presto.expressions.translator.TranslatedExpression.untranslated) BooleanType(com.facebook.presto.common.type.BooleanType) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) ConstantExpression(com.facebook.presto.spi.relation.ConstantExpression) TranslatedExpression(com.facebook.presto.expressions.translator.TranslatedExpression) IntegerType(com.facebook.presto.common.type.IntegerType) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) TimeWithTimeZoneType(com.facebook.presto.common.type.TimeWithTimeZoneType) CharType(com.facebook.presto.common.type.CharType) CallExpression(com.facebook.presto.spi.relation.CallExpression) RowExpressionTreeTranslator(com.facebook.presto.expressions.translator.RowExpressionTreeTranslator) FunctionMetadataManager(com.facebook.presto.spi.function.FunctionMetadataManager) Type(com.facebook.presto.common.type.Type) SpecialFormExpression(com.facebook.presto.spi.relation.SpecialFormExpression) RowExpressionTranslator(com.facebook.presto.expressions.translator.RowExpressionTranslator) TinyintType(com.facebook.presto.common.type.TinyintType) BigintType(com.facebook.presto.common.type.BigintType) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) LambdaDefinitionExpression(com.facebook.presto.spi.relation.LambdaDefinitionExpression) VarcharType(com.facebook.presto.common.type.VarcharType) RealType(com.facebook.presto.common.type.RealType) String.format(java.lang.String.format) TimeType(com.facebook.presto.common.type.TimeType) TimestampWithTimeZoneType(com.facebook.presto.common.type.TimestampWithTimeZoneType) FunctionMetadata(com.facebook.presto.spi.function.FunctionMetadata) SmallintType(com.facebook.presto.common.type.SmallintType) List(java.util.List) ColumnHandle(com.facebook.presto.spi.ColumnHandle) Optional(java.util.Optional) DateType(com.facebook.presto.common.type.DateType) FunctionTranslator(com.facebook.presto.expressions.translator.FunctionTranslator) DoubleType(com.facebook.presto.common.type.DoubleType) TimestampType(com.facebook.presto.common.type.TimestampType) JdbcColumnHandle(com.facebook.presto.plugin.jdbc.JdbcColumnHandle) Joiner(com.google.common.base.Joiner) FunctionMetadata(com.facebook.presto.spi.function.FunctionMetadata) TranslatedExpression(com.facebook.presto.expressions.translator.TranslatedExpression)

Aggregations

BigintType (com.facebook.presto.common.type.BigintType)1 BooleanType (com.facebook.presto.common.type.BooleanType)1 CharType (com.facebook.presto.common.type.CharType)1 DateType (com.facebook.presto.common.type.DateType)1 DoubleType (com.facebook.presto.common.type.DoubleType)1 IntegerType (com.facebook.presto.common.type.IntegerType)1 RealType (com.facebook.presto.common.type.RealType)1 SmallintType (com.facebook.presto.common.type.SmallintType)1 TimeType (com.facebook.presto.common.type.TimeType)1 TimeWithTimeZoneType (com.facebook.presto.common.type.TimeWithTimeZoneType)1 TimestampType (com.facebook.presto.common.type.TimestampType)1 TimestampWithTimeZoneType (com.facebook.presto.common.type.TimestampWithTimeZoneType)1 TinyintType (com.facebook.presto.common.type.TinyintType)1 Type (com.facebook.presto.common.type.Type)1 VarcharType (com.facebook.presto.common.type.VarcharType)1 FunctionTranslator (com.facebook.presto.expressions.translator.FunctionTranslator)1 RowExpressionTranslator (com.facebook.presto.expressions.translator.RowExpressionTranslator)1 RowExpressionTreeTranslator (com.facebook.presto.expressions.translator.RowExpressionTreeTranslator)1 TranslatedExpression (com.facebook.presto.expressions.translator.TranslatedExpression)1 TranslatedExpression.untranslated (com.facebook.presto.expressions.translator.TranslatedExpression.untranslated)1