Repository navigation
[CXH-2723] - Add Unity Catalog table and volume sync - Databricks Connector - #73
Conversation
920df46 to
f9142b4
Compare
0ee9040 to
38e403e
Compare
f9142b4 to
29274ee
Compare
38e403e to
7c8e7a3
Compare
29274ee to
e74210e
Compare
7c8e7a3 to
a3bd512
Compare
e74210e to
7deff05
Compare
a3bd512 to
5dce9b1
Compare
7deff05 to
1253d7e
Compare
5dce9b1 to
5effb3f
Compare
FeliLucero1
left a comment
There was a problem hiding this comment.
Did a pass on this one. Main things: the per-table perf (the stack-wide one actually bites here), the List/Revoke 404 handling copied from #72, and the table_type mapping dropping REFRESH / ALL_PRIVILEGES grants from the sync. The rest are nits.
Comments tagged (out of scope) are inherited or stack-wide, so treat them as FYI, not blocking for this PR. Build/vet/tests pass locally.
d10a7e9 to
a03b5a6
Compare
b704b02 to
f63db64
Compare
a03b5a6 to
47a3e98
Compare
f63db64 to
068e05d
Compare
47a3e98 to
acfcba8
Compare
FeliLucero1
left a comment
There was a problem hiding this comment.
Round 7. Nice: the single-schema GET fixes the O(schemas²), the walks now continue (with two-workspace tests), and volumes confirm the generic 404. CI green. One thing I'd still want before merge: the gone codes trusted from a single workspace (inline on volume.go:61/81).
(out of scope, #71) the catalog is still emitted once per bound workspace (catalog.go:225-238, no dedupe), so its whole subtree gets listed W times, Sergio's perf point. FYI on the trait split: per c1 (uplift_app.go), only TRAIT_APP resources become child apps, so not having it on 100k tables is actually a plus. Dropping it from all five like you asked ggreer sounds good to me.
068e05d to
fbc1394
Compare
101ce0f to
d5596f4
Compare
34cecee to
9b8a7aa
Compare
Listing a schema's tables or volumes resolved its route on the first page, once per child type, and schemaThrough found the schema by paging the whole catalog's schema listing. That is one full listing walk per schema per child type: a catalog with 1,000 schemas spends about 21,000 listing requests, and 43,000 requests in all, before the first table is listed. The uhttp GET cache hid it while a catalog's listing fit in the 5 MB it holds by default, which a catalog of 30 KB schema rows does not. schemaThrough now reads the one schema it needs. The same catalog costs 2,000 schema reads instead, and the cost is linear in the schema count rather than quadratic. Error classification is unchanged. A 404 naming SCHEMA_DOES_NOT_EXIST is read exactly like a schema absent from the listing was: proof of deletion only for a caller that sees the whole catalog, since Databricks answers the same way for a schema the caller merely cannot see. Every other refusal, including a 404 carrying no code, still leaves the schema unknown rather than absent -- read as an empty result the SDK would skip the children and ConductorOne would delete every table and volume under the schema. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Listing a schema's tables or volumes returned the catalog read's error for every refusal, where the schema syncer walks on to the next workspace. A catalog bound to one workspace of several is answered by the others with a 404, and which of the two answers Databricks gives decides which way this breaks. A 404 carrying no error code reached the SDK as codes.NotFound, which it reads as a warning: the listing finished green with no resources and ConductorOne deleted every table and volume under the schema. A 404 naming CATALOG_DOES_NOT_EXIST raised errCatalogGone, which failed the whole sync. Both now continue the walk, matching the schema syncer. A catalog every workspace names as gone, with none refusing the read, empties the listing: the catalog syncer drops it in the same sync. A refusal still fails the sync and keeps what ConductorOne already has. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…hildren
schemaThrough classified every refusal of the single-schema read with
schemaListingError, which maps CATALOG_DOES_NOT_EXIST to codes.NotFound.
The SDK reads NotFound from a List as a warning, not a failure: isWarning
(sync/syncer.go) returns true for it and syncOneAction
(sync/parallel_syncer.go) logs "skipping sync action" and carries on. The
listing then completes having emitted nothing and ConductorOne deletes
every table and volume under that schema.
A parent-catalog 404 is a real answer there: measured on the tenant,
GET /schemas/{full} returns CATALOG_DOES_NOT_EXIST once the catalog is
dropped. So the read now refuses as unreadable, which reaches C1 as
FailedPrecondition and keeps what it already has. Only a code naming the
schema itself still reports errSchemaGone, and the caller decides what
that absence means.
The message drops the privilege remedy: it is the answer to a partial
listing, not to an arbitrary refusal, and on a 403 it contradicted the
remedy the client layer already appends. schemaReadError is inlined into
the branch that uses it, since it classified nothing.
Side effect worth naming: a 403 now reaches C1 as PermissionDenied and a
401 as Unauthenticated, where both were FailedPrecondition. Neither is a
warning, so neither changes what C1 keeps.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…landed
and volume layer behind on the same counts, one level deeper.
**Writes were decided from sync-time owners.** Grant and Revoke read the
metastore owner, the catalog owner, the schema owner and the securable's own
owner off the profile the last sync wrote, and those four are exactly what the
trust check short-circuits on. An ownership transfer away from the connector
therefore left a write being decided from a privilege list Databricks had
already started truncating, and Revoke could report a grant removed that is
still held. Both now rebuild the entitlement's table or volume the way the
schema does: the metastore owner from a live listing, the catalog from the
recorded workspace when this sync still admits it and otherwise from the first
running in-scope workspace that serves it, the schema from GET
/schemas/{full_name}, and the securable itself from a new GET
/tables/{full_name} or from GET /volumes/{full_name}. The whole path bypasses
the HTTP cache, because a remembered page would decide the write with the
access of an earlier one. A table also reads table_type live, so the write is
no longer checked against the variant the last sync happened to record.
**A live sighting did not supersede an earlier gone answer.** The walk in
pushSchemaChildRoute could empty a schema's children on a gone answer a later
workspace had already contradicted. The reads run in order and a catalog cannot
be absent before it is present, so a workspace that serves it now clears the
flag. A metastore the account no longer lists also stops returning its bare
sentinel; the metastore syncer removes the parent in the same sync.
**The sync session never reached the shared path.** The children listing and
the table and volume Grants now carry it, so the workspace-Admin check behind
the trust rule is read once per workspace per sync instead of once per
securable. The listing also gained the repeated-page-token guard the schema
listing has.
**A refused schema read stopped the walk.** Only the catalog read continued to
the next workspace, so a 401, 403 or 404 on the schema failed the sync even
where another in-scope workspace serves it. Both reads now walk on, and a
refusal left standing is still an error rather than an empty listing: emptying
one is reserved for a parent every workspace named as gone with none refusing.
GetTable and GetVolume check the name Databricks answers with, as GetCatalog and
GetSchema do, because the owner they report decides whether a privilege list is
complete. GetSchema now refuses an answer naming no schema at all for that same
reason, which is what the client test on this branch already asserted.
Not re-measured against the tenant yet.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The file was 293 lines built on the fake Databricks account the schema tests carried, and #72 dropped that fake with them. What it proved was that the code does what it was written to do. The tenant run is what answers whether the layer works, and QA runs the connector against a tenant before production. Nothing tracked references the fake or its helpers any more, so the package builds and tests clean without this file, which is the view CI gets. It stays excluded per clone, next to the schema tests, for local iteration. The client tests in pkg/databricks/unity_catalog_test.go stay: they assert the query set a listing sends and the name a single read is allowed to answer with, which is a contract rather than a restatement of the caller. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…volume traits resource_types.go dropped TRAIT_APP from table and volume, because neither has app semantics and a profile rides on any resource now. The committed capabilities file still carried the trait, and its workflow only regenerates on a push to main, so CI would not have caught it before the file reached the customer-facing docs. Regenerated with the same command the workflow runs. The trait is gone from both types, and the volume's SkipEntitlements annotation moved with it; the volume keeps a static entitlement set and the table does not, because its privileges follow table_type. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…s needs The setup sections stopped at the catalog and the schema, so an operator who grants USE_SCHEMA follows them, sees the schemas synced, and then fails on the tables and volumes under them: listing those needs ownership of the metastore, the catalog or the schema, direct workspace Admin where the admins group owns the catalog, or ALL_PRIVILEGES on the catalog, and reading one's privileges needs ownership or MANAGE on it, its schema or its catalog. USE_SCHEMA and MANAGE answer neither. The README, the connector doc and the limitations now state both requirements, as the catalog and schema sections do. The limitations also gain the table and volume keys, the one table securable that covers views, materialized views, metric views and streaming tables, and the privileges that are reported when already held but cannot be requested. Two corrections ride along. The ownership limitation said a workspace admins group is never shown; the principal resolver looks an owner name up against the account groups, and a workspace admins group is one, so it is shown when it resolves there. The limitation now says so, which is what the connector doc on this branch already said. And the opt-in is a C1 setting, so it does not gate the CLI: a local run with no selection syncs every type and fails on a service principal that cannot list every table and volume. The README now says to pass --sync-resource-types there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…e is gone
A 404 on the permissions endpoint decided whether Grants reports no grants and
Revoke answers GrantAlreadyRevoked. The table level took SCHEMA_DOES_NOT_EXIST
and CATALOG_DOES_NOT_EXIST as proof, and the volume level took those plus the
generic RESOURCE_DOES_NOT_EXIST after reading the volume through the same
workspace. Every one of those codes also comes back from a workspace that
cannot serve the catalog, and the sync path reads through the workspace the
last sync wrote on the profile, so a binding that changed since then made a
revoke report success while the privilege was still held, and emptied the
securable's grants in C1.
The parent is now read first through that same workspace. Only a schema it
answers 200 for makes the securable's own 404 proof; the securable is then read
with GET /tables/{full_name} or GET /volumes/{full_name}, and a 404 there is a
deletion. Any other answer, from either read, leaves the absence unproven, so
the caller refuses rather than reporting an empty list. The parent syncer walks
every workspace and removes the parent with its children when it is really gone.
Only a code naming the securable itself stays unambiguous, which is
TABLE_DOES_NOT_EXIST and nothing on a volume: Databricks never returns
VOLUME_DOES_NOT_EXIST. The confirmation costs two reads on a 404 and none on
the happy path.
The write path already had this discipline after the live-route change:
liveChildRoute has the chosen workspace serve the catalog and answer 200 for
the schema before the leaf is read, so a parent code there is a deletion
between two reads. The comments now say so.
schema_child_gone_test.go pins the contract in five cases for both levels:
parent served plus a leaf 404 is gone, parent served plus a leaf 200 is not,
and a parent that answers 404, answers 403, or a leaf read that fails leaves it
unproven with no leaf read attempted when the parent did not answer.
A full tenant sync still exits 0 with the same counts as before the change:
871 grants, 7 on the table and 6 on the volume.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
f16c40a to
4c26675
Compare




Description
Last of four stacked PRs for Unity Catalog (CXH-2723). Adds the
tableandvolumeresources: sync, entitlements, grants, and Grant/Revoke of their privileges. No new config field, no credential change.What this adds
schemawas a leaf. Tables and volumes now hang from it, each opt-in, keyed{metastore_id}::{catalog}.{schema}.{name}, with a read-onlyownerentitlement. These are the data assets an access review is about; every level before this one is a container that leads to them.A principal can hold
USE_SCHEMAand hold nothing on the tables under it, which is why each one is its own resource.One
tablesecurable, several kinds of tableUnity Catalog uses one
tablesecurable for tables, views, materialized views, metric views and streaming tables. The grants API accepts a different set for each, so entitlements are built per instance fromtable_typerather than declared once. A privilege the API refuses is still reported when a principal already holds it; it is just not requestable, and Grant rejects it before any PATCH.A volume's set is static —
ALL_PRIVILEGES,APPLY_TAG,MANAGE,READ_METADATA,READ_VOLUME,WRITE_VOLUME— sovolumeskips per-instance entitlements andtabledoes not.Who may list them, and who may read their privileges
Two different rights again, and this time they do not line up with the schema's.
USE_SCHEMAandALL_PRIVILEGESon the catalog each make the schema listing complete; onlyALL_PRIVILEGESmakes the table and volume listing complete. Databricks answers a caller that may not see everything with HTTP 200 and a short list, so each needs its own proof.flowchart TD q["What may the service principal do on this schema?"] --> own{"owns the metastore,<br/>the catalog or the schema?"} own -->|yes| both["lists every table and volume<br/>and reads every privilege"] own -->|no| grp{"catalog owner is _workspace_admins_<ws>_<id><br/>and a <b>direct</b> Admin there?"} grp -->|yes| both grp -->|no| all{"holds ALL_PRIVILEGES<br/>on the catalog?"} all -->|yes| listonly["lists every table and volume;<br/>Grants still needs MANAGE"] all -->|no| man{"holds MANAGE or USE_SCHEMA<br/>on the schema or the catalog?"} man -->|yes| schemaonly["the schemas sync;<br/>their children refuse with PermissionDenied"] man -->|no| deny["PermissionDenied naming the schema<br/>and the remedy — C1 removes nothing"] style both fill:#238636,color:#fff,stroke:#238636 style listonly fill:#9e6a03,color:#fff,stroke:#9e6a03 style schemaonly fill:#9e6a03,color:#fff,stroke:#9e6a03 style deny fill:#da3633,color:#fff,stroke:#da3633The amber branches are real setups, not corner cases:
ALL_PRIVILEGESleavesMANAGEout, andUSE_SCHEMAis the privilege an operator reaches for first. The setup docs now say what each level needs.What the sync does in each case
The rule throughout: nothing is removed on an answer the connector could not prove.
PermissionDeniednaming the schemaFailedPreconditionPermissionDeniedinformation_schemaProvisioning
PATCH .../permissions/{table|volume}/{catalog}.{schema}.{name}, with an uncached pre-read decidingGrantAlreadyExists/GrantAlreadyRevokedand the echo confirming the write.owneris read-only and answersInvalidArgument, and so does a privilege the grants API refuses for thattable_type— before any PATCH goes out.Every write first rebuilds the securable from live reads, because the four owners the trust check short-circuits on — metastore, catalog, schema and the object itself — ride on the profile the last sync wrote, where they can be hours old. A table also re-reads
table_typethere, so a view replaced by a table is not checked against the recorded variant.flowchart TD start[Grant or Revoke] --> live["live reads: metastore owner,<br/>catalog, schema, the table or volume"] live -->|recorded workspace still in scope and serving| trust[trust check on the securable] live -->|otherwise| walk[first running in-scope workspace that serves the catalog] walk --> trust live -->|names the object or a parent gone| gone{Grant or Revoke?} walk -->|no workspace serves the catalog| unproven[FailedPrecondition: deletion cannot be proved] gone -->|Grant| nf[NotFound] gone -->|Revoke| already[GrantAlreadyRevoked] trust --> read[uncached permissions pre-read] read --> patch[PATCH permissions, echo confirms]Which 404 proves a deletion. On the sync path the read goes through the workspace the last sync wrote on the profile, so a 404 there can be a deletion or a workspace that no longer serves the catalog. Only a code naming the securable itself tells them apart, and that is
TABLE_DOES_NOT_EXISTand nothing at all on a volume: measured on this tenant, the permissions endpoint answersRESOURCE_DOES_NOT_EXISTfor a missing volume, a missing schema and a missing catalog alike, and never returnsVOLUME_DOES_NOT_EXIST.Every other code is confirmed before it is believed. The parent schema is read first through that same workspace; only a 200 there makes the securable's own 404 proof, which
GET /tables/{full_name}orGET /volumes/{full_name}then settles. Any other answer from either read leaves the absence unproven and the caller refuses instead of reporting an empty list — the schema and catalog syncers walk every workspace, so a parent that is really gone is removed there, with its children. The confirmation costs two reads on a 404 and none on the happy path.On the write path the same discipline is already in the route: the chosen workspace has just served the catalog and answered 200 for the schema, so a parent code at the leaf read is a deletion between two reads.
Measured on the Baton account
information_schemais not emitted.Links