morningman commented on code in PR #70903:
URL: https://github.com/apache/doris/pull/70903#discussion_r4671488939
##########
fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java:
##########
@@ -233,10 +241,14 @@ boolean registerDiscovered(ConnectorProvider provider,
ConnectorSecuritySurface
boolean failFast) {
Review Comment:
Fixed in 517a285442a. `loadBuiltins` and `loadPlugins` now read
`getFileFormats()` in the try that already guards `securitySurface()` and pass
the result to `registerDiscovered`, which no longer calls the provider for it.
A provider whose formats throw is skipped like one whose security surface
throws: a directory plugin is discarded and logged, and the directories after
it still load; a classpath provider is skipped before its inventory row is
written.
The escape was wider than described: the exception left `Env.initialize`,
and `DorisFE` exits on it, so the FE did not start at all.
Tests: `classpathProviderWhoseFileFormatsThrowIsSkippedNotFatal`, and
`pluginWhoseFileFormatsThrowIsSkippedNotFatal`, whose failing plugin directory
loads before the `version-probe` one, which must still register. On a6c1ad97c52
both fail with `Unexpected exception thrown: java.lang.IllegalStateException:
the connector could not list its file formats`.
`getType()` and `acceptedCreateTableEngineNames()` are still read in
`registerDiscovered`, as on master; this PR does not touch them.
##########
fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java:
##########
@@ -299,6 +314,46 @@ private String createTableEngineNameProblem(Set<String>
engineNames) {
return null;
}
+ /**
+ * Same uniqueness rule as the type name, applied to the file formats a
provider claims for the file table
+ * functions, so that a format means one reader whatever the load order.
The formats the engine reads itself
+ * are reserved: a plugin answering to one would change what existing
statements read.
+ */
+ private String fileFormatProblem(Set<String> formats) {
+ for (String format : formats) {
+ if (format == null || format.trim().isEmpty()) {
+ return "getFileFormats() returned a blank format name";
+ }
+ String lower = format.toLowerCase();
+ if (FileFormatProperties.ENGINE_FORMATS.contains(lower)) {
+ return "file format '" + format + "' is reserved for a format
the engine reads itself";
+ }
+ if (fileFormatProviders.containsKey(lower)) {
+ return "file format '" + format + "' is already claimed by
another registered connector provider";
+ }
+ }
+ return null;
+ }
+
+ /**
+ * The reader of {@code format} for the file table functions, or empty
when no plugin claims the format. Its
+ * connector is built through {@link
ConnectorProvider#createFileFormatConnector} when a statement first reads
+ * the format, with the plugin's own conf and no storage, and kept for the
life of the FE.
+ */
+ public Optional<PluginFileFormat> getFileFormat(String format) {
+ String key = format.toLowerCase();
+ ConnectorProvider provider = fileFormatProviders.get(key);
+ if (provider == null) {
+ return Optional.empty();
+ }
Review Comment:
Not changing this: the file-format path pins the TCCL exactly where a
catalog does.
On master the engine pins it around scan-plan, write-plan, close and two
validation calls. Building a connector (`provider.create`, for CREATE CATALOG
and lazy catalog init) and metadata calls run on the caller's TCCL: a catalog
table's `getTableHandle` / `getTableSchema`, `applyFilter` / `getColumnHandles`
in `PluginDrivenScanNode`, and `getColumnsFromQuery` of the `query()` table
function this path follows. A connector whose libraries resolve classes by name
pins at those boundaries itself (`fe/fe-connector/README.md`, step 12). Lance
does so in `LanceFileFormatConnector.read`, the only call on this path that
touches `org.lance`; its constructor loads no Lance class.
Pinning only `createFileFormatConnector` and `readPluginFormat` would not
give a plugin the guarantee asked for: the scan node's pushdown calls the same
metadata again unpinned, for catalog tables and table functions alike. Making
the engine pin every metadata call changes that convention on both paths, and
is not part of this PR.
This head's External run passed `test_lance_s3_tvf` with Lance loaded from
its plugin directory.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]