[jira] [Commented] (DRILL-8328) HTTP UDF Not Resolving Storage Aliases

2022-10-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/DRILL-8328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17613762#comment-17613762
 ] 

ASF GitHub Bot commented on DRILL-8328:
---

cgivre merged PR #2668:
URL: https://github.com/apache/drill/pull/2668




> 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)


[jira] [Commented] (DRILL-8328) HTTP UDF Not Resolving Storage Aliases

2022-10-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/DRILL-8328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 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)


[jira] [Commented] (DRILL-8327) GoogleSheets not Reporting Schemata to Info_Schema

2022-10-06 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/DRILL-8327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17613461#comment-17613461
 ] 

ASF GitHub Bot commented on DRILL-8327:
---

cgivre merged PR #2667:
URL: https://github.com/apache/drill/pull/2667




> GoogleSheets not Reporting Schemata to Info_Schema
> --
>
> Key: DRILL-8327
> URL: https://issues.apache.org/jira/browse/DRILL-8327
> Project: Apache Drill
>  Issue Type: Bug
>  Components: Storage - GoogleSheets
>Affects Versions: 2.0.0
>Reporter: Charles Givre
>Assignee: Charles Givre
>Priority: Major
> Fix For: 2.0.0
>
>
> The GoogleSheets (GS) plugin was not reporting the available documents to the 
> info schema.  This PR makes some modifications so that users can determine 
> which documents are available via the information schema. 
> The GS plugin does not report the tabs as tables to the information schema 
> because that can cause Drill to exceed Google's rate quota.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)