Skip to content

Commit

Permalink
Add new error code and handling: QUERY_EXCEEDED_COMPILER_LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
mduggan-starburst committed Oct 2, 2024
1 parent 2ce6829 commit f2f0979
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import static io.trino.cache.SafeCaches.buildNonEvictableCache;
import static io.trino.operator.project.PageFieldsToInputParametersRewriter.rewritePageFieldsToInputParameters;
import static io.trino.spi.StandardErrorCode.COMPILER_ERROR;
import static io.trino.spi.StandardErrorCode.QUERY_EXCEEDED_COMPILER_LIMIT;
import static io.trino.sql.gen.BytecodeUtils.generateWrite;
import static io.trino.sql.gen.BytecodeUtils.invoke;
import static io.trino.sql.gen.LambdaExpressionExtractor.extractLambdaExpressions;
Expand Down Expand Up @@ -206,7 +207,7 @@ private Supplier<PageProjection> compileProjectionInternal(RowExpression project
}
catch (Exception e) {
if (Throwables.getRootCause(e) instanceof MethodTooLargeException) {
throw new TrinoException(COMPILER_ERROR,
throw new TrinoException(QUERY_EXCEEDED_COMPILER_LIMIT,
"Query exceeded maximum columns. Please reduce the number of columns referenced and re-run the query.", e);
}
throw new TrinoException(COMPILER_ERROR, e);
Expand Down Expand Up @@ -400,7 +401,7 @@ private Supplier<PageFilter> compileFilterInternal(RowExpression filter, Optiona
}
catch (Exception e) {
if (Throwables.getRootCause(e) instanceof MethodTooLargeException) {
throw new TrinoException(COMPILER_ERROR,
throw new TrinoException(QUERY_EXCEEDED_COMPILER_LIMIT,
"Query exceeded maximum filters. Please reduce the number of filters referenced and re-run the query.", e);
}
throw new TrinoException(COMPILER_ERROR, filter.toString(), e.getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import static io.trino.cache.SafeCaches.buildNonEvictableCache;
import static io.trino.operator.project.PageFieldsToInputParametersRewriter.rewritePageFieldsToInputParameters;
import static io.trino.spi.StandardErrorCode.COMPILER_ERROR;
import static io.trino.spi.StandardErrorCode.QUERY_EXCEEDED_COMPILER_LIMIT;
import static io.trino.sql.gen.BytecodeUtils.invoke;
import static io.trino.sql.gen.columnar.FilterEvaluator.isNotExpression;
import static io.trino.sql.gen.columnar.IsNotNullColumnarFilter.createIsNotNullColumnarFilter;
Expand Down Expand Up @@ -179,7 +180,7 @@ static Supplier<ColumnarFilter> createClassInstance(CallSiteBinder binder, Class
}
catch (Exception e) {
if (Throwables.getRootCause(e) instanceof MethodTooLargeException) {
throw new TrinoException(COMPILER_ERROR,
throw new TrinoException(QUERY_EXCEEDED_COMPILER_LIMIT,
"Query exceeded maximum filters. Please reduce the number of filters referenced and re-run the query.", e);
}
throw new TrinoException(COMPILER_ERROR, e.getCause());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.sql.planner;

import com.google.common.base.Throwables;
import com.google.common.base.VerifyException;
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ContiguousSet;
Expand Down Expand Up @@ -270,6 +271,7 @@
import io.trino.sql.relational.SqlToRowExpressionTranslator;
import io.trino.type.BlockTypeOperators;
import io.trino.type.FunctionType;
import org.objectweb.asm.MethodTooLargeException;

import java.util.AbstractMap.SimpleEntry;
import java.util.ArrayList;
Expand Down Expand Up @@ -350,6 +352,7 @@
import static io.trino.operator.window.pattern.PhysicalValuePointer.CLASSIFIER;
import static io.trino.operator.window.pattern.PhysicalValuePointer.MATCH_NUMBER;
import static io.trino.spi.StandardErrorCode.COMPILER_ERROR;
import static io.trino.spi.StandardErrorCode.QUERY_EXCEEDED_COMPILER_LIMIT;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.TypeUtils.readNativeValue;
import static io.trino.spi.type.TypeUtils.writeNativeValue;
Expand Down Expand Up @@ -2067,6 +2070,10 @@ else if (sourceNode instanceof SampleNode sampleNode) {
throw e;
}
catch (RuntimeException e) {
if (Throwables.getRootCause(e) instanceof MethodTooLargeException) {
throw new TrinoException(QUERY_EXCEEDED_COMPILER_LIMIT,
"Query exceeded maximum filters. Please reduce the number of filters referenced and re-run the query.", e);
}
throw new TrinoException(
COMPILER_ERROR,
"Compiler failed. Possible reasons include: the query may have too many or too complex expressions, " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ public enum StandardErrorCode
EXCHANGE_MANAGER_NOT_CONFIGURED(65564, INTERNAL_ERROR),
CATALOG_NOT_AVAILABLE(65565, INTERNAL_ERROR),
CATALOG_STORE_ERROR(65566, INTERNAL_ERROR),
QUERY_EXCEEDED_COMPILER_LIMIT(65567, INTERNAL_ERROR),

GENERIC_INSUFFICIENT_RESOURCES(131072, INSUFFICIENT_RESOURCES),
EXCEEDED_GLOBAL_MEMORY_LIMIT(131073, INSUFFICIENT_RESOURCES),
Expand Down

0 comments on commit f2f0979

Please sign in to comment.