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 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@drill.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org