-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Implement support for connector specific builtin functions #25594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
|
|
||
| import com.facebook.airlift.log.Logger; | ||
| import com.facebook.airlift.node.NodeInfo; | ||
| import com.facebook.presto.common.CatalogSchemaName; | ||
| import com.facebook.presto.common.block.BlockEncodingSerde; | ||
| import com.facebook.presto.common.type.TypeManager; | ||
| import com.facebook.presto.connector.informationSchema.InformationSchemaConnector; | ||
|
|
@@ -82,6 +83,7 @@ | |
| import java.util.concurrent.ConcurrentMap; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
|
|
||
| import static com.facebook.presto.metadata.FunctionExtractor.extractFunctions; | ||
| import static com.facebook.presto.spi.ConnectorId.createInformationSchemaConnectorId; | ||
| import static com.facebook.presto.spi.ConnectorId.createSystemTablesConnectorId; | ||
| import static com.google.common.base.Preconditions.checkArgument; | ||
|
|
@@ -308,6 +310,10 @@ private synchronized void addConnectorInternal(MaterializedConnector connector) | |
| } | ||
| connector.getConnectorCodecProvider().ifPresent(connectorCodecProvider -> connectorCodecManager.addConnectorCodecProvider(connectorId, connectorCodecProvider)); | ||
| metadataManager.getProcedureRegistry().addProcedures(connectorId, connector.getProcedures()); | ||
| Set<Class<?>> systemFunctions = connector.getSystemFunctions(); | ||
| if (!systemFunctions.isEmpty()) { | ||
| metadataManager.registerConnectorFunctions(connectorId.getCatalogName(), extractFunctions(systemFunctions, new CatalogSchemaName(connectorId.getCatalogName(), "system"))); | ||
| } | ||
|
|
||
| connector.getAccessControl() | ||
| .ifPresent(accessControl -> accessControlManager.addCatalogAccessControl(connectorId, accessControl)); | ||
|
|
@@ -390,6 +396,8 @@ private static class MaterializedConnector | |
| private final ConnectorSplitManager splitManager; | ||
| private final Set<SystemTable> systemTables; | ||
| private final Set<Procedure> procedures; | ||
|
|
||
| private final Set<Class<?>> functions; | ||
| private final ConnectorPageSourceProvider pageSourceProvider; | ||
| private final Optional<ConnectorPageSinkProvider> pageSinkProvider; | ||
| private final Optional<ConnectorIndexProvider> indexProvider; | ||
|
|
@@ -512,6 +520,10 @@ public MaterializedConnector(ConnectorId connectorId, Connector connector) | |
| List<PropertyMetadata<?>> analyzeProperties = connector.getAnalyzeProperties(); | ||
| requireNonNull(analyzeProperties, "Connector %s returned a null analyze properties set"); | ||
| this.analyzeProperties = ImmutableList.copyOf(analyzeProperties); | ||
|
|
||
| Set<Class<?>> systemFunctions = connector.getSystemFunctions(); | ||
| requireNonNull(systemFunctions, "Connector %s returned a null system function set"); | ||
| this.functions = ImmutableSet.copyOf(systemFunctions); | ||
| } | ||
|
|
||
| public ConnectorId getConnectorId() | ||
|
|
@@ -539,6 +551,11 @@ public Set<Procedure> getProcedures() | |
| return procedures; | ||
| } | ||
|
|
||
| public Set<Class<?>> getSystemFunctions() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name "SystemFunction" seems a bit misleading to me. It suggests they are Presto system functions. How about just call it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think system functions makes sense, because they will be added to the following catalog-schema:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @yingsu00 here that "system" is a bit confusing. It makes me think that these will be system related functions like for getting catalog metadata or something. I also prefer getFunctions().
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we need naming that makes the following clear:
I think |
||
| { | ||
| return functions; | ||
| } | ||
|
|
||
| public ConnectorPageSourceProvider getPageSourceProvider() | ||
| { | ||
| return pageSourceProvider; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove empty line