morningman commented on code in PR #70903:
URL: https://github.com/apache/doris/pull/70903#discussion_r4675490165
##########
fe/fe-core/src/main/java/org/apache/doris/connector/ConnectorPluginManager.java:
##########
@@ -192,12 +200,14 @@ void loadBuiltins(ClassLoader classLoader) {
continue;
}
ConnectorSecuritySurface securitySurface;
+ Set<String> formats;
try {
- // Snapshot self-reported metadata (the security surface
included) before publishing the
- // provider so one throwing implementation is rejected cleanly
instead of
+ // Snapshot self-reported metadata (the security surface and
the file formats included) before
+ // publishing the provider so one throwing implementation is
rejected cleanly instead of
// aborting startup or being active without an inventory row.
A surface built through the
// provider's own ServiceLoader fails with
ServiceConfigurationError, as construction can.
securitySurface = provider.securitySurface();
+ formats = provider.getFileFormats();
Review Comment:
Not changing this. 517a285442a reads `getFileFormats()` inside the catch
each loader already has around `securitySurface()` (#70338), so failing formats
count as a failing security surface on that loader. This PR does not change
which errors either loader tolerates: the class path loader skips
`RuntimeException` and `ServiceConfigurationError`, the plugin-directory loader
`LinkageError` too.
No release FE reaches this with a provider that can fail to link. fe-core
depends on connector modules in test scope only (`fe/fe-core/pom.xml`: "fe-core
must never depend on a connector at compile or runtime scope"), and `build.sh`
installs every connector under `plugins/connector/`, whose loader catches
`LinkageError`. In a release FE, `loadBuiltins` finds a provider only in a jar
an operator adds. The only `getFileFormats()` override, Lance's, returns
`Collections.singleton("lance")` with the constant inlined and loads no class.
Catching `LinkageError` there would also change #70338's handling of a
`securitySurface()` that fails to link. `FileSystemPluginManager.loadBuiltins`
draws the same class path / plugin directory line; changing it is one change
for both managers, outside this PR.
##########
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:
The review of cc88d510b8c lists this again without a new trace. The review
of 517a285442a reassessed it and did not retain it ("construction/metadata
follow the actual catalog convention, Lance pins its native read boundary"),
and nothing on this path has changed since: cc88d510b8c changes only the Lance
plugin's metadata memo.
The reasons above hold at cc88d510b8c. The engine pins neither a catalog's
`provider.create` nor its metadata calls: `PluginDrivenScanNode` calls
`applyFilter` and `getColumnHandles` through `readMetadata` unpinned, for
catalog tables and table functions alike, and pins only the scan plan provider.
A plugin whose libraries resolve classes through the TCCL pins at those
boundaries itself (`fe/fe-connector/README.md`, step 12), as Lance does in
`LanceFileFormatConnector.read`. Pinning only `createFileFormatConnector` and
`readPluginFormat` would set the file-format path apart from the catalog path
and still leave the pushdown unpinned, so a plugin could not rely on it. Not
changing it.
--
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]