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());
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations