|
19 | 19 | import com.facebook.presto.common.type.Type; |
20 | 20 | import com.facebook.presto.spi.ColumnHandle; |
21 | 21 | import com.facebook.presto.spi.ColumnMetadata; |
| 22 | +import com.facebook.presto.spi.ConnectorId; |
22 | 23 | import com.facebook.presto.spi.TableHandle; |
23 | 24 | import com.facebook.presto.spi.analyzer.AccessControlInfo; |
24 | 25 | import com.facebook.presto.spi.analyzer.AccessControlInfoForTable; |
25 | 26 | import com.facebook.presto.spi.analyzer.AccessControlReferences; |
26 | 27 | import com.facebook.presto.spi.analyzer.AccessControlRole; |
| 28 | +import com.facebook.presto.spi.connector.ConnectorTransactionHandle; |
27 | 29 | import com.facebook.presto.spi.function.FunctionHandle; |
28 | 30 | import com.facebook.presto.spi.function.FunctionKind; |
| 31 | +import com.facebook.presto.spi.function.table.Argument; |
| 32 | +import com.facebook.presto.spi.function.table.ConnectorTableFunctionHandle; |
29 | 33 | import com.facebook.presto.spi.security.AccessControl; |
30 | 34 | import com.facebook.presto.spi.security.AccessControlContext; |
31 | 35 | import com.facebook.presto.spi.security.AllowAllAccessControl; |
|
51 | 55 | import com.facebook.presto.sql.tree.Statement; |
52 | 56 | import com.facebook.presto.sql.tree.SubqueryExpression; |
53 | 57 | import com.facebook.presto.sql.tree.Table; |
| 58 | +import com.facebook.presto.sql.tree.TableFunctionInvocation; |
54 | 59 | import com.google.common.collect.ArrayListMultimap; |
55 | 60 | import com.google.common.collect.HashMultiset; |
56 | 61 | import com.google.common.collect.ImmutableList; |
@@ -199,6 +204,8 @@ public class Analysis |
199 | 204 | // Keeps track of the subquery we are visiting, so we have access to base query information when processing materialized view status |
200 | 205 | private Optional<QuerySpecification> currentQuerySpecification = Optional.empty(); |
201 | 206 |
|
| 207 | + private final Map<NodeRef<TableFunctionInvocation>, TableFunctionInvocationAnalysis> tableFunctionAnalyses = new LinkedHashMap<>(); |
| 208 | + |
202 | 209 | public Analysis(@Nullable Statement root, Map<NodeRef<Parameter>, Expression> parameters, boolean isDescribe) |
203 | 210 | { |
204 | 211 | this.root = root; |
@@ -1061,6 +1068,16 @@ public Map<String, Expression> getColumnMasks(Table table) |
1061 | 1068 | return columnMasks.getOrDefault(NodeRef.of(table), ImmutableMap.of()); |
1062 | 1069 | } |
1063 | 1070 |
|
| 1071 | + public void setTableFunctionAnalysis(TableFunctionInvocation node, TableFunctionInvocationAnalysis analysis) |
| 1072 | + { |
| 1073 | + tableFunctionAnalyses.put(NodeRef.of(node), analysis); |
| 1074 | + } |
| 1075 | + |
| 1076 | + public TableFunctionInvocationAnalysis getTableFunctionAnalysis(TableFunctionInvocation node) |
| 1077 | + { |
| 1078 | + return tableFunctionAnalyses.get(NodeRef.of(node)); |
| 1079 | + } |
| 1080 | + |
1064 | 1081 | @Immutable |
1065 | 1082 | public static final class Insert |
1066 | 1083 | { |
@@ -1311,4 +1328,57 @@ public int hashCode() |
1311 | 1328 | return Objects.hash(table, column, identity); |
1312 | 1329 | } |
1313 | 1330 | } |
| 1331 | + |
| 1332 | + /** |
| 1333 | + * Encapsulates the result of analyzing a table function invocation. |
| 1334 | + * Includes the connector ID, function name, argument bindings, and the |
| 1335 | + * connector-specific table function handle needed for planning and execution. |
| 1336 | + */ |
| 1337 | + public static class TableFunctionInvocationAnalysis |
| 1338 | + { |
| 1339 | + private final ConnectorId connectorId; |
| 1340 | + private final String functionName; |
| 1341 | + private final Map<String, Argument> arguments; |
| 1342 | + private final ConnectorTableFunctionHandle connectorTableFunctionHandle; |
| 1343 | + private final ConnectorTransactionHandle transactionHandle; |
| 1344 | + |
| 1345 | + public TableFunctionInvocationAnalysis( |
| 1346 | + ConnectorId connectorId, |
| 1347 | + String functionName, |
| 1348 | + Map<String, Argument> arguments, |
| 1349 | + ConnectorTableFunctionHandle connectorTableFunctionHandle, |
| 1350 | + ConnectorTransactionHandle transactionHandle) |
| 1351 | + { |
| 1352 | + this.connectorId = requireNonNull(connectorId, "connectorId is null"); |
| 1353 | + this.functionName = requireNonNull(functionName, "functionName is null"); |
| 1354 | + this.arguments = ImmutableMap.copyOf(arguments); |
| 1355 | + this.connectorTableFunctionHandle = requireNonNull(connectorTableFunctionHandle, "connectorTableFunctionHandle is null"); |
| 1356 | + this.transactionHandle = requireNonNull(transactionHandle, "transactionHandle is null"); |
| 1357 | + } |
| 1358 | + |
| 1359 | + public ConnectorId getConnectorId() |
| 1360 | + { |
| 1361 | + return connectorId; |
| 1362 | + } |
| 1363 | + |
| 1364 | + public String getFunctionName() |
| 1365 | + { |
| 1366 | + return functionName; |
| 1367 | + } |
| 1368 | + |
| 1369 | + public Map<String, Argument> getArguments() |
| 1370 | + { |
| 1371 | + return arguments; |
| 1372 | + } |
| 1373 | + |
| 1374 | + public ConnectorTableFunctionHandle getConnectorTableFunctionHandle() |
| 1375 | + { |
| 1376 | + return connectorTableFunctionHandle; |
| 1377 | + } |
| 1378 | + |
| 1379 | + public ConnectorTransactionHandle getTransactionHandle() |
| 1380 | + { |
| 1381 | + return transactionHandle; |
| 1382 | + } |
| 1383 | + } |
1314 | 1384 | } |
0 commit comments