Skip to content

Commit

Permalink
Rename PrestoException to TrinoException
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Jan 3, 2021
1 parent e2ae5a9 commit f13283b
Show file tree
Hide file tree
Showing 625 changed files with 2,872 additions and 2,872 deletions.
4 changes: 2 additions & 2 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ otherwise performance sensitive sections.

#### Categorize errors when throwing exceptions.

Categorize errors when throwing exceptions. For example, PrestoException takes
an error code as an argument, `PrestoException(HIVE_TOO_MANY_OPEN_PARTITIONS)`.
Categorize errors when throwing exceptions. For example, `TrinoException` takes
an error code as an argument, `TrinoException(HIVE_TOO_MANY_OPEN_PARTITIONS)`.
This categorization lets you generate reports so you can monitor the frequency
of various failures.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
package io.trino;

import io.airlift.units.Duration;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;

import static io.trino.spi.StandardErrorCode.EXCEEDED_CPU_LIMIT;

public class ExceededCpuLimitException
extends PrestoException
extends TrinoException
{
public ExceededCpuLimitException(Duration duration)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
package io.trino;

import io.airlift.units.DataSize;
import io.trino.spi.PrestoException;
import io.trino.spi.StandardErrorCode;
import io.trino.spi.TrinoException;

import static io.trino.spi.StandardErrorCode.EXCEEDED_GLOBAL_MEMORY_LIMIT;
import static io.trino.spi.StandardErrorCode.EXCEEDED_LOCAL_MEMORY_LIMIT;
import static java.lang.String.format;

public class ExceededMemoryLimitException
extends PrestoException
extends TrinoException
{
public static ExceededMemoryLimitException exceededGlobalUserLimit(DataSize maxMemory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
package io.trino;

import io.airlift.units.DataSize;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;

import static io.trino.spi.StandardErrorCode.EXCEEDED_SCAN_LIMIT;

public class ExceededScanLimitException
extends PrestoException
extends TrinoException
{
public ExceededScanLimitException(DataSize limit)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
package io.trino;

import io.airlift.units.DataSize;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;

import static io.trino.spi.StandardErrorCode.EXCEEDED_SPILL_LIMIT;
import static java.lang.String.format;

public class ExceededSpillLimitException
extends PrestoException
extends TrinoException
{
public static ExceededSpillLimitException exceededLocalLimit(DataSize maxSpill)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.google.common.collect.ImmutableMap;
import io.trino.connector.CatalogName;
import io.trino.metadata.SessionPropertyManager;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.security.ConnectorIdentity;
import io.trino.spi.type.TimeZoneKey;
Expand Down Expand Up @@ -118,7 +118,7 @@ public Optional<String> getTraceToken()
public <T> T getProperty(String propertyName, Class<T> type)
{
if (properties == null) {
throw new PrestoException(INVALID_SESSION_PROPERTY, format("Unknown session property: %s.%s", catalog, propertyName));
throw new TrinoException(INVALID_SESSION_PROPERTY, format("Unknown session property: %s.%s", catalog, propertyName));
}

return sessionPropertyManager.decodeCatalogPropertyValue(catalogName, catalog, propertyName, properties.get(propertyName), type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
*/
package io.trino;

import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.transaction.TransactionId;

import static io.trino.spi.StandardErrorCode.UNKNOWN_TRANSACTION;
import static java.lang.String.format;

public class NotInTransactionException
extends PrestoException
extends TrinoException
{
public NotInTransactionException()
{
Expand Down
6 changes: 3 additions & 3 deletions core/trino-main/src/main/java/io/trino/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.trino.metadata.SessionPropertyManager;
import io.trino.security.AccessControl;
import io.trino.security.SecurityContext;
import io.trino.spi.PrestoException;
import io.trino.spi.QueryId;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.security.Identity;
import io.trino.spi.security.SelectedRole;
Expand Down Expand Up @@ -314,7 +314,7 @@ public Session beginTransactionId(TransactionId transactionId, TransactionManage
continue;
}
CatalogName catalog = transactionManager.getOptionalCatalogMetadata(transactionId, catalogName)
.orElseThrow(() -> new PrestoException(NOT_FOUND, "Session property catalog does not exist: " + catalogName))
.orElseThrow(() -> new TrinoException(NOT_FOUND, "Session property catalog does not exist: " + catalogName))
.getCatalogName();

for (Entry<String, String> property : catalogProperties.entrySet()) {
Expand All @@ -332,7 +332,7 @@ public Session beginTransactionId(TransactionId transactionId, TransactionManage
String catalogName = entry.getKey();
SelectedRole role = entry.getValue();
CatalogName catalog = transactionManager.getOptionalCatalogMetadata(transactionId, catalogName)
.orElseThrow(() -> new PrestoException(NOT_FOUND, "Catalog for role does not exist: " + catalogName))
.orElseThrow(() -> new TrinoException(NOT_FOUND, "Catalog for role does not exist: " + catalogName))
.getCatalogName();
if (role.getType() == SelectedRole.Type.ROLE) {
accessControl.checkCanSetRole(new SecurityContext(transactionId, identity, queryId), role.getRole().get(), catalogName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.trino.execution.TaskManagerConfig;
import io.trino.memory.MemoryManagerConfig;
import io.trino.memory.NodeMemoryConfig;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.session.PropertyMetadata;
import io.trino.sql.analyzer.FeaturesConfig;
import io.trino.sql.analyzer.FeaturesConfig.JoinDistributionType;
Expand Down Expand Up @@ -319,7 +319,7 @@ public SystemSessionProperties(
value -> {
int intValue = (int) value;
if (intValue < 2) {
throw new PrestoException(INVALID_SESSION_PROPERTY, format("%s must be greater than or equal to 2: %s", MAX_REORDERED_JOINS, intValue));
throw new TrinoException(INVALID_SESSION_PROPERTY, format("%s must be greater than or equal to 2: %s", MAX_REORDERED_JOINS, intValue));
}
return intValue;
},
Expand Down Expand Up @@ -887,7 +887,7 @@ private static void validateValueIsPowerOfTwo(Object value, String property)
{
int intValue = (int) value;
if (Integer.bitCount(intValue) != 1) {
throw new PrestoException(
throw new TrinoException(
INVALID_SESSION_PROPERTY,
format("%s must be a power of 2: %s", property, intValue));
}
Expand All @@ -901,7 +901,7 @@ private static Integer validateNullablePositiveIntegerValue(Object value, String
private static Integer validateIntegerValue(Object value, String property, int lowerBoundIncluded, boolean allowNull)
{
if (value == null && !allowNull) {
throw new PrestoException(INVALID_SESSION_PROPERTY, format("%s must be non-null", property));
throw new TrinoException(INVALID_SESSION_PROPERTY, format("%s must be non-null", property));
}

if (value == null) {
Expand All @@ -910,7 +910,7 @@ private static Integer validateIntegerValue(Object value, String property, int l

int intValue = (int) value;
if (intValue < lowerBoundIncluded) {
throw new PrestoException(INVALID_SESSION_PROPERTY, format("%s must be equal or greater than %s", property, lowerBoundIncluded));
throw new TrinoException(INVALID_SESSION_PROPERTY, format("%s must be equal or greater than %s", property, lowerBoundIncluded));
}
return intValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.trino.Session;
import io.trino.metadata.Metadata;
import io.trino.metadata.QualifiedObjectName;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.SystemTable;
Expand Down Expand Up @@ -75,7 +75,7 @@ public Optional<SystemTable> getSystemTable(ConnectorSession session, SchemaTabl

// dynamic tables require access to the transaction and thus can only run on the current coordinator
if (systemTable.isPresent() && systemTable.get().getDistribution() != SINGLE_COORDINATOR) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Distribution for dynamic system table must be " + SINGLE_COORDINATOR);
throw new TrinoException(GENERIC_INTERNAL_ERROR, "Distribution for dynamic system table must be " + SINGLE_COORDINATOR);
}

return systemTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import io.trino.dispatcher.DispatchManager;
import io.trino.dispatcher.DispatchQuery;
import io.trino.security.AccessControl;
import io.trino.spi.PrestoException;
import io.trino.spi.QueryId;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.procedure.Procedure;
import io.trino.spi.procedure.Procedure.Argument;
Expand Down Expand Up @@ -70,19 +70,19 @@ public void killQuery(String queryId, String message, ConnectorSession session)

// check before killing to provide the proper error message (this is racy)
if (dispatchQuery.isDone()) {
throw new PrestoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
throw new TrinoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
}

dispatchQuery.fail(createKillQueryException(message));

// verify if the query was killed (if not, we lost the race)
checkState(dispatchQuery.isDone(), "Failure to fail the query: %s", query);
if (!ADMINISTRATIVELY_KILLED.toErrorCode().equals(dispatchQuery.getErrorCode().orElse(null))) {
throw new PrestoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
throw new TrinoException(NOT_SUPPORTED, "Target query is not running: " + queryId);
}
}
catch (NoSuchElementException e) {
throw new PrestoException(NOT_FOUND, "Target query not found: " + queryId);
throw new TrinoException(NOT_FOUND, "Target query not found: " + queryId);
}
}

Expand All @@ -98,15 +98,15 @@ public Procedure getProcedure()
KILL_QUERY.bindTo(this));
}

public static PrestoException createKillQueryException(String message)
public static TrinoException createKillQueryException(String message)
{
return new PrestoException(ADMINISTRATIVELY_KILLED, "Query killed. " +
return new TrinoException(ADMINISTRATIVELY_KILLED, "Query killed. " +
(isNullOrEmpty(message) ? "No message provided." : "Message: " + message));
}

public static PrestoException createPreemptQueryException(String message)
public static TrinoException createPreemptQueryException(String message)
{
return new PrestoException(ADMINISTRATIVELY_PREEMPTED, "Query preempted. " +
return new TrinoException(ADMINISTRATIVELY_PREEMPTED, "Query preempted. " +
(isNullOrEmpty(message) ? "No message provided." : "Message: " + message));
}

Expand All @@ -116,7 +116,7 @@ private static QueryId parseQueryId(String queryId)
return QueryId.valueOf(queryId);
}
catch (IllegalArgumentException e) {
throw new PrestoException(INVALID_PROCEDURE_ARGUMENT, e);
throw new TrinoException(INVALID_PROCEDURE_ARGUMENT, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package io.trino.connector.system;

import com.google.common.collect.ImmutableList;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.connector.ConnectorPageSource;
Expand Down Expand Up @@ -69,15 +69,15 @@ public ConnectorPageSource createPageSource(
SchemaTableName tableName = ((SystemTableHandle) table).getSchemaTableName();
SystemTable systemTable = tables.getSystemTable(session, tableName)
// table might disappear in the meantime
.orElseThrow(() -> new PrestoException(NOT_FOUND, format("Table '%s' not found", tableName)));
.orElseThrow(() -> new TrinoException(NOT_FOUND, format("Table '%s' not found", tableName)));

List<ColumnMetadata> tableColumns = systemTable.getTableMetadata().getColumns();

Map<String, Integer> columnsByName = new HashMap<>();
for (int i = 0; i < tableColumns.size(); i++) {
ColumnMetadata column = tableColumns.get(i);
if (columnsByName.put(column.getName(), i) != null) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Duplicate column name: " + column.getName());
throw new TrinoException(GENERIC_INTERNAL_ERROR, "Duplicate column name: " + column.getName());
}
}

Expand All @@ -87,7 +87,7 @@ public ConnectorPageSource createPageSource(

Integer index = columnsByName.get(columnName);
if (index == null) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, format("Column does not exist: %s.%s", tableName, columnName));
throw new TrinoException(GENERIC_INTERNAL_ERROR, format("Column does not exist: %s.%s", tableName, columnName));
}

userToSystemFieldIndex.add(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.google.common.collect.ImmutableMap;
import io.trino.connector.system.jdbc.JdbcTable;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ColumnHandle;
import io.trino.spi.connector.ColumnMetadata;
import io.trino.spi.connector.ConnectorMetadata;
Expand Down Expand Up @@ -112,7 +112,7 @@ private SystemTable checkAndGetTable(ConnectorSession session, ConnectorTableHan
SystemTableHandle systemTableHandle = (SystemTableHandle) tableHandle;
return tables.getSystemTable(session, systemTableHandle.getSchemaTableName())
// table might disappear in the meantime
.orElseThrow(() -> new PrestoException(NOT_FOUND, format("Table '%s' not found", systemTableHandle.getSchemaTableName())));
.orElseThrow(() -> new TrinoException(NOT_FOUND, format("Table '%s' not found", systemTableHandle.getSchemaTableName())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.trino.metadata.QualifiedObjectName;
import io.trino.metadata.QualifiedTablePrefix;
import io.trino.security.AccessControl;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorSession;
import io.trino.spi.connector.ConnectorTableMetadata;
import io.trino.spi.connector.ConnectorTransactionHandle;
Expand Down Expand Up @@ -99,7 +99,7 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect
try {
names = listTables(session, metadata, accessControl, prefix);
}
catch (PrestoException e) {
catch (TrinoException e) {
// listTables throws an exception if cannot connect the database
LOG.debug(e, "Failed to get tables for catalog: %s", catalog);
}
Expand All @@ -113,7 +113,7 @@ public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, Connect
.map(metadata -> metadata.getMetadata().getComment())
.get();
}
catch (PrestoException e) {
catch (TrinoException e) {
// getTableHandle may throw an exception (e.g. Cassandra connector doesn't allow case insensitive column names)
LOG.debug(e, "Failed to get metadata for table: %s", name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import io.trino.server.SessionPropertyDefaults;
import io.trino.server.SessionSupplier;
import io.trino.server.protocol.Slug;
import io.trino.spi.PrestoException;
import io.trino.spi.QueryId;
import io.trino.spi.TrinoException;
import io.trino.spi.resourcegroups.SelectionContext;
import io.trino.spi.resourcegroups.SelectionCriteria;
import io.trino.transaction.TransactionManager;
Expand Down Expand Up @@ -166,7 +166,7 @@ private <C> void createQueryInternal(QueryId queryId, Slug slug, SessionContext
if (query.length() > maxQueryLength) {
int queryLength = query.length();
query = query.substring(0, maxQueryLength);
throw new PrestoException(QUERY_TEXT_TOO_LARGE, format("Query text length (%s) exceeds the maximum length (%s)", queryLength, maxQueryLength));
throw new TrinoException(QUERY_TEXT_TOO_LARGE, format("Query text length (%s) exceeds the maximum length (%s)", queryLength, maxQueryLength));
}

// decode session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import io.trino.execution.StateMachine.StateChangeListener;
import io.trino.server.BasicQueryInfo;
import io.trino.spi.ErrorCode;
import io.trino.spi.PrestoException;
import io.trino.spi.QueryId;
import io.trino.spi.TrinoException;
import org.joda.time.DateTime;

import java.util.Optional;
Expand Down Expand Up @@ -185,7 +185,7 @@ public DispatchInfo getDispatchInfo()

if (queryInfo.getState() == QueryState.FAILED) {
ExecutionFailureInfo failureInfo = stateMachine.getFailureInfo()
.orElseGet(() -> toFailure(new PrestoException(GENERIC_INTERNAL_ERROR, "Query failed for an unknown reason")));
.orElseGet(() -> toFailure(new TrinoException(GENERIC_INTERNAL_ERROR, "Query failed for an unknown reason")));
return DispatchInfo.failed(failureInfo, queryInfo.getQueryStats().getElapsedTime(), queryInfo.getQueryStats().getQueuedTime());
}
if (dispatched) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import io.trino.metadata.Metadata;
import io.trino.security.AccessControl;
import io.trino.server.protocol.Slug;
import io.trino.spi.PrestoException;
import io.trino.spi.TrinoException;
import io.trino.spi.resourcegroups.ResourceGroupId;
import io.trino.sql.tree.Statement;
import io.trino.transaction.TransactionManager;
Expand Down Expand Up @@ -122,7 +122,7 @@ public DispatchQuery createDispatchQuery(
ListenableFuture<QueryExecution> queryExecutionFuture = executor.submit(() -> {
QueryExecutionFactory<?> queryExecutionFactory = executionFactories.get(preparedQuery.getStatement().getClass());
if (queryExecutionFactory == null) {
throw new PrestoException(NOT_SUPPORTED, "Unsupported statement type: " + preparedQuery.getStatement().getClass().getSimpleName());
throw new TrinoException(NOT_SUPPORTED, "Unsupported statement type: " + preparedQuery.getStatement().getClass().getSimpleName());
}

try {
Expand Down
Loading

0 comments on commit f13283b

Please sign in to comment.