[ https://issues.apache.org/jira/browse/DRILL-8328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17613715#comment-17613715 ]
ASF GitHub Bot commented on DRILL-8328: --------------------------------------- cgivre commented on code in PR #2668: URL: https://github.com/apache/drill/pull/2668#discussion_r989275883 ########## exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillOptiq.java: ########## @@ -713,11 +715,58 @@ private LogicalExpression getDrillFunctionFromOptiqCall(RexCall call) { case "date_trunc": { return handleDateTruncFunction(args); } + case "httprequest": + case "http_request": { + // This code resolves aliases in the http_request function. + String completeRawPluginName = ((QuotedString) args.get(0)).value; + String username = context.getPlannerSettings().getQueryUser(); + + AliasRegistryProvider aliasRegistryProvider = context.getPlannerSettings().getAliasRegistryProvider(); + AliasRegistry storageAliasRegistry = aliasRegistryProvider.getStorageAliasesRegistry(); + AliasRegistry tableAliasRegistry = aliasRegistryProvider.getTableAliasesRegistry(); + + // Split into plugin and endpoint + SchemaPath schemaPath = SchemaPath.parseFromString(completeRawPluginName); + String rawPluginName = SchemaPath.getSimplePath(schemaPath.rootName()).toExpr(); + String rawEndpoint = SchemaPath.getSimplePath(schemaPath.getLastSegment().getNameSegment().getPath()).toExpr(); + + // Now resolve plugin name + String actualPluginName = storageAliasRegistry.getUserAliases(username).get(rawPluginName); + if (StringUtils.isEmpty(actualPluginName)) { + // If it is empty, assign it the original name, + actualPluginName = rawPluginName; + } + + // Finally remove backticks + actualPluginName = SchemaPath.parseFromString(actualPluginName).getRootSegmentPath(); + + // Now do the same for the endpoint name + String actualEndpointName = tableAliasRegistry.getUserAliases(username).get(rawEndpoint); + if (StringUtils.isEmpty(actualEndpointName)) { + // If it is empty, assign it the original name, + actualEndpointName = rawEndpoint; + } + + // Now remove backticks + actualEndpointName = SchemaPath.parseFromString(actualEndpointName).getRootSegmentPath(); + + String finalPluginName = SchemaPath + .getCompoundPath(actualPluginName, actualEndpointName) + .getAsUnescapedPath(); + + QuotedString q = new QuotedString(finalPluginName, finalPluginName.length(), ExpressionPosition.UNKNOWN); + + // Add args to new arg lists + List<LogicalExpression> requestArgs = new ArrayList<>(); + requestArgs.add(q); + requestArgs.addAll(args.subList(1, args.size())); + + return FunctionCallFactory.createExpression(functionName, requestArgs); + } } return FunctionCallFactory.createExpression(functionName, args); } - Review Comment: Fixed, ########## contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/udfs/HttpHelperFunctions.java: ########## @@ -125,6 +125,9 @@ public static class HttpGetFromStoragePluginFunction implements DrillSimpleFunc @Inject DrillbitContext drillbitContext; + @Inject + org.apache.drill.exec.ops.ContextInformation contextInformation; Review Comment: Removed > HTTP UDF Not Resolving Storage Aliases > -------------------------------------- > > Key: DRILL-8328 > URL: https://issues.apache.org/jira/browse/DRILL-8328 > Project: Apache Drill > Issue Type: Bug > Components: Storage - HTTP > Affects Versions: 1.20.0 > Reporter: Charles Givre > Assignee: Charles Givre > Priority: Blocker > Fix For: 1.20.3 > > > The http_request function currently does not resolve plugin aliases > correctly. This PR fixes that issue. -- This message was sent by Atlassian Jira (v8.20.10#820010)