Search in sources :

Example 26 with JdbcColumnHandle

use of io.trino.plugin.jdbc.JdbcColumnHandle in project trino by trinodb.

the class ImplementSqlServerStdev method rewrite.

@Override
public Optional<JdbcExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<String> context) {
    Variable argument = captures.get(ARGUMENT);
    JdbcColumnHandle columnHandle = (JdbcColumnHandle) context.getAssignment(argument.getName());
    verify(columnHandle.getColumnType().equals(DOUBLE));
    verify(aggregateFunction.getOutputType().equals(DOUBLE));
    return Optional.of(new JdbcExpression(format("STDEV(%s)", context.rewriteExpression(argument).orElseThrow()), columnHandle.getJdbcTypeHandle()));
}
Also used : Variable(io.trino.spi.expression.Variable) JdbcColumnHandle(io.trino.plugin.jdbc.JdbcColumnHandle) JdbcExpression(io.trino.plugin.jdbc.JdbcExpression)

Example 27 with JdbcColumnHandle

use of io.trino.plugin.jdbc.JdbcColumnHandle in project trino by trinodb.

the class ImplementSqlServerVariance method rewrite.

@Override
public Optional<JdbcExpression> rewrite(AggregateFunction aggregateFunction, Captures captures, RewriteContext<String> context) {
    Variable argument = captures.get(ARGUMENT);
    JdbcColumnHandle columnHandle = (JdbcColumnHandle) context.getAssignment(argument.getName());
    verify(columnHandle.getColumnType().equals(DOUBLE));
    verify(aggregateFunction.getOutputType().equals(DOUBLE));
    return Optional.of(new JdbcExpression(format("VAR(%s)", context.rewriteExpression(argument).orElseThrow()), columnHandle.getJdbcTypeHandle()));
}
Also used : Variable(io.trino.spi.expression.Variable) JdbcColumnHandle(io.trino.plugin.jdbc.JdbcColumnHandle) JdbcExpression(io.trino.plugin.jdbc.JdbcExpression)

Aggregations

JdbcColumnHandle (io.trino.plugin.jdbc.JdbcColumnHandle)27 JdbcExpression (io.trino.plugin.jdbc.JdbcExpression)18 Variable (io.trino.spi.expression.Variable)18 JdbcTableHandle (io.trino.plugin.jdbc.JdbcTableHandle)8 TrinoException (io.trino.spi.TrinoException)3 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 ArrayList (java.util.ArrayList)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 Lists (com.google.common.collect.Lists)2 Logger (io.airlift.log.Logger)2 JdbcTypeHandle (io.trino.plugin.jdbc.JdbcTypeHandle)2 HostAddress (io.trino.spi.HostAddress)2 ConnectorSession (io.trino.spi.connector.ConnectorSession)2 ConnectorSplit (io.trino.spi.connector.ConnectorSplit)2 ConnectorSplitManager (io.trino.spi.connector.ConnectorSplitManager)2 ConnectorSplitSource (io.trino.spi.connector.ConnectorSplitSource)2 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)2 ConnectorTransactionHandle (io.trino.spi.connector.ConnectorTransactionHandle)2