Repository navigation
Conversation
| schema: | ||
| type: string | ||
| enum: | ||
| - vended-credentials | ||
| style: simple | ||
| explode: false | ||
| example: "vended-credentials" |
There was a problem hiding this comment.
| schema: | |
| type: string | |
| enum: | |
| - vended-credentials | |
| style: simple | |
| explode: false | |
| example: "vended-credentials" | |
| schema: | |
| type: array | |
| items: | |
| type: string | |
| enum: | |
| - vended-credentials | |
| example: "vended-credentials" |
| Storage configurations required to access the directory, encompassing both credentials and other necessary | ||
| settings for storage access, such as the client region for S3. | ||
| items: | ||
| $ref: './generic-tables-api.yaml#/components/schemas/StorageAccessConfig' |
There was a problem hiding this comment.
Would be worthwhile extracting this schema to a common set of schemas for various APIs, rather than referencing the generic-tables API spec directly?
|
|
||
| ### Credential vending | ||
|
|
||
| The directory table might contain additional fields for credential vending. |
There was a problem hiding this comment.
I would like to understand how we envision credential vending.
Right now, if the spec was live, clients could request vended credentials for the inventory table, but would necessarily have to be in possession of their own storage credentials, in order to access the actual data.
I think it would be a real added-value if Polaris could also be the governing entity that grants access to the remote files, via some form of credential vending.
It's too soon to sort out the details, but my gut feeling is that we'll need a form of "fast authz checks", similar to what was proposed in #3995 for remote signing. In which case, it's likely that the inventory table would have to store some encrypted payload that will be used later for generating the storage credentials.
There was a problem hiding this comment.
I added a note related to credential vending in the description for now.
4400916 to
2a5338b
Compare
orca-review-bot
left a comment
There was a problem hiding this comment.
Nice to see this follow the generic-table path closely, with scan off by default and replaceable through an SPI. Main asks are inline: the drop authz target, the SPI default method, pagination, and the inventory files ending up in their own scan.
Unanchored items:
- Tests: no handler authz test like GenericTableCatalogHandlerAuthzTest. Can we add allow/deny cases for each directory op, plus a read-only principal getting 403 on scan/drop in PolarisDirectoryServiceIntegrationTest?
- Tests: can we cover ENABLE_DIRECTORY_SCAN=false (scan rejected, not in /v1/config) and ENABLE_DIRECTORIES=false?
- CHANGELOG: can we mark Directories as beta and say ENABLE_DIRECTORIES defaults to true, since every catalog config now lists the endpoints?
- PR metadata: can we add a
feat:title prefix and link an issue or the dev-list thread? - Docs: can directories.md say that dropping or writing the inventory table through the Iceberg API breaks the directory?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| public boolean dropDirectory(TableIdentifier identifier) { | ||
| this.inventoryTable = inventoryTableIdentifier(identifier); | ||
| PolarisAuthorizableOperation op = PolarisAuthorizableOperation.DROP_TABLE_WITHOUT_PURGE; | ||
| authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier); |
There was a problem hiding this comment.
Drop checks DROP_TABLE_WITHOUT_PURGE on the parent namespace, not on the directory. Generic tables check the leaf (resolveAndAuthorizeBasicTableLikeOperationOrThrow in GenericTableCatalogHandler). Two effects: a TABLE_DROP grant on the directory itself does nothing, and an external authorizer sees a namespace target, so a per-directory deny won't apply. Can we switch to the leaf helper with PolarisEntitySubType.DIRECTORY?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| * @return the initialized catalog | ||
| * @throws IllegalStateException if the connection configuration is invalid | ||
| */ | ||
| DirectoryCatalog createDirectoryCatalog( |
There was a problem hiding this comment.
Adding an abstract method to this SPI breaks every out-of-tree FederatedCatalogFactory at compile time. Every in-tree implementation just throws UnsupportedOperationException anyway. Can this be a default method that throws, so we can drop the three overrides and their TODOs?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| public Response listDirectories( | ||
| String prefix, | ||
| String namespace, | ||
| String pageToken, |
There was a problem hiding this comment.
pageToken/pageSize are accepted here but never passed down, and PolarisDirectoryCatalog always uses PageToken.readEverything(). So a namespace with many directories returns one unbounded page. Can we follow GenericTableCatalogHandler.listGenericTables (PageToken.build + rejectIncompleteListing + setNextPageToken)?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| List<Pattern> excludePatterns = compile(exclude); | ||
|
|
||
| List<Record> records = new ArrayList<>(); | ||
| for (FileInfo file : prefixIO.listPrefix(baseLocation)) { |
There was a problem hiding this comment.
This lists everything under the base location, including the inventory table's own files when they live under it. That happens with allow.unstructured.table.location=true and a base location above the namespace location. Old data files stay on storage after an overwrite, so each rescan also indexes the Parquet and metadata files from earlier scans. Can we skip table.location() here, or reject that layout at create time?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| throw new NoSuchNamespaceException("Namespace does not exist: %s", identifier.namespace()); | ||
| } | ||
| // The base location is read with vended credentials: it must be within the allowed locations | ||
| CatalogUtils.validateLocationsForTableLike( |
There was a problem hiding this comment.
Unlike table create, this doesn't run the location-overlap check (LocalIcebergCatalog.validateNoLocationOverlap, gated by ALLOW_TABLE_LOCATION_OVERLAP). So a directory can point at a sibling table's location, and a scan writes that table's file names and sizes into an inventory the caller can read. Is that intended, or should directories get the same overlap check?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| this.icebergCatalog.dropTable(tableId, false); | ||
| LOGGER.debug("Dropped associated Iceberg table {} for directory {}", tableId, identifier); | ||
| } catch (Exception e) { | ||
| LOGGER.error("Failed to drop associated Iceberg table for directory {}", identifier, e); |
There was a problem hiding this comment.
Log-then-rethrow: the exception gets logged here and again by the framework. Can we drop the try/catch?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
|
|
||
| // Check that the inventory table name does not collide with an existing entity | ||
| TableIdentifier tableId = inventoryTableIdentifier(identifier); | ||
| if (this.icebergCatalog.tableExists(tableId)) { |
There was a problem hiding this comment.
This pre-check races with a concurrent createTable of <dir>__inventory. The rollback below already handles the case where createTable fails. Can we drop the pre-check and rely on the AlreadyExistsException from createTable?
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
| } | ||
| } | ||
|
|
||
| private static List<Pattern> compile(List<String> regexes) { |
There was a problem hiding this comment.
Filters are only compiled at scan time, so a bad regex is accepted on create and only fails on the first scan. Can we compile them in createDirectory and reject bad ones there? Capping pattern count and length would also limit backtracking cost.
🤖 AI-generated review comment — agents make mistakes, so please verify before acting on it.
…data) on object stores Directories allow users to point Polaris at a location/prefix on an object store (S3, GCS, Azure) containing objects (including unstructured data like images, videos, documents) and automatically track the objects via an Iceberg table with objecr-level metadata (location, size, content type, checksum, last modified, etc.). When a directory is created, Polaris stores the directory configuration (name, location, scan filters, scan schedule) as a DIRECTORY entity and also creates an associated Iceberg table with the predefined schema.
…ase_location, fix ENABLE_DIRECTORIES doc
…irectory scan dependencies
- Name the inventory table <directory>__inventory: a directory and a table cannot share a name, so creating the table always failed and rolled back - Register the inventory table as a passthrough resolution path - Validate base_location against the allowed locations on create and scan - Let the scan use FileIO wrapped by ExceptionMappingFileIO - Add a REST end-to-end test for the directory create, scan and drop flow
When the overwrite commit fails with CommitStateUnknownException, the commit may have landed: deleting the new Parquet file could leave the inventory snapshot pointing to a missing file, breaking every read of the inventory. Rethrow the exception without deleting the file, as Iceberg's SnapshotProducer does.
The built-in scan is synchronous: it runs inside the request and keeps the listing in memory, so it is not suited to large directories yet. ENABLE_DIRECTORY_SCAN is now false by default, so users who enable it know they run a synchronous scan. The directory integration test enables the scan with a dedicated test profile, and the regtests no longer expect the scan endpoint in the catalog configuration.
Replace the speculative credential vending section with the current behavior: the directory table lists the objects but does not give access to them. Vended credentials are scoped to the directory table location, privileges on the directory or its table don't cover the base location, and the scan credentials never leave the server.
Authorize directory drop on the directory itself, paginate directory listing, validate filter regexes on creation, skip the inventory table files during a scan, make FederatedCatalogFactory.createDirectoryCatalog a default method, and add authorization, endpoint and read-only principal tests. Mark Directories as beta.
… schema Apply the sibling location overlap check to the directory base location on creation, and move StorageAccessConfig to a common schemas file referenced by the generic tables and directories specs.
|
As discussed during the Community Meeting, I will split this in three PRs:
|
dimas-b
left a comment
There was a problem hiding this comment.
Reviewing only the API part since, as we discussed, in the community sync today, this PR is going to be split, I think.
The API LGTM with some minor comments below 👍
| paths: | ||
| /polaris/v1/{prefix}/namespaces/{namespace}/directories: | ||
| parameters: | ||
| - $ref: '../iceberg-rest-catalog-open-api.yaml#/components/parameters/prefix' |
There was a problem hiding this comment.
non-blocking: I do not think yaml cross-references are convenience for downstream users. If someone wants to copy this API definition to generate clients, the IRC spec has to be copied too, but the IRC spec does not appear to be a conceptual prerequisite to the Directories spec.
Also (perhaps more critical): changes to IRC spec do not have to automatically trickle down to the directories spec, IMHO. It may be a weak point with respect to these two parameters, but in general I think it makes sense 🤔
| operationId: listDirectories | ||
| parameters: | ||
| - $ref: '../iceberg-rest-catalog-open-api.yaml#/components/parameters/page-token' | ||
| - $ref: '../iceberg-rest-catalog-open-api.yaml#/components/parameters/page-size' |
There was a problem hiding this comment.
Aside from yaml cross-references, I do not think pagination parameters are defined with due rigour in IRC. Specifically, the treatment of empty page tokens and defauting to "all". I think it would be nicer to define pagination locally in a Polaris spec.
|
|
||
| --- | ||
| paths: | ||
| /polaris/v1/{prefix}/namespaces/{namespace}/directories: |
There was a problem hiding this comment.
Non-blocking: this path prefix interleaves with other Polaris API (e.g. Generic Tables, Policies...). Since endpoints are distinct, it is not a problem. However, it makes separating APIs more difficult.
The v1 prefix is shared and it is usually perceived as the "API root".
There is no static prefix just for the directories API, which can complicate network routing if someone wants to segregate traffic by API.
I know this fit the existing pattern, so my comment is non-blocking 😅
|
|
||
| @ApplicationScoped | ||
| @Priority(350) | ||
| public class DirectoryConfigEndpoints implements CatalogConfigEndpointContributor { |
There was a problem hiding this comment.
I'm not sure what we gain by exposing Directory endpoints in the IRC config.
Previous discussion on this topic identified only a very narrow use case for Spark Clients discovering Generic Tables:
Do we expect a Directories API client to check IRC config for the presence of Directory endpoints?
| ConnectionConfigInfoDpo connectionConfig, | ||
| PolarisCredentialManager polarisCredentialManager, | ||
| Map<String, String> catalogProperties) { | ||
| throw new UnsupportedOperationException("Directory federation is not supported."); |
There was a problem hiding this comment.
This is awkward... why should a "federated" Catalog Factory care about Directories at all? It does not look like we have any support for Directories in Federated catalogs ATM 🤔
|
|
||
| public static final FeatureConfiguration<Boolean> ENABLE_DIRECTORY_SCAN = | ||
| PolarisConfiguration.<Boolean>builder() | ||
| .key("ENABLE_DIRECTORY_SCAN") |
There was a problem hiding this comment.
Do we need a flag for this? It could be disabled via the Authorizer, I guess 🤔
| "credentials"); | ||
| } | ||
|
|
||
| public String directories(Namespace ns) { |
There was a problem hiding this comment.
This is used only in tests. Could we move it to test utilities?
| "polaris/v1/{prefix}/namespaces/{namespace}/generic-tables/{generic-table}"; | ||
|
|
||
| // Directory endpoints | ||
| public static final String V1_DIRECTORIES = |
There was a problem hiding this comment.
Why not keep it in DirectoryEndpoints for better feature isolation?
| federatedCatalog = | ||
| federatedCatalogFactory | ||
| .get() | ||
| .createDirectoryCatalog( |
There was a problem hiding this comment.
This call always throws, does it not? 🤔
| // The scan exposes the names and sizes of the objects under the base location: it must not | ||
| // overlap the location of a sibling table, view, directory or namespace | ||
| ((LocalIcebergCatalog) icebergCatalog) | ||
| .validateNoDirectoryLocationOverlap( |
There was a problem hiding this comment.
@adutra : could review from the recent location check improvements perspective?
| identifier, baseLocation, resolvedParent.getRawFullPath()); | ||
|
|
||
| DirectoryScanner.validateFilters(parseJsonArray(filterInclude), parseJsonArray(filterExclude)); | ||
| TableIdentifier tableId = inventoryTableIdentifier(identifier); |
|
|
||
| @QuarkusTest | ||
| @TestProfile(Profiles.DefaultProfile.class) | ||
| public class PolarisDirectoryCatalogRelationalTest extends AbstractPolarisDirectoryCatalogTest {} |
There was a problem hiding this comment.
What makes it "relational"? Did you mean RelationalJdbcProfile? 🤔
| implementation("org.apache.iceberg:iceberg-core") | ||
| implementation("org.apache.iceberg:iceberg-data") | ||
| implementation("org.apache.iceberg:iceberg-parquet") | ||
| implementation(libs.parquet.hadoop) |
There was a problem hiding this comment.
Could we put Directories impl. code into a separate module to avoid these new deps in runtime/service?
This is our usual practice to avoid automatically pushing new feature deps to downstream servers. Pretty much all downstream servers have to depend on runtime/service. Ideally optional features should only be bundled in runtime/server to allow downstream project to opt in/out.
|
Heads-up: #5967 has been merged, so Could you rebase onto |
Directories allow users to point Polaris at a location/prefix on an object store (S3, GCS, Azure) containing objects (including unstructured data like images, videos, documents) and automatically track the objects via an Iceberg table with object-level metadata (location, size, content type, checksum, last modified, etc.).
When a directory is created, Polaris stores the directory configuration (name, location, scan filters, scan schedule) as a DIRECTORY entity and also creates an associated Iceberg inventory table with the predefined schema. The table is named
<directory>__inventory, because a directory and a table cannot share a name in a namespace (both are table-like entities).Location validation
base_locationis validated like a table location, on creation and again before each scan: it must be within the catalog's allowed locations, and within the namespace location unlesspolaris.config.allow.unstructured.table.locationistrueon the catalog.Scan service
A simple scan endpoint populates the directory table:
POST /v1/{prefix}/namespaces/{namespace}/directories/{directory}/scanbase_location(with read/list credentials scoped to that location), applies the include/exclude filters, and replaces the table content with a Parquet data file in a single overwrite commit. A failed scan leaves the table unchanged; if the commit state is unknown, the new data file is kept, as the commit may have landed.file_uri,content_type(guessed from the file name),sizeandlast_modified; the other columns are left empty.UPDATE_TABLEon the directory and aFileIOthat supports listing a prefix.ENABLE_DIRECTORY_SCANfeature flag: the scan is synchronous and keeps the listing in memory, so it is not suited to large directories yet. When disabled, the endpoint is rejected and not advertised in the catalog config.scan-schedulestays informational, so periodic scans are left to the caller or an external scheduler.DirectoryScanServiceSPI: the built-in implementation is a@DefaultBean, and an extension can replace it with its own CDI bean (for example to compute checksums or update the table incrementally).iceberg-data,iceberg-parquetandparquet-hadoop(same Parquet version already on the runtime classpath) to the runtime service.Notes for reviewers
DirectoryServiceIntegrationTest). It was also tested manually on S3. It has not been tested on GCS or Azure yet.directories.md.Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed)