Repository navigation
[feature](lance) Read Lance datasets with s3() through a connector file format SPI - #70903
Conversation
|
run buildall |
…ed reads out of it ### Background Each Lance catalog keeps its FE resources in a generation: the namespace, an Arrow allocator, the cache of described table accesses, and one Lance `Session` that every FE metadata read opens its dataset with, so a later statement reads manifests and index metadata from memory. apache#70830 added the generation and the shared Session (ported from branch-4.2 apache#68078 and apache#68305). REFRESH CATALOG replaced the generation; REFRESH TABLE and REFRESH DATABASE only dropped the cached table accesses and kept the Session. ### What problem does this PR solve? Issue Number: apache#70680 Related PR: apache#70830 (added the shared Session; a code owner found both problems in its review), apache#68078 (branch-4.2's shared Session, which has both) PR Type: Bugfix Problem Summary: REFRESH TABLE and REFRESH DATABASE kept the Session. For a dataset deleted and written again at the same URI with V1 manifest names, the Session serves the deleted dataset's index list. A filtered scan of the new dataset is then planned over index segments it does not have, and the BE fails the query with `scalar index segment ... is absent from the dataset snapshot`; only REFRESH CATALOG recovered. Every REFRESH now starts a new generation. Separately, a REST namespace may vend a new token on every describe. The shared Session keeps an object store for every distinct set of storage options and drops an unused one only when the same options are looked up again, so every token stayed in native memory until the generation was retired, outside the Session's 64 MiB and 128 MiB capacities. A table described with vended options is now opened with a Session of its own, as master did before apache#70830. ### Details - **Frequency:** The first needs a dataset deleted and written again at the same URI with V1 manifest names (older writers, or the Java `Fragment.create` plus `FragmentOperation.Overwrite` commit path), and a version that had an index before and has none now; every filtered query on that version fails until REFRESH CATALOG. The second needs a REST namespace that vends a different token on every describe; FE native memory then grows with every read of such a table. - **Root cause:** Lance 12 keys a version's index list by URI, version and manifest e-tag, and a pinned open of a V1-named dataset has no e-tag, so the deleted dataset's entry matches the new one. The Java `Session` of lance-core 12.0.0 cannot drop the entries of one URI. A Session's object-store registry is keyed by the full storage options and prunes a dead entry only when the same key is looked up again (`rust/lance-io/src/object_store/providers.rs` at Lance v12.0.0). - **Why existing tests missed it:** The native test of the same-URI rewrite asserted recovery after REFRESH CATALOG only, and the shared-Session tests read with storage options that never change. - **Fix:** `invalidateTable` and `invalidateDb` retire the generation as `invalidateAll` does, and the invalidation that dropped only the cached table accesses is removed. A described access records whether the namespace vended options, the same condition the access cache already used to skip caching. Such a read opens its dataset with a Session of its own: a 64 MiB metadata cache and no index cache, as before apache#70830. - **Other paths and branches:** branch-4.2 has both problems: its query reads use the shared Session, and REFRESH TABLE keeps it. The engine also calls `invalidateTable` or `invalidateDb` when a lookup finds a known table gone, and that now starts a new generation too. ### Testing - `fe-connector-lance` unit tests, run locally on Mac arm64 with the JNI libraries loaded: 257 pass, none skipped, 0 Checkstyle violations. - `LanceSharedSessionNativeTest.everyRefreshReadsTheIndexesOfADatasetWrittenAgainAtTheSameUri` now runs for REFRESH TABLE, DATABASE and CATALOG. `readsWithVendedOptionsKeepOutOfTheSharedSession` reads 8 times, with a new token each time, and asserts that the shared Session's metadata cache saw none of them; a read without vended options still hits it. - Mutations, each run against its test classes (the unmutated run passes all of them): REFRESH TABLE and DATABASE dropping only the described accesses again fails the same-URI test for TABLE and DATABASE (`expected: <[]> but was: <[id_idx]>`) and both generation tests, while CATALOG still passes; opening vended reads with the shared Session fails the vended test (the shared cache saw all 8 reads), and so does never recording the vended flag, which also fails the two access-cache tests of vended credentials. ### Release note None (changes behavior that apache#70830 added and no release has shipped) ### Check List (For Author) - Behavior changed: Yes (REFRESH TABLE and REFRESH DATABASE on a Lance catalog also start a new Lance Session; reads with vended options do not use the shared Session) - Does this need documentation: Yes, apache/doris-website#4159 documents the refresh behavior of apache#70830 and needs the same change - Pre-submission status: Partially verified: the native tests ran on Mac arm64 only; the BE failure is the reviewer's report and was not reproduced here ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: the code, the tests and this description - Human review: not stated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…properties ### Background A Lance scan is planned in two calls to the connector's scan-plan provider: `getScanNodePropertiesResult` builds the scan's properties (the pushed Substrait filter that BE receives, and the EXPLAIN text), and `planScan` builds the ranges. The provider keeps no state between the two, so each converts the scan's conjuncts with `LancePredicateConverter`. ### What problem does this PR solve? Issue Number: apache#70680 Related PR: apache#70827 (added the predicate pushdown; review comment r4656423962 asked for this) PR Type: Performance Problem Summary: `LancePredicateConverter.convert` serialized the pushed conjuncts to Substrait and rendered their EXPLAIN text on every call, so `planScan` serialized a filter it never uses: planning the ranges needs only which conjuncts were pushed. The result of a conversion now keeps the converted expression and serializes it, or renders the text, only when asked, which only the scan properties do. The provider still keeps no state between its calls. ### Details - **Why it was slow:** One extra Substrait serialization per scan node, measured for the reply on apache#70827 on JDK 17: 2.2 µs for two comparisons on a 20-column table, 51 µs with a 1000-value IN, 0.54 ms for a 10k-value IN on 200 columns. - **Optimization:** `ConversionResult` holds the combined expression and the serializer; `getSubstraitFilter()` serializes and `getDebugPredicate()` renders on each call, and `getScanNodePropertiesResult` calls the first once instead of twice. A statement-scoped reuse of the conversion was not taken: its key would need the filter, as a self-join or UNION ALL of one table at one version plans two scans with different filters, and loading index metadata inside a statement-scope loader can fail with `Recursive update`. - **Results:** `planScan` serializes nothing; the scan properties serialize once. The bytes BE receives and the EXPLAIN output are unchanged. - **Applicability and cost:** Every Lance scan with a pushed filter. No cost: the expression the converter already built is kept until the scan properties serialize it. ### Testing - `fe-connector-lance` unit tests, run locally on Mac arm64 with the JNI libraries loaded: 257 pass, none skipped, 0 Checkstyle violations. The existing Substrait and EXPLAIN assertions of `LancePredicateConverterTest` and `LanceScanPlanProviderTest` pass unchanged. - `LanceScanPlanProviderTest.rangePlanningNeverSerializesTheFilter` gives the provider a converter whose serializer counts its calls: planning the ranges of a scan with a pushed filter counts 0, the scan properties count 1, and the filter BE receives equals the one serialized directly. - Mutations, each failing the new test: serializing at conversion time as before (`expected: <0> but was: <1>`), and serializing twice for the scan properties (`expected: <1> but was: <2>`). ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: the code, the test and this description - Human review: not stated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le format SPI
### Background
A Lance dataset is a directory of versioned manifests that list its fragments (data files) and indexes. branch-4.1 (since 4.1.4) and branch-4.2 read one with `s3("uri" = ..., "format" = "lance")`: the FE opens the dataset, pins its newest version and plans one range per fragment. On master, Lance lives in the `fe-connector-lance` plugin, which serves Lance catalogs (apache#70681, apache#70725, apache#70827). The file table functions (`s3()`, `file()`, `hdfs()`, ...) read only the formats of a closed list in fe-core: the FE lists the files and the BE's file readers read them.
### What problem does this PR solve?
Issue Number: apache#70680
Related PR: apache#70830 (builds on it), apache#70827 (the pushdown this scan reuses), apache#65730, apache#66805, apache#67325, apache#67921, apache#68078 (the branch-4.x implementation this ports)
PR Type: Feature
Problem Summary:
Users who read Lance datasets with `s3()` on 4.1.4 and 4.2 get an error on master, because fe-core no longer knows the format. This PR lets a connector plugin serve a format to the file table functions: `s3()`, and `file()` over S3-compatible storage, hand the dataset's location and storage to the plugin, which pins the newest version, gives the columns, and plans the scan through the scan node of catalog tables, pushdown included. The Lance plugin serves `lance`. Half of the diff is tests. The branch also carries three review fixes for the Lance plugin, each in its own commit. Other formats and table functions are unchanged.
```sql
SELECT count(*), sum(row_id) FROM s3(
"uri" = "s3://warehouse/lance/all_types.lance", "s3.endpoint" = "http://127.0.0.1:19001",
"s3.access_key" = "<ak>", "s3.secret_key" = "<sk>", "s3.region" = "us-east-1",
"use_path_style" = "true", "format" = "lance");
```
| FE | Result |
|---|---|
| master before this PR | `ERROR 1105 (HY000): errCode = 2, detailMessage = Can not build s3(): format:lance is not supported.` |
| this PR | `12 78` |
### Details
- **Change map:** The feature commit is +2043 −69 in 37 files, more than half of it tests: unit tests +613, two regression suites with a fixture builder +341, their generated `.out` +116, and a 5 KB Lance fixture copied from branch-4.2. The production code is +967 −63, in three parts, in reading order:
1. The SPI (+150 −1): `ConnectorProvider#getFileFormats` and `#createFileFormatConnector`, `ConnectorFileSource`, `ConnectorFileSourceOps`; connector plugin API 35.0 -> 36.0 with its surface baseline.
2. fe-core (+310 −12): format claims and one connector per format (`ConnectorPluginManager`, `PluginFileFormat`); `ExternalFileTableValuedFunction` and `S3TableValuedFunction` hand the location to the plugin and scan with `PluginDrivenScanNode`; two small `PluginDrivenScanNode` fixes for a table that belongs to no catalog (Notes for Reviewers).
3. The Lance plugin (+508 −51): `LanceFileFormatConnector`, `LanceFileMetadata`, `LanceFileTableHandle`, and `LanceScanPlanProvider` split by where the metadata comes from (`CatalogSource`, the old behavior; `FileSource`, the new one).
The two commits before it hold the carried review fixes (+248 −194).
- **Scope:** `s3()`, and `file()` over S3-compatible storage. The uri is the dataset root: nothing is listed and no glob applies. The statement reads the version that is newest when it is analyzed. `DESC FUNCTION` shows the columns as a Lance catalog does. Predicates, LIMIT and `COUNT(*)` are pushed as for a catalog table; the 4.x table function pushed none. Read only: `INSERT INTO s3(...)`, `OUTFILE ... FORMAT AS lance` and routine load still fail with `format:lance is not supported.`. `hdfs()` and `http()` refuse the format, as on 4.x, and so do `path_partition_keys` and a streaming job's file list. `local()` is out: master disables it for every format (apache#69591).
- **Design:** A plugin declares its formats (`ConnectorProvider#getFileFormats()`) and builds, for each, a connector that belongs to no catalog (`createFileFormatConnector`). Its metadata implements `ConnectorFileSourceOps#getFileTableHandle(session, ConnectorFileSource)`, which resolves the location and storage to a table handle and pins the version; from there the engine uses the existing interfaces, as the `query()` table function does: `getTableSchema` for the columns, `PluginDrivenScanNode` for the scan. fe-core claims format names when it admits a plugin: case-insensitive, one plugin per name, and the formats the engine reads itself are reserved. A format's connector is built on first use, kept for the life of the FE, and given a negative catalog id, which no catalog has, so its per-statement state stays apart. Rejected: a narrow `TVFScanNode` interface returning a schema and splits, which would duplicate the plugin scan node's range and storage plumbing and lose the pushdown. Not discussed publicly; apache#70680 lists this as a follow-up.
- **Usage:**
```sql
DESC FUNCTION s3("uri" = "s3://bucket/path/data.lance", "s3.endpoint" = "...",
"s3.access_key" = "...", "s3.secret_key" = "...", "s3.region" = "...", "format" = "lance");
SELECT row_id FROM file("uri" = "s3://bucket/path/data.lance", "s3.endpoint" = "...",
"s3.access_key" = "...", "s3.secret_key" = "...", "s3.region" = "...", "format" = "lance")
WHERE int64_col > 0;
```
EXPLAIN of the second statement:
```
TABLE: null.null.S3TableValuedFunction
CONNECTOR: lance
lanceCatalogType=tvf
lanceVersion=1
lanceFragments=1
lancePushdownPredicate=(int64_col > 0)
```
- **Default behavior:** Available whenever the Lance plugin is installed, as the FE package does by default.
- **Compatibility:** FE only: the ranges carry the same `TLanceFileDesc` and `TLanceScanParams` as a catalog scan, so neither the BE nor thrift changes. A column of the types the BE reader added in 4.2 keeps a smooth-upgrade source BE out of the scan, as for a catalog table. Plugins built for API 35.0 are refused by the version gate, as after every SPI change. Nothing is persisted.
- **Security and privileges:** The FE reads the dataset's manifest and fragment list at the endpoint the user names, with the user's credentials: the request `s3()` already makes to list files, behind the same gate, which runs before the plugin opens anything (`s3_load_endpoint_white_list`, and the SSRF check when `security_checker_class_name` is set). The privilege is that of `s3()`: none beyond running the query, USAGE when a `resource` is named. Credentials stay out of EXPLAIN, the handle's `toString` and error messages.
- **Carried review fixes:**
1. REFRESH TABLE and REFRESH DATABASE also start a new Lance Session (`535b9085a51`, [apache#70830 r4661513530](apache#70830 (comment))). A dataset deleted and written again at the same URI with V1 manifest names kept a stale index list after REFRESH TABLE, and the BE refused filtered scans (`scalar index segment ... is absent from the dataset snapshot`); lance-core 12's Java `Session` cannot drop one URI's entries. Cost: REFRESH TABLE drops the catalog's cached Lance metadata, where branch-4.x rotates the Session only on REFRESH CATALOG.
2. Reads with namespace-vended storage options use a Session of their own (`535b9085a51`, [apache#70830 r4665616715](apache#70830 (comment))): a namespace vending a new token per describe grew the shared Session's object-store registry without bound.
3. `planScan` no longer serializes the pushed Substrait filter (`ec723b4f2e5`, [apache#70827 r4656423962](apache#70827 (comment))): the conversion is lazy.
- **Follow-up plan:** The Lance search table functions, index DDL and inspection, and tag and branch versioning follow in their own PRs (apache#70680).
### Testing
- fe-core: the new `PluginFileFormatTableValuedFunctionTest` (8 cases) drives `s3()`, `file()`, `hdfs()` and `http()` against a mocked plugin: the endpoint gate runs first and a refused endpoint never reaches the plugin, nothing is listed, the plugin gets the normalized location and storage, the columns are its own, the scan and its EXPLAIN go through `PluginDrivenScanNode`, a predicate reaches the plugin while the statement holds an internal table's plan read lock, and the refusals hold. `ConnectorPluginManagerTest` covers the claims. With the other table function tests, the `PluginDrivenScanNode*Test` family and `PluginDrivenMissingTableTest`, 479 fe-core tests in 45 classes pass.
- `fe-connector-spi`: its 166 tests, with the new surface baseline and API 36.0.
- Lance plugin: 264 tests, none skipped (macOS arm64, lance-core 12.0.0 JNI), among them `LanceFileFormatNativeTest`: the pinned version holds after a newer commit, the table function's storage goes into the scan and stays out of EXPLAIN, filter and `COUNT(*)` are pushed, the added types raise the upgrade fence, a missing dataset fails with a message.
- Mutations, run before the rebase: 13 targeted mutations of the feature commit fail their tests, among them the old EXPLAIN code (`NullPointerException`), the unguarded cast (`FunctionGenTable cannot be cast to class PluginDrivenExternalTable`), the endpoint gate skipped, an engine format claimable, and the version pin dropped.
- Regression, locally and before the rebase: the 10 `external_table_p0/lance` suites, the two new ones included, pass on an FE built from this branch and a BE built from apache#70827's head, against a host S3 stand-in and the REST stub instead of MinIO. The 7 result blocks ported from branch-4.2's `.out` are identical; the new blocks (EXPLAIN, pushdown, `COUNT(*)` over three fragments with deletions, `file()`, `INSERT ... SELECT` into an OLAP table, a join with one, the refusals) match what pylance 7.0.0 reads from the same fixtures.
- Carried fixes: their tests are in the plugin run above, and one mutation per changed behavior, run before the rebase, fails each.
- After apache#70830 merged, the three commits were replayed onto master without conflicts and with unchanged patches (`git range-diff` all `=`). The new base changes no file of the plugin, the SPI, the Lance suites or their fixtures; on this path it changes only the generic pipeline-task and TLS code. The unit tests above ran on the rebased branch; the mutations and the regression suites did not run again.
### Notes for Reviewers
- Review commit by commit: the first two are the carried review fixes, the third is the feature.
- `PluginDrivenScanNode` assumed a catalog table in two places that a table function's table (no database, no catalog) broke: EXPLAIN read `getDatabase().getCatalog()`, and `convertPredicate` cast the table to `PluginDrivenExternalTable` whenever the statement also held an internal table (a join, or `INSERT INTO olap_table SELECT ...`).
- `ConnectorFileSource` hands over no other table function properties: they cannot be told apart from storage keys reliably, and passing them would copy the credentials again.
- A format's connector holds nothing to close: every read opens and closes its own Arrow allocator and Lance Session, so one table function's credentials never reach a cache another reads. The statement memo, keyed by URI and version, only spares the scan a second read; every table function resolves its handle with its own storage.
### Release note
`s3()`, and `file()` over S3-compatible storage, read Lance datasets with `"format" = "lance"` as on 4.1 and 4.2, and now push predicates, LIMIT and `COUNT(*)` into the scan.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: Yes (the `s3()` and `file()` pages need `"format" = "lance"` for releases built from master; a doris-website PR follows)
- Pre-submission status: Partially verified: the regression suites ran before the rebase, on macOS against a local S3 stand-in instead of the MinIO container, with a BE built from apache#70827's head (this PR changes no BE code); the External pipeline runs them in docker
### AI Disclosure
- Tool: Claude Code (Claude Opus 5.5)
- Generated: the code, the tests and this description
- Human review: not stated
- Prompts:
1. Port branch-4.x's `"format" = "lance"` file table function to master as the next Lance task, on a branch stacked on apache#70830.
2. Fix in the same PR the two round-4 review findings on apache#70830 and r4656423962 on apache#70827.
3. The design as approved: plugins declare formats and build a catalog-less connector; only `s3()` and `file()` over S3 hand over a data set; keep the pushdown the catalog scan already has.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fcddb3a to
a6c1ad9
Compare
|
run buildall |
|
/review |
There was a problem hiding this comment.
REQUEST_CHANGES. Reviewed the exact PR head a6c1ad9 against base 2f298f7. The PR's Lance file-format TVF design, URI/version pinning, storage-option propagation, refresh generation lifecycle, predicate conversion, SPI 36.0 surface, fixture wiring, and S3/file delegation were traced statically. Two P1 findings remain: the new file-format plugin construction/analysis boundary is not TCCL-pinned, and a throwing getFileFormats() aborts directory plugin discovery despite the documented partial-success behavior. No existing blocking inline comments apply.
Critical checkpoints: the requested Lance TVF behavior is covered by the new connector path and regression tests; no thrift/proto compatibility change is present; refresh/in-flight resource ownership and FE/BE snapshot consistency were verified; parallel s3()/file() and catalog/TVF paths were checked; and all changed files were covered by the two full-review slices plus the targeted risk sweeps. The tests/builds/regression cluster were not executed because this invocation is static-only. There was no additional user-provided focus.
Convergence: round 1 produced the two findings; round 2 independently reconfirmed both, found no new valuable findings, and left no coverage gaps. The review converged after round 2.
Review converged after 2 round(s).
… stopping FE startup ### Background At startup the FE admits connector providers in two batches: `loadBuiltins` for the classpath, then `loadPlugins` for each directory under `plugins/connector`. A provider is third-party code, so each loader first reads what the provider reports about itself inside a catch, and skips the provider when that throws; `loadPlugins` promises partial success, so one bad plugin directory must not stop the FE. `registerDiscovered` then checks and claims the names a provider declares: its type, its `CREATE TABLE ... ENGINE=` names, and, since the file format SPI of this PR, its file formats (`ConnectorProvider#getFileFormats`). ### What problem does this PR solve? Issue Number: apache#70680 Related PR: apache#70903 (review comment r4668526070) PR Type: Bugfix Problem Summary: `registerDiscovered` called `getFileFormats()` itself, outside the catch in which both loaders read the provider's security surface. A provider whose `getFileFormats()` throws escaped `loadPlugins`, then `Env.initialize`, and `DorisFE` exits on that: the FE did not start, where a plugin whose security surface throws is skipped. Both loaders now read the formats in the same catch as the security surface and pass them to `registerDiscovered`: such a directory plugin is discarded and logged and the directories after it still load, and such a classpath provider is skipped before its inventory row is written. ### Details - **Frequency:** Not observed; found by review. Triggers when a connector provider's `getFileFormats()` throws, such as an override that reaches a class its plugin cannot link. The Lance provider returns a constant. - **Root cause:** `ConnectorPluginManager.registerDiscovered` read `getFileFormats()`, which is plugin code, after the loaders' catch, so an exception there propagated out of `loadPlugins` and `loadBuiltins`. - **Why existing tests missed it:** The file format cases of `ConnectorPluginManagerTest` admit providers through `registerDiscovered` directly, with providers that answer their formats; the throwing-provider cases there cover only `securitySurface()`. No regression suite loads a broken plugin. - **Fix:** Read the formats with the security surface, where the loaders already turn a failure into a skip; `registerDiscovered` takes them as a parameter, as it takes the security surface. - **Other paths and branches:** `getType()` and `acceptedCreateTableEngineNames()` are still read in `registerDiscovered`, as on master; this change does not touch them. No release branch has the bug: `getFileFormats()` is new in this PR. ### Testing - `ConnectorPluginManagerTest.classpathProviderWhoseFileFormatsThrowIsSkippedNotFatal` and `pluginWhoseFileFormatsThrowIsSkippedNotFatal`; the second loads a plugin directory whose provider throws ahead of the `version-probe` plugin, which must still register. Before the fix both fail with `Unexpected exception thrown: java.lang.IllegalStateException: the connector could not list its file formats`; with it they pass. - fe-core, run locally on Mac arm64 with the table function, `PluginDrivenScanNode*Test` and plugin manager tests of this PR: 481 tests in 45 classes pass, 0 Checkstyle violations. ### Release note None ### Check List (For Author) - Behavior changed: No - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Claude Code (Claude Opus 5.5) - Generated: the code, the tests and this description - Human review: not stated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the review of a6c1ad9 in 517a285. Per finding:
|
|
run buildall |
|
/review |
There was a problem hiding this comment.
Request changes for one new P1: Lance file-table-function metadata is shared across unrelated S3 endpoints when URI and version match, which can silently produce incorrect COUNT(*) results and incorrect schema/fragment planning. The inline comment contains the concrete trigger and fix direction.
Reviewed all 52 changed paths and the full authoritative diff at 517a285, including the carried refresh/session and lazy-serialization fixes. Execution flow inspected: s3()/file() -> storage normalization and endpoint gate -> plugin handle/schema -> FunctionGenTable -> PluginDrivenScanNode -> Lance scan properties and versioned fragment ranges -> existing BE reader.
| Required checkpoint | Static-review conclusion |
|---|---|
| Goal and evidence | The generic file-format SPI restores Lance reads through s3()/file() and reuses catalog pushdown. Unit/native/regression tests exercise the intended flow; endpoint-dependent metadata identity is incorrect (new P1). |
| Scope and reuse | Core remains connector-agnostic; catalog/file scans share the planner. The carried lifecycle fixes are documented and have focused tests. |
| Concurrency and locks | Startup registers providers before query admission; concurrent lazy construction uses ConcurrentHashMap and AtomicLong. Generation enter/retire/leave protect ownership; native cleanup runs outside the monitor. No new table/catalog lock order issue found. |
| Lifecycle and initialization | Format connectors are FE-lifetime and stateless; metadata is statement-owned. TABLE/DATABASE refresh now retires native generations, preserving readers in flight. Vended reads and file TVFs use dataset-owned Sessions; dataset closes before allocator. No new C++ static initialization involved. |
| Configuration | No new configuration key; existing plugin configuration supplies the Arrow read limit. |
| Compatibility | SPI major version, pinned test and public surface advance to 36.0. Existing Lance scan descriptors are reused; additional-type projections retain the current-BE fence. |
| Thrift/protobuf IDs | No gensrc changes or new wire fields. |
| Parallel paths | Catalog and file reads, s3()/file() delegation, joins/INSERT SELECT, filter/residual/LIMIT/count, and ordinary versus scalar-index planning were traced. Read-only refusals remain. |
| Special conditions | Engine format names remain reserved; non-S3 TVFs, path partitions and prelisted streaming files are rejected. Catalog-only scan branches are guarded or unreachable for TVFs; TABLESAMPLE and TopN lazy materialization do not admit this Lance TVF path. |
| Test coverage | Added tests cover format admission, failure isolation, endpoint ordering, schema/scan/EXPLAIN, version pinning, storage transport, count/filter, upgrade fence, refresh and Session isolation. Missing case: two endpoints with the same URI/version. |
| Changed results | Regression .out expectations were checked against queries, fixture-builder values, nested-null semantics and deterministic ordering. Generated-output provenance and binary fixture decoding were not independently established. |
| Observability | Existing TVF initialization timing, discovery/error logging, scan EXPLAIN and BE counters cover the new flow. File metadata intentionally omits catalog-group metrics. |
| Transactions and persistence | No new journal, transaction, persistent catalog state or failover protocol. Snapshot versions remain pinned for schema and ranges; metadata identity still needs the inline fix. |
| Writes and atomicity | No new write path. INSERT INTO s3 and OUTFILE retain closed format validation; INSERT SELECT only reads through the new source. |
| FE/BE propagation | Storage/filter remain scan-level, while URI/version/fragments/count remain per-range on the existing protocol; producer and consumer paths were inspected. |
| Performance and memory | Lazy conversion removes redundant Substrait serialization from range planning. Shared planning is reused; native ownership and bounded caches were inspected. No further substantiated performance defect found. |
| Other core invariants | No Doris committed-data visibility, visible-version or MoW delete-bitmap changes. Error propagation and resource cleanup were inspected; the endpoint memo collision is the identified data-correctness regression. |
Existing review context was independently reassessed: 4668526070 is fixed for the reported directory-provider failure by the guarded getFileFormats snapshot and discard/continue path. 4668525701 is not retained as a confirmed blocker: construction/metadata follow the actual catalog convention, Lance pins its native read boundary, and scan callbacks use engine classloader pinning. No duplicate inline comments are added, and no existing P0/P1 was independently confirmed still blocking this head.
No additional user focus was supplied. This is a static review: no builds, tests, benchmarks, JNI execution or multi-endpoint runtime reproduction were performed. Runtime behavior and the binary fixture contents remain outside the inspected evidence; no unresolved concrete candidate or uncovered source scope remains. Review converged after two rounds, with every reviewer in the final round reporting NO_NEW_VALUABLE_FINDINGS.
Review converged after 2 round(s).
| static LanceTableMetadata sharedFileMetadata(ConnectorSession session, LanceFileTableHandle handle, | ||
| Supplier<LanceTableMetadata> loader) { | ||
| return ConnectorStatementScopes.resolveInStatement(session, FILE_METADATA_NAMESPACE, "", | ||
| handle.getUri() + "@" + handle.getVersion(), loader); |
There was a problem hiding this comment.
[P1] Include the storage binding in the file metadata memo key
All Lance TVFs in a statement share this format's catalog id, so two calls with the same s3://bucket/t.lance and version 1 but different s3.endpoint values hit the same entry. getFileTableHandle reads both datasets, but the second memo insertion is discarded; getTableSchema and FileSource.metadata then use the first dataset's schema, fragments and row count with the second handle's storage. For example, a UNION ALL of COUNT(*) against two MinIO endpoints containing 1 and 2 rows returns the first resolved count twice when count pushdown is enabled. Include the storage binding in the memo identity, or retain metadata per TVF handle, and cover two endpoints sharing a URI/version.
There was a problem hiding this comment.
Fixed in cc88d51. Each LanceFileTableHandle now carries a resolution number that no other handle has, and sharedFileMetadata keys the memo by uri@version#resolution: the memo is kept per resolved handle, not per uri and version. A uri names no endpoint (s3() keeps s3://bucket/key and maps HTTP URLs to it), so the old key could not tell two stores apart.
I did not put the storage binding into the key. It would bring credentials, even hashed, into it, and a partial choice of the options that name a store (endpoint, region, path style) would bring the collision back. It would also spare no read: every table function reads its dataset when getFileTableHandle resolves its handle, and the memo only spares that handle's scan a second read.
Test: LanceScanPlanProviderTest.fileTableFunctionsOfOneUriOnTwoEndpointsCountTheirOwnDatasets plans COUNT(*) for two handles on one uri at one version with two endpoints, 1 row and 2 rows. On 517a285 it fails with expected: <2> but was: <1>; on cc88d51 it passes, as do the plugin's other 264 tests.
…o entry
### Background
A Lance file table function, `s3("uri" = ..., "format" = "lance")`, resolves its dataset in the Lance plugin: `getFileTableHandle` reads the manifest at the newest version with the table function's storage and returns a handle pinned to that version. The columns, the scan properties and the range plan then take that metadata from a per-statement memo instead of opening the dataset again. Every Lance table function of a statement has the format's catalog id, so the memo key alone tells their datasets apart.
### What problem does this PR solve?
Issue Number: apache#70680
Related PR: apache#70903 (review comment r4671691836)
PR Type: Bugfix
Problem Summary:
The memo key was the dataset's uri and version, and a uri names no endpoint: `s3()` keeps `s3://bucket/path` as written and turns `http://host:port/bucket/path` into `s3://bucket/path`. Two table functions of one statement that read one bucket and path on two object stores, at the same version, shared one entry, so the second one planned the first one's columns, fragments and row count against its own storage. With `COUNT(*)` pushed, a `UNION ALL` of the two counts returned the first count twice; a scan read the second dataset by the first one's fragment ids and missed any fragment the first did not have. The memo is now kept per resolved handle. Each table function still reads its dataset once, when it resolves its handle, so no read is added.
### Details
- **Frequency:** Not observed; found by review. Triggers when one statement reads, through two file table functions, the same bucket and path on two endpoints whose datasets are at the same version, such as datasets written once (version 1) on a test store and a production store.
- **Root cause:** `LanceStatementScope.sharedFileMetadata` keyed the memo by `uri@version`, which names a dataset only within one store. `getFileTableHandle` read both datasets, but the memo kept the first entry, and `getTableSchema` and the scan took that entry for every handle with that uri and version.
- **Why existing tests missed it:** The file table function tests read one dataset per statement, and `LanceFileFormatNativeTest.scanCarriesTheTableFunctionsStorageAndShowsNoneOfIt` built a second handle on the same dataset and relied on the shared entry. The regression suites run against one object store.
- **Fix:** Each `LanceFileTableHandle` carries a resolution number no other handle has, and the memo key includes it. Rejected: the storage binding in the key. Credentials, even hashed, would enter the key, and a partial choice of the options that name a store (endpoint, region, path style) would bring the collision back, all to spare reads that never happen, since each table function reads its dataset when it resolves its handle.
- **Other paths and branches:** A Lance catalog's memo is keyed by catalog id, database and table, and a catalog reads one storage, so it does not collide. The BE opens each scan's dataset with that scan's own storage options. No release branch has the bug: branch-4.1 and branch-4.2 keep a table function's version, fragments and columns in the table function itself, and the memo is new in this PR.
### Testing
- `LanceScanPlanProviderTest.fileTableFunctionsOfOneUriOnTwoEndpointsCountTheirOwnDatasets`: two handles on one uri at one version with two endpoints, one dataset of 1 row and one of 2, each remembered as resolving its handle remembers it; then `COUNT(*)` of each through the file table function's scan planning. Before the fix it fails with `expected: <2> but was: <1>`; with it, it passes.
- The Lance plugin, run locally on Mac arm64 with lance-core 12.0.0's JNI: 265 tests pass, none skipped, `LanceFileFormatNativeTest` among them, whose second handle now reads its own metadata; 0 Checkstyle violations in 9 modules.
- Not run: a statement against two real object stores; the regression environment has one.
### Release note
None
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Ready
### AI Disclosure
- Tool: Claude Code (Claude Opus 5.5)
- Generated: the code, the tests and this description
- Human review: not stated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Addressed the review of 517a285 in cc88d51. Per finding:
The two first-round threads are resolved, as the second round's summary accepts both. |
|
run buildall |
|
/review |
There was a problem hiding this comment.
Static review completed at the pinned PR head cc88d51. The main feature path is coherent: plugin file TVFs resolve a per-statement Lance handle, preserve the pinned version and storage options into FE/BE planning, and the refresh/session lifecycle is reference-counted. The required FE module, connector, lifecycle, compatibility, and error-handling checkpoints were inspected. The SPI major version and surface baseline are updated.
One new P1 is included inline: classpath provider discovery now calls getFileFormats(), but loadBuiltins() catches only ServiceConfigurationError and RuntimeException; a NoClassDefFoundError or other LinkageError from an optional format dependency escapes Env initialization and aborts FE startup. The directory path already handles this failure class.
Existing review context: the prior file-format TCCL lifecycle P1 (comment 4668525701) still applies to the generic plugin boundary and is preserved in existing_blocking_comment_ids without duplicating it. The earlier directory-provider failure and Lance metadata-memo findings are fixed at this head and were not repeated.
The TVF null-database/TABLESAMPLE concern was dismissed after tracing the physical TVF translator: it does not forward TABLESAMPLE, and the remaining catalog assumptions are guarded or null-safe. Lance snapshot, storage, vended-credential, nested-Null, and fixture risks were checked and no additional finding was substantiated. No user-provided focus points were supplied. Review validation was static inspection only; builds, tests, and runtime/regression execution were not run.
Review converged after 2 round(s).
Existing P0/P1 findings confirmed for this head: #70903 (comment)
| // 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(); |
There was a problem hiding this comment.
[P1] Skip classpath providers whose file-format inventory fails to link. loadBuiltins() now invokes provider.getFileFormats() here, but the surrounding catch only handles ServiceConfigurationError | RuntimeException. A classpath provider that references an optional format dependency can throw NoClassDefFoundError (a LinkageError), which escapes the synchronous Env.initConnectorPluginManager() startup path and aborts FE initialization. The directory-loader path already catches LinkageError; catch it for classpath metadata too and add a classpath provider failure test.
There was a problem hiding this comment.
Not changing this. 517a285 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.
| throw new AnalysisException("Format " + fileFormatProperties.getFormatName() | ||
| + " reads the data set at the uri as a whole, not a list of files"); | ||
| } | ||
| readPluginFormat(); |
There was a problem hiding this comment.
[P1] Check the bound filesystem before handing this URI to the plugin. file() also delegates Azure to S3TableValuedFunction, whose getTFileType() always returns FILE_S3. With Azure shared-key properties, I verified that wasbs://warehouse@demo.blob.core.windows.net/test.lance becomes s3://warehouse/test.lance and LanceStorageOptions.fromDorisStorageProperties returns an empty map. Lance then tries S3 without the Azure endpoint or credentials. A lookup can fail or resolve a different dataset if that S3 location exists and is accessible. Please require storageAdapter.getSpiProperties() instanceof S3CompatibleFileSystemProperties before calling readPluginFormat() and cover the Azure file() case.
There was a problem hiding this comment.
Fixed in a1a26b6. readPluginFormat() now requires an S3-compatible binding before it hands the location over, and refuses any other binding with the message hdfs() and http() already get. The check is there rather than on file()'s path because s3() reaches it too: an s3.endpoint on *.blob.core.windows.net, or provider = azure, binds Azure in s3() as well.
PluginFileFormatTableValuedFunctionTest.azureStorageNeverReachesThePlugin covers both: file() with wasbs:// and Azure shared-key properties, and s3() with an Azure endpoint. Before the fix it fails with handed to the plugin: [s3://warehouse/test.lance with [AZURE]]; with the fix the plugin is never called. test_lance_s3_tvf also refuses the Azure file() case.
| ConnectorSession session = pluginFormat.buildSession(); | ||
| ConnectorMetadata metadata = PluginDrivenMetadata.get(session, pluginFormat.getConnector()); | ||
| pluginTableHandle = ((ConnectorFileSourceOps) metadata).getFileTableHandle(session, source); | ||
| columns = ConnectorColumnConverter.convertColumns( |
There was a problem hiding this comment.
[P2] Reject case-insensitive duplicate column names before exposing the plugin schema. I created and reopened a Lance dataset with top-level fields id and ID. This conversion keeps both, but the resulting FunctionGenTable.getColumn("id") and getColumn("ID") both return the second field. DESC FUNCTION can therefore advertise two columns that Doris cannot address independently. The 4.2 Lance TVF and the ordinary file TVF both reject this schema during analysis. Please share that uniqueness check with the plugin path and add a regression case that also verifies a single mixed-case name keeps its original spelling.
There was a problem hiding this comment.
Fixed in a1a26b6. fillColumns and the plugin path now share one check. It refuses a column whose name an earlier column already took, regardless of case, with the existing message (Repeated lowercase column names: id, as on 4.2). The plugin path keeps the plugin's spelling; a file's non-JSON columns are still lower-cased, as before.
Unit tests: columnsWhoseNamesDifferOnlyInCaseAreRefused fails before the fix and passes with it; mixedCaseColumnKeepsThePluginsSpelling; and S3TableValuedFunctionTest.testColumnNamesThatDifferOnlyInCaseAreRefused for the shared check on a file's columns.
Regression: test_lance_s3_tvf reads two new fixtures, built by lance_build_column_case.py with the pinned pylance 7.0.0:
column_case.lance(row_id,UserName): itsDESC FUNCTIONshowsUserName, andSELECT row_id, username ... WHERE USERNAME <> 'b'reads it.column_case_conflict.lance(id,ID): refused.
…ugin file formats
### Background
A file table function whose format a connector plugin serves, such as `s3("uri" = ..., "format" = "lance")`, hands its location and the storage it bound to the plugin, which resolves the dataset and gives the columns (`ExternalFileTableValuedFunction.readPluginFormat`). Only `s3()`, and `file()` over S3-compatible storage, hand a dataset over, because a plugin reads object storage by the S3 vocabulary. Doris resolves column names regardless of case, so the other paths that turn an external schema into Doris columns refuse two names that differ only in case: a file's columns (`Repeated lowercase column names`), a catalog table's schema, and branch-4.2's Lance table function.
### What problem does this PR solve?
Issue Number: apache#70680
Related PR: apache#70903 (review comments r4675740308 and r4675740314)
PR Type: Bugfix
Problem Summary:
Two gaps in the plugin path, both found by review:
1. Azure storage reached the plugin as an S3 location with no S3 storage. The gate checked the file type, and `s3()` reports `FILE_S3` for whatever it binds: `file()` hands Azure to `s3()`, and `s3()` binds an `s3.endpoint` on `*.blob.core.windows.net`, or `provider = azure`, as Azure too. The location was rewritten to `s3://container/path` (`wasbs://warehouse@demo.blob.core.windows.net/test.lance` became `s3://warehouse/test.lance`), and the Lance plugin, finding no S3-compatible storage, opened it with no storage options: no Azure endpoint, no Azure account, and no endpoint check. Lance then read S3 with whatever AWS settings the FE and BE processes carry: the read failed, or read another dataset where that S3 location exists and is reachable. Now `readPluginFormat` refuses a binding that is not S3-compatible, with the message `hdfs()` and `http()` already give: `Format lance is read only by the s3() table function, or by file() over S3-compatible storage`.
2. A plugin's columns whose names differ only in case were all exposed. For a Lance dataset with columns `id` and `ID`, `DESC FUNCTION` listed both, the table resolved either name to the second column, and a query naming either one failed as ambiguous. Now the plugin path refuses such a schema with the check a file's columns use, `Repeated lowercase column names: id`, as branch-4.2's Lance table function did. A single mixed-case name keeps the plugin's spelling.
### Details
- **Frequency:** Not observed in use; found by review. (1) needs `s3()` or `file()` with Azure storage and `"format" = "lance"`; (2) a Lance dataset with top-level names that differ only in case.
- **Root cause:** (1) The plugin-format gate in `parseCommonProperties` checked the file type, which `S3TableValuedFunction` reports as `FILE_S3` for any binding; nothing checked the binding. (2) `readPluginFormat` converted the plugin's columns as they came. The uniqueness check lived only in `fillColumns`, which reads a file's schema from a BE, and in the catalog schema cache, which a table function does not use.
- **Why existing tests missed it:** The plugin-format tests bound S3 storage only, and their mocked plugin returned distinct names; the Lance fixtures have lower-case, distinct names.
- **Fix:** (1) `readPluginFormat` requires an S3-compatible binding before it hands anything over. The file-type gate stays, so `hdfs()` and `http()` are refused before their storage is parsed. (2) `fillColumns` and `readPluginFormat` share one check (`addColumnLowerName`). The plugin path keeps the plugin's spelling; a file's columns other than JSON are lower-cased as before. Both messages are unchanged.
- **Other paths and branches:** Catalog tables already refuse such a schema when the schema cache loads it. branch-4.1 and branch-4.2 refuse the duplicate names in their Lance table function but have the Azure gap; they are not changed here.
### Testing
- `PluginFileFormatTableValuedFunctionTest.azureStorageNeverReachesThePlugin` (`file()` with `wasbs://` and Azure shared-key properties, `s3()` with an Azure endpoint) and `columnsWhoseNamesDifferOnlyInCaseAreRefused` fail without the fix (`handed to the plugin: [s3://warehouse/test.lance with [AZURE]] ==> Expected java.lang.RuntimeException to be thrown, but nothing was thrown.`, and no exception for `id` and `ID`) and pass with it. `mixedCaseColumnKeepsThePluginsSpelling` and `S3TableValuedFunctionTest.testColumnNamesThatDifferOnlyInCaseAreRefused` (the shared check on a file's columns) pass. With the other table function tests, the `PluginDrivenScanNode*Test` family and the plugin manager tests, 485 fe-core tests in 45 classes pass, with 0 Checkstyle violations.
- Regression: `test_lance_s3_tvf` refuses the Azure `file()`, shows `UserName` in the `DESC FUNCTION` of a new fixture and reads it as `username`, and refuses a fixture with `id` and `ID`. The two fixtures come from the new `lance_build_column_case.py` with the pinned pylance 7.0.0, whose `--check` passes. The 10 `external_table_p0/lance` suites pass locally on an FE built from this commit and a BE built from apache#70827's head, against a host S3 stand-in instead of MinIO; the generated `.out` adds only the two new blocks.
### Release note
None
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: the regression suites ran on macOS against a local S3 stand-in instead of the MinIO container, with a BE built from apache#70827's head (this PR changes no BE code)
### AI Disclosure
- Tool: Claude Code (Claude Opus 5.5)
- Generated: the code, the tests, the fixtures and this description
- Human review: not stated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a1a26b6
|
Addressed the code owner's review of cc88d51 in a1a26b6. Per finding:
The 10 Lance regression suites pass locally on an FE built from a1a26b6. |
|
run buildall |
| * resolves column names regardless of case, so two columns whose names differ only in case cannot be told apart. | ||
| */ | ||
| private static String addColumnLowerName(Set<String> columnLowerNames, String columnName) { | ||
| String colLowerName = columnName.toLowerCase(); |
There was a problem hiding this comment.
[P2] Use the same comparison for duplicate detection as Table.nameToColumn. I created and reopened Lance datasets and ran this helper against their schemas. With the FE default locale set to tr-TR, id and ID both pass because ID lowercases to ıd. With en-US, Σ and ς also both pass. In each case FunctionGenTable.getColumn() returns the second column for either spelling. Locale.ROOT alone still misses the Greek case. Could both callers track the original names in a TreeSet<>(String.CASE_INSENSITIVE_ORDER), keeping lowercasing of the displayed file column separate? A test with Σ and ς would cover the mismatch without changing the process locale.
There was a problem hiding this comment.
Fix this in another PR
### Background Master now plans Iceberg REWRITE file ordering from the write schema and uses Connector API 36.0 for the file-format SPI. ### What problem does this PR solve? Issue Number: None Related PR: apache#69032, apache#70615, apache#70903 PR Type: Build/CI/Chore Problem Summary: Integrate the upstream REWRITE path and distinguish spatial-aware plugins from plugins built for upstream API 36.0. ### Details - Affected: Validate REWRITE spatial writes against the schema resolved after beginWrite, before the sink is built. Use this same context for the upstream sort-order handling. - Developer and release impact: Set the combined Connector SPI to 37.0. - License and third-party: None. - Rollback: Reverting this merge restores the previous upstream baseline. ### Testing - IcebergWritePlanProviderTest, ConnectorPluginSurfaceTest and ConnectorMetadataSurfaceTest: 131 tests passed. - PluginApiVersionWiringTest: 14 tests passed. ### Notes for Reviewers The plugin-loading test exercises refusal of an upstream 36.0 plugin. ### Release note Rebuild Connector plugins for API 37.0. ### Check List (For Author) - Behavior changed: Connector plugins must declare the updated API. - Does this need documentation: Yes, update the PR compatibility note. - Pre-submission status: Targeted tests passed. ### AI Disclosure - Tool: Codex - Generated: Merge resolution, test expectation, and commit message. - Human review: Pending.
### Background Iceberg rewrite groups carry the resolved target file size through the connector SPI so each writer uses the operation's target. ### What problem does this PR solve? Issue Number: None Related PR: apache#70510 (writer target), apache#70616 (oversized rewrite groups), apache#70903 (connector file format SPI) PR Type: Build/CI/Chore Problem Summary: Both branches added procedure tests at the same location and independently reserved connector plugin API 36. Merge their test coverage and reserve the next API major for the combined plugin surface. ### Details - **Affected:** The procedure test retains the oversized-file case and both writer-target cases. The connector parent POM and frozen version assertion advance to 37.0. - **Developer and release impact:** Plugins targeting API 36 do not declare the new rewrite-group surface. Connector artifacts built with this change use API 37. - **License and third-party:** None. - **Rollback:** Revert the writer-target PR if reverting the feature. ### Testing Checkstyle 9.3 passed on all eight Java files in the PR. The connector import and FE metadata funnel gates passed. A static comparison confirmed all test methods from both parents are present, the metadata surface matches master, and the plugin surface contains master's baseline plus the six rewrite-group methods. The POM version and test pin agree. The PR diff passed the whitespace check. Local compilation and runtime tests were skipped per request. ### Release note Connector plugins must target API 37.0 for the combined rewrite-group SPI. ### Check List (For Author) - Behavior changed: Yes (see Details). - Does this need documentation: No. - Pre-submission status: Partially verified, pending remote build and tests. ### AI Disclosure - Tool: Codex. - Generated: Merge resolution, static verification and commit message. - Human review: Pending.
### Background The frontend loads plugins built for its connector API version. Master assigned 36.0 to the file format SPI while the Iceberg partition row estimates in this branch independently advanced the same version. ### What problem does this PR solve? Issue Number: None Related PR: apache#70016 (partition row estimates), apache#70903 (file format SPI) PR Type: Build/CI/Chore Problem Summary: Merge master into the partition estimates branch. Pin the combined API to 37.0 so plugins can distinguish the new partition surface. ### Details - **Affected:** The connector parent POM and the plugin API surface test. - **Developer and release impact:** Rebuild external connector plugins against API 37.0 when deploying an FE with the new partition surface. - **License and third-party:** None. - **Rollback:** Reverting the partition statistics SPI changes together with this version bump restores the master connector contract. ### Testing Checkstyle 9.3 passed on all 13 changed Java files. Both FE connector architecture scripts passed. A source check verified the ordered union of both plugin method baselines and the unchanged metadata method baseline. ### Release note Connector plugins built for the API with partition row estimates use connector plugin API 37.0. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Partially verified: local compilation was skipped at the author's request. Remote checks cover compilation and runtime tests. ### AI Disclosure - Tool: OpenAI Codex - Generated: Merge conflict resolution, static verification and commit message - Human review: Pending
Background
A Lance dataset is a directory of versioned manifests that list its fragments (data files) and indexes. branch-4.1 (since 4.1.4) and branch-4.2 read one with
s3("uri" = ..., "format" = "lance"): the FE opens the dataset, pins its newest version and plans one range per fragment. On master, Lance lives in thefe-connector-lanceplugin, which serves Lance catalogs (#70681, #70725, #70827). The file table functions (s3(),file(),hdfs(), ...) read only the formats of a closed list in fe-core: the FE lists the files and the BE's file readers read them.What problem does this PR solve?
Issue Number: #70680
Related PR: #70830 (builds on it), #70827 (the pushdown this scan reuses), #65730, #66805, #67325, #67921, #68078 (the branch-4.x implementation this ports)
PR Type: Feature
Problem Summary:
Users who read Lance datasets with
s3()on 4.1.4 and 4.2 get an error on master, because fe-core no longer knows the format. This PR lets a connector plugin serve a format to the file table functions:s3(), andfile()over S3-compatible storage, hand the dataset's location and storage to the plugin, which pins the newest version, gives the columns, and plans the scan through the scan node of catalog tables, pushdown included. The Lance plugin serveslance. Half of the diff is tests. The branch also carries three review fixes for the Lance plugin, each in its own commit. Other formats and table functions are unchanged.ERROR 1105 (HY000): errCode = 2, detailMessage = Can not build s3(): format:lance is not supported.12 78Details
Change map: The feature commit is +2043 −69 in 37 files, more than half of it tests: unit tests +613, two regression suites with a fixture builder +341, their generated
.out+116, and a 5 KB Lance fixture copied from branch-4.2. The production code is +967 −63, in three parts, in reading order:ConnectorProvider#getFileFormatsand#createFileFormatConnector,ConnectorFileSource,ConnectorFileSourceOps; connector plugin API 35.0 -> 36.0 with its surface baseline.ConnectorPluginManager,PluginFileFormat);ExternalFileTableValuedFunctionandS3TableValuedFunctionhand the location to the plugin and scan withPluginDrivenScanNode; two smallPluginDrivenScanNodefixes for a table that belongs to no catalog (Notes for Reviewers).LanceFileFormatConnector,LanceFileMetadata,LanceFileTableHandle, andLanceScanPlanProvidersplit by where the metadata comes from (CatalogSource, the old behavior;FileSource, the new one).The two commits before it hold the carried review fixes (+248 −194); the two after it fix this PR's first two reviews (+105 −13 and +60 −10).
Scope:
s3(), andfile()over S3-compatible storage. The uri is the dataset root: nothing is listed and no glob applies. The statement reads the version that is newest when it is analyzed.DESC FUNCTIONshows the columns as a Lance catalog does. Predicates, LIMIT andCOUNT(*)are pushed as for a catalog table; the 4.x table function pushed none. Read only:INSERT INTO s3(...),OUTFILE ... FORMAT AS lanceand routine load still fail withformat:lance is not supported..hdfs()andhttp()refuse the format, as on 4.x, and so dopath_partition_keysand a streaming job's file list.local()is out: master disables it for every format ([fix](fe) Disable LOCAL TVF #69591).Design: A plugin declares its formats (
ConnectorProvider#getFileFormats()) and builds, for each, a connector that belongs to no catalog (createFileFormatConnector). Its metadata implementsConnectorFileSourceOps#getFileTableHandle(session, ConnectorFileSource), which resolves the location and storage to a table handle and pins the version; from there the engine uses the existing interfaces, as thequery()table function does:getTableSchemafor the columns,PluginDrivenScanNodefor the scan. fe-core claims format names when it admits a plugin: case-insensitive, one plugin per name, and the formats the engine reads itself are reserved. A format's connector is built on first use, kept for the life of the FE, and given a negative catalog id, which no catalog has, so its per-statement state stays apart. Rejected: a narrowTVFScanNodeinterface returning a schema and splits, which would duplicate the plugin scan node's range and storage plumbing and lose the pushdown. Not discussed publicly; [Feature][Lance] Serve Lance catalogs on master through a connector plugin #70680 lists this as a follow-up.Usage:
EXPLAIN of the second statement:
Default behavior: Available whenever the Lance plugin is installed, as the FE package does by default.
Compatibility: FE only: the ranges carry the same
TLanceFileDescandTLanceScanParamsas a catalog scan, so neither the BE nor thrift changes. A column of the types the BE reader added in 4.2 keeps a smooth-upgrade source BE out of the scan, as for a catalog table. Plugins built for API 35.0 are refused by the version gate, as after every SPI change. Nothing is persisted.Security and privileges: The FE reads the dataset's manifest and fragment list at the endpoint the user names, with the user's credentials: the request
s3()already makes to list files, behind the same gate, which runs before the plugin opens anything (s3_load_endpoint_white_list, and the SSRF check whensecurity_checker_class_nameis set). The privilege is that ofs3(): none beyond running the query, USAGE when aresourceis named. Credentials stay out of EXPLAIN, the handle'stoStringand error messages.Carried review fixes:
535b9085a51, #70830 r4661513530). A dataset deleted and written again at the same URI with V1 manifest names kept a stale index list after REFRESH TABLE, and the BE refused filtered scans (scalar index segment ... is absent from the dataset snapshot); lance-core 12's JavaSessioncannot drop one URI's entries. Cost: REFRESH TABLE drops the catalog's cached Lance metadata, where branch-4.x rotates the Session only on REFRESH CATALOG.535b9085a51, #70830 r4665616715): a namespace vending a new token per describe grew the shared Session's object-store registry without bound.planScanno longer serializes the pushed Substrait filter (ec723b4f2e5, #70827 r4656423962): the conversion is lazy.Follow-up plan: The Lance search table functions, index DDL and inspection, and tag and branch versioning follow in their own PRs ([Feature][Lance] Serve Lance catalogs on master through a connector plugin #70680).
Testing
PluginFileFormatTableValuedFunctionTest(8 cases) drivess3(),file(),hdfs()andhttp()against a mocked plugin: the endpoint gate runs first and a refused endpoint never reaches the plugin, nothing is listed, the plugin gets the normalized location and storage, the columns are its own, the scan and its EXPLAIN go throughPluginDrivenScanNode, a predicate reaches the plugin while the statement holds an internal table's plan read lock, and the refusals hold.ConnectorPluginManagerTestcovers the claims. With the other table function tests, thePluginDrivenScanNode*Testfamily andPluginDrivenMissingTableTest, 479 fe-core tests in 45 classes pass.fe-connector-spi: its 166 tests, with the new surface baseline and API 36.0.LanceFileFormatNativeTest: the pinned version holds after a newer commit, the table function's storage goes into the scan and stays out of EXPLAIN, filter andCOUNT(*)are pushed, the added types raise the upgrade fence, a missing dataset fails with a message.NullPointerException), the unguarded cast (FunctionGenTable cannot be cast to class PluginDrivenExternalTable), the endpoint gate skipped, an engine format claimable, and the version pin dropped.external_table_p0/lancesuites, the two new ones included, pass on an FE built from this branch and a BE built from [feature](lance) Push predicates, LIMIT and COUNT(*) into Lance scans #70827's head, against a host S3 stand-in and the REST stub instead of MinIO. The 7 result blocks ported from branch-4.2's.outare identical; the new blocks (EXPLAIN, pushdown,COUNT(*)over three fragments with deletions,file(),INSERT ... SELECTinto an OLAP table, a join with one, the refusals) match what pylance 7.0.0 reads from the same fixtures.ConnectorPluginManagerTest.classpathProviderWhoseFileFormatsThrowIsSkippedNotFatalandpluginWhoseFileFormatsThrowIsSkippedNotFatalfail on the feature commit withUnexpected exception thrown: java.lang.IllegalStateException: the connector could not list its file formatsand pass with it; the fe-core tests above, now 481 in 45 classes, pass.LanceScanPlanProviderTest.fileTableFunctionsOfOneUriOnTwoEndpointsCountTheirOwnDatasetsplansCOUNT(*)for two table functions on one uri at one version with two endpoints, one dataset of 1 row and one of 2. On the fourth commit it fails withexpected: <2> but was: <1>; with the fifth it passes, and so do the plugin's other 264 tests.git range-diffall=). The new base changes no file of the plugin, the SPI, the Lance suites or their fixtures; on this path it changes only the generic pipeline-task and TLS code. The unit tests above ran on the rebased branch; the mutations and the regression suites did not run again.Notes for Reviewers
getFileFormats()throws instead of stopping FE startup (review comment r4668526070), and the fifth gives each table function its own entry in the statement's metadata memo (review comment r4671691836).PluginDrivenScanNodeassumed a catalog table in two places that a table function's table (no database, no catalog) broke: EXPLAIN readgetDatabase().getCatalog(), andconvertPredicatecast the table toPluginDrivenExternalTablewhenever the statement also held an internal table (a join, orINSERT INTO olap_table SELECT ...).ConnectorFileSourcehands over no other table function properties: they cannot be told apart from storage keys reliably, and passing them would copy the credentials again.Release note
s3(), andfile()over S3-compatible storage, read Lance datasets with"format" = "lance"as on 4.1 and 4.2, and now push predicates, LIMIT andCOUNT(*)into the scan.Check List (For Author)
s3()andfile()pages need"format" = "lance"for releases built from master; a doris-website PR follows)AI Disclosure
"format" = "lance"file table function to master as the next Lance task, on a branch stacked on [improvement](lance) Reuse Lance metadata across queries and show its FE time in the profile #70830.s3()andfile()over S3 hand over a data set; keep the pushdown the catalog scan already has.