morningman commented on code in PR #71125:
URL: https://github.com/apache/doris/pull/71125#discussion_r4736465010
##########
fe/fe-connector/fe-connector-lance/src/main/java/org/apache/doris/connector/lance/LanceNamespaceClient.java:
##########
@@ -242,10 +244,124 @@ private CachedTableAccess
describeTableAccess(List<String> tableId, String dbNam
// BE through lance-c, so neither can end up with credentials the
other lacks. The dataset URL picks
// the option vocabulary, the same way Lance picks a provider from it.
Map<String, String> vendedOptions = table.getStorageOptions();
- LanceTableAccess access = new LanceTableAccess(datasetUri,
-
LanceStorageOptions.fromDorisAndVendedStorageOptions(datasetUri,
storageProperties, vendedOptions),
- vendedOptions != null && !vendedOptions.isEmpty());
- return new CachedTableAccess(access, cacheTtlNanos(access));
+ Map<String, String> storageOptions =
+
LanceStorageOptions.fromDorisAndVendedStorageOptions(datasetUri,
storageProperties, vendedOptions);
+ boolean vended = vendedOptions != null && !vendedOptions.isEmpty();
+ if (!Boolean.TRUE.equals(table.getManagedVersioning())) {
+ LanceTableAccess access = new LanceTableAccess(datasetUri,
storageOptions, vended);
+ return new CachedTableAccess(access, cacheTtlNanos(access));
+ }
+ // The namespace decides which versions exist; the FE and the BE both
read one of them by URI, which is
+ // all lance-c supports. The manifest paths the namespace records are
object-store paths under
+ // `location`, so `table_uri` must name the same place; it may add a
query, such as presigned
+ // credentials, which Doris then opens it with.
+ if (StringUtils.isBlank(table.getLocation())) {
+ throw new DorisConnectorException("Lance namespace returned no
location for managed table " + tableId);
+ }
+ // An s3+ddb URI commits through DynamoDB, whose handler records and
finalizes versions itself, even on
+ // read; the namespace already decides the versions of a managed table.
+ if (StringUtils.startsWithIgnoreCase(datasetUri, "s3+ddb:")) {
+ throw new DorisConnectorException("Lance namespace returned an
s3+ddb URI for managed table " + tableId
+ + ", whose versions the namespace manages");
+ }
+ if (StringUtils.isNotBlank(table.getTableUri())
+ &&
!withoutQuery(table.getTableUri()).equals(withoutQuery(table.getLocation()))) {
Review Comment:
Thanks, reproduced: with the same `#meta` on both fields, `@branch(dev)` of
a managed table read main's version 3 (6 rows in our test fixture, where dev's
version 3 has 4). c4f624f699a refuses such a table at `DescribeTable` with
branch-4.2's check from #69384 and its message (`Lance managed table URI must
not contain a fragment: ...`). It checks the URI Doris opens, so a fragment on
`table_uri`, or on `location` when there is no `table_uri`, is refused; a
fragment on `location` alone still fails as a `table_uri` that differs from
`location`. `LanceManagedAccessTest.managedTableUriMustNotCarryAFragment`
covers both fields with the same fragment and the other cases. branch-4.1
doesn't have #69384, so it still accepts such a URI.
##########
fe/fe-connector/fe-connector-lance/src/main/java/org/apache/doris/connector/lance/LanceScanPlanProvider.java:
##########
@@ -402,17 +413,17 @@ public LanceTableMetadata metadata(ConnectorSession
session, ConnectorTableHandl
LanceMetadataMetrics metrics) {
LanceTableHandle table = lanceHandle(handle);
return LanceStatementScope.sharedMetadata(session, table,
- () -> client.loadTableMetadata(table.getDbName(),
table.getTableName(), table.getVersion(),
- metrics));
+ () -> client.loadTableMetadata(table.getDbName(),
table.getTableName(),
+ LanceRefSelector.of(table), metrics));
}
@Override
public LanceIndexMetadata indexMetadata(ConnectorSession session,
ConnectorTableHandle handle,
LanceTableMetadata metadata, LanceMetadataMetrics metrics) {
LanceTableHandle table = lanceHandle(handle);
return LanceStatementScope.sharedIndexMetadata(session, table,
metadata,
- () -> client.loadIndexMetadata(table.getDbName(),
table.getTableName(), metadata.getVersion(),
- metrics));
+ () -> client.loadIndexMetadata(table.getDbName(),
table.getTableName(), metadata.getBranch(),
Review Comment:
Agreed, done in d37ebf0b795 as you suggest: `loadIndexMetadata` now takes
the pinned `LanceTableMetadata` and opens its dataset with its
`LanceTableAccess`, at its version, without describing the table again; both
callers (scan planning and the search functions' field ids) pass it. The index
segments and the fragments now always come from one dataset, a managed table's
index read no longer bypasses the namespace's checks, and a branch is opened by
the URI the BE reads instead of being joined again. This also removes the
second describe that #70827 left for tables with vended credentials.
`LanceSharedSessionNativeTest.indexesAreReadFromTheDatasetTheMetadataWasReadFrom`
moves the table between the two reads (it read `moved_idx` before the fix) and
asserts a single describe; `indexesOfABranchAreReadFromTheBranch` covers a
branch with its own index.
--
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]