diff --git a/core/trino-main/src/main/java/io/trino/metadata/FunctionResolver.java b/core/trino-main/src/main/java/io/trino/metadata/FunctionResolver.java index 2aa3b6601d4d..d216f73fbdc4 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/FunctionResolver.java +++ b/core/trino-main/src/main/java/io/trino/metadata/FunctionResolver.java @@ -48,6 +48,7 @@ import static io.trino.spi.StandardErrorCode.AMBIGUOUS_FUNCTION_CALL; import static io.trino.spi.StandardErrorCode.FUNCTION_IMPLEMENTATION_MISSING; import static io.trino.spi.StandardErrorCode.FUNCTION_NOT_FOUND; +import static io.trino.spi.StandardErrorCode.MISSING_CATALOG_NAME; import static io.trino.spi.function.FunctionKind.AGGREGATE; import static io.trino.spi.function.FunctionKind.SCALAR; import static io.trino.spi.function.FunctionKind.WINDOW; @@ -219,7 +220,7 @@ public static List toPath(Session session, QualifiedF if (name.getSchemaName().isPresent()) { String currentCatalog = session.getCatalog() - .orElseThrow(() -> new IllegalArgumentException("Session default catalog must be set to resolve a partial function name: " + name)); + .orElseThrow(() -> new TrinoException(MISSING_CATALOG_NAME, "Session default catalog must be set to resolve a partial function name: " + name)); return ImmutableList.of(new CatalogSchemaFunctionName(currentCatalog, name.getSchemaName().orElseThrow(), name.getFunctionName())); } @@ -231,7 +232,7 @@ public static List toPath(Session session, QualifiedF // add resolved path items for (SqlPathElement sqlPathElement : session.getPath().getParsedPath()) { String catalog = sqlPathElement.getCatalog().map(Identifier::getCanonicalValue).or(session::getCatalog) - .orElseThrow(() -> new IllegalArgumentException("Session default catalog must be set to resolve a partial function name: " + name)); + .orElseThrow(() -> new TrinoException(MISSING_CATALOG_NAME, "Session default catalog must be set to resolve a partial function name: " + name)); names.add(new CatalogSchemaFunctionName(catalog, sqlPathElement.getSchema().getCanonicalValue(), name.getFunctionName())); } return names.build(); diff --git a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java index 3ddb676ed885..7de4179c53ca 100644 --- a/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java +++ b/core/trino-main/src/main/java/io/trino/metadata/MetadataManager.java @@ -168,6 +168,7 @@ import static io.trino.spi.StandardErrorCode.FUNCTION_IMPLEMENTATION_MISSING; import static io.trino.spi.StandardErrorCode.FUNCTION_NOT_FOUND; import static io.trino.spi.StandardErrorCode.INVALID_VIEW; +import static io.trino.spi.StandardErrorCode.MISSING_CATALOG_NAME; import static io.trino.spi.StandardErrorCode.NOT_FOUND; import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED; import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_FOUND; @@ -2276,7 +2277,7 @@ public Collection listFunctions(Session session) functions.addAll(this.functions.listFunctions()); for (SqlPathElement sqlPathElement : session.getPath().getParsedPath()) { String catalog = sqlPathElement.getCatalog().map(Identifier::getValue).or(session::getCatalog) - .orElseThrow(() -> new IllegalArgumentException("Session default catalog must be set to resolve a partial function name: " + sqlPathElement)); + .orElseThrow(() -> new TrinoException(MISSING_CATALOG_NAME, "Session default catalog must be set to resolve a partial function name: " + sqlPathElement)); getOptionalCatalogMetadata(session, catalog).ifPresent(metadata -> { ConnectorSession connectorSession = session.toConnectorSession(metadata.getCatalogHandle()); functions.addAll(metadata.getMetadata(session).listFunctions(connectorSession, sqlPathElement.getSchema().getValue().toLowerCase(ENGLISH)));