Search in sources :

Example 61 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class MetadataManager method renameTable.

@Override
public void renameTable(Session session, TableHandle tableHandle, QualifiedObjectName newTableName) {
    String catalogName = newTableName.getCatalogName();
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
    ConnectorId connectorId = catalogMetadata.getConnectorId();
    if (!tableHandle.getConnectorId().equals(connectorId)) {
        throw new PrestoException(SYNTAX_ERROR, "Cannot rename tables across catalogs");
    }
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    metadata.renameTable(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), newTableName.asSchemaTableName());
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Example 62 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method input.

public static void input(MethodHandle methodHandle, NullableDoubleState state, double value) {
    if (state.isNull()) {
        state.setNull(false);
        state.setDouble(value);
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(value, state.getDouble())) {
            state.setDouble(value);
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 63 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method combine.

public static void combine(MethodHandle methodHandle, NullableLongState state, NullableLongState otherState) {
    if (state.isNull()) {
        state.setNull(false);
        state.setLong(otherState.getLong());
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(otherState.getLong(), state.getLong())) {
            state.setLong(otherState.getLong());
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 64 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method input.

public static void input(MethodHandle methodHandle, NullableLongState state, long value) {
    if (state.isNull()) {
        state.setNull(false);
        state.setLong(value);
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(value, state.getLong())) {
            state.setLong(value);
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 65 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class SessionPropertyManager method decodeCatalogPropertyValue.

public <T> T decodeCatalogPropertyValue(ConnectorId connectorId, String catalogName, String propertyName, @Nullable String propertyValue, Class<T> type) {
    String fullPropertyName = catalogName + "." + propertyName;
    PropertyMetadata<?> property = getConnectorSessionPropertyMetadata(connectorId, propertyName).orElseThrow(() -> new PrestoException(INVALID_SESSION_PROPERTY, "Unknown session property " + fullPropertyName));
    return decodePropertyValue(fullPropertyName, propertyValue, type, property);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Aggregations

PrestoException (com.facebook.presto.spi.PrestoException)273 IOException (java.io.IOException)58 Type (com.facebook.presto.spi.type.Type)48 ImmutableList (com.google.common.collect.ImmutableList)40 SchemaTableName (com.facebook.presto.spi.SchemaTableName)32 ArrayList (java.util.ArrayList)32 List (java.util.List)28 Path (org.apache.hadoop.fs.Path)28 Map (java.util.Map)24 Slice (io.airlift.slice.Slice)23 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)22 SqlType (com.facebook.presto.spi.function.SqlType)22 ImmutableMap (com.google.common.collect.ImmutableMap)22 Optional (java.util.Optional)20 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)19 Block (com.facebook.presto.spi.block.Block)19 Test (org.testng.annotations.Test)19 ConnectorSession (com.facebook.presto.spi.ConnectorSession)17 Table (com.facebook.presto.hive.metastore.Table)15 Session (com.facebook.presto.Session)14