Repository navigation
handle catalog and namespace properly in Iceberg REST api - #324
alexreid-db merged 7 commits into
Conversation
6d31dbc to
7fa4aca
Compare
|
@creechy @tdas @ramesh-db It would be good to get this one in if anyone has cycles to give this a review. |
| } | ||
| // ListNamespaces from catalog | ||
| { | ||
| /*{ |
There was a problem hiding this comment.
should we remove this?
vikrantpuppala
left a comment
There was a problem hiding this comment.
minor comment but lgtm
| When querying Iceberg REST Catalog for Unity Catalog, tables are identified using the following pattern `iceberg.<catalog-name>.<schema-name>.<table-name>` (e.g. `iceberg.unity.default.marksheet_uniform`). | ||
| When querying Iceberg REST Catalog for Unity Catalog, tables are identified using the following pattern `iceberg.<schema-name>.<table-name>` (e.g. `iceberg.default.marksheet_uniform`). | ||
|
|
||
| NOTE: If you want your Spark catalog name to be the same as your UC catalog name, replace `iceberg` in the above configurations with `<catalog-name>`, then tables are identified by the following pattern `<catalog-name>.<schema-name>.<table-name>` (e.g. `unity.default.marksheet_uniform`). |
There was a problem hiding this comment.
nit / followup item: I think we might want to take a clarity pass on the docs here (I remember this being a little confusing back when I was starting w/ spark). Shouldn't block this PR though
There was a problem hiding this comment.
I'm confused about the difference between "Spark catalog name" and "UC catalog name". An Iceberg Catalog doesn't actually have a name that is part of the SQL identifier. Outside of the Iceberg Catalog, each engine will refer to the catalog using its own alias.
The fully qualified identifier to a table in the Iceberg Catalog is engine specific. So for engine A, the identifier to a particular table may look like:
CatalogForEngineA.namespace.table
And for engine B, the identifier may look like:
CatalogForEngineB.namespace.table
There was a problem hiding this comment.
Note that we would now be configuring a UC catalog per REST client through the warehouse config parameter.
In Spark for instance, you can set the Spark/Engine catalog name to whatever you want in the configuration. This is just saying if you want the Engine catalog name to match up to the UC catalog name you have set, then you would want to set the Engine catalog name to the UC catalog name.
Let's say I have a UC catalog named main and a schema named default that has tables in it named table1 and table2.
I could set a spark configuration to access this like:
"spark.sql.catalog.iceberg": "org.apache.iceberg.spark.SparkCatalog",
"spark.sql.catalog.iceberg.catalog-impl": "org.apache.iceberg.rest.RESTCatalog",
"spark.sql.catalog.iceberg.uri": "http://127.0.0.1:8080/api/2.1/unity-catalog/iceberg",
"spark.sql.catalog.iceberg.warehouse": "main"
I would then in spark-sql, list tables like so:
>show tables from iceberg.default;
table1
table2
If I wanted to make it so I could address the schemas/tables using the actual UC catalog name for the UC catalog I configured the Spark catalog for, then I would do:
"spark.sql.catalog.main": "org.apache.iceberg.spark.SparkCatalog",
"spark.sql.catalog.main.catalog-impl": "org.apache.iceberg.rest.RESTCatalog",
"spark.sql.catalog.main.uri": "http://127.0.0.1:8080/api/2.1/unity-catalog/iceberg",
"spark.sql.catalog.main.warehouse": "main"
>show tables from main.default;
table1
table2
There was a problem hiding this comment.
I see now. That makes sense. This diagram was helpful to understand the difference between the metastore vs catalog. https://docs.databricks.com/en/data-governance/unity-catalog/index.html#the-unity-catalog-object-model
Thanks for explaining!
| } | ||
|
|
||
| @Get("/v1/namespaces/{namespace}/tables/{table}") | ||
| @Get("/v1/catalogs/{catalog}/namespaces/{namespace}/tables/{table}") |
There was a problem hiding this comment.
What is the purpose of acatalog part here? The Iceberg specification doesn't have such concept, and this change would further deviate from the spec defined at https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml#L240-L254
Parent namespaces should be nested into a parent= GET parameter to conform the specification.
There was a problem hiding this comment.
This does not deviate from the spec and is valid use of {prefix} as defined in the spec.
There was a problem hiding this comment.
Well isn't catalog part of the namespace here? If it is, the listNamespaces query should have a parent param, and listTables should use the %1F separator.
I don't think {prefix} was really meant to be used this way. Like what's the meaning of /v1/{prefix}/transactions/commit then (as seen here) if we give a catalog name there?
There was a problem hiding this comment.
Well isn't catalog part of the namespace here
We are/would be saying that catalog is NOT considered part of the namespace.
I don't think {prefix} was really meant to be used this way.
Again, this is valid to the spec where an implementation performs operations within in the context of a catalog.
There was a problem hiding this comment.
catalog is NOT considered part of the namespace.
Then it makes sense of course.
But: catalog did use to be part of the namespace and on top of that, a client would be restricted to work with only one catalog from now on. That strikes me as a rather larger structural change compared to just a namespace separator fix, wouldn't you agree?
Also - how is this going to be backward compatible with older client versions? (Considering those that provided . as separator of course..)
Edit:
one more thing: I belive this also takes away the possibility for clients to discover what catalogs there are? Should we plan to substitute the lost functionality somehow?
There was a problem hiding this comment.
But: catalog did use to be part of the namespace and on top of that, a client would be restricted to work with only one catalog from now on. That strikes me as a rather larger structural change compared to just a namespace separator fix, wouldn't you agree?
Not if we felt the original implementation was incorrect. Other IRC implementations (Tabular, Polaris) utilize the prefix in this way and separate out a entity like catalog/warehouse and do not consider it to be part of the namespace so this is not a new/foreign concept.
I agree that using the . was not to spec for namespace separating, but since we consider the catalog to not be part of the namespace and UC OSS only has 1 level for namespace (Schema), we don't have to worry about a separator for now (and only if later it is decided UC wants to support nested schemas/namespaces).
Also - how is this going to be backward compatible with older client versions? (Considering those that provided . as separator of course..)
0.2 hasn't even been released yet, so not sure why anyone would expect it to be "stable" as far as things like this.
Also, per the spec, REST clients should be hitting the config endpoint first to get configurations.
one more thing: I belive this also takes away the possibility for clients to discover what catalogs there are? Should we plan to substitute the lost functionality somehow?
UC OSS has other endpoints for this that are not part of the IRC spec. (so this can be done through the cli, UI, etc.)
There was a problem hiding this comment.
Okay, thanks for explaining @alexreid-db
7fa4aca to
e5f6536
Compare
84f3bd9 to
8a3012c
Compare
| .isEqualTo( | ||
| "{\"defaults\":{},\"overrides\":{\"prefix\":\"catalogs/" | ||
| + TestUtils.CATALOG_NAME | ||
| + "\"}}"); |
There was a problem hiding this comment.
can you add a test to ensure that non-warehouse fails?
| .containsExactly(TableIdentifier.of(TestUtils.SCHEMA_NAME, TestUtils.TABLE_NAME)); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
why remove these tests?
and can you also add tests that test failure of non-catalog-prefixed urls
8a3012c to
a9bd565
Compare
tdas
left a comment
There was a problem hiding this comment.
thank you for this @alexreid-db this is great!
|
can you fix the DCO stuff? see the failing test. |
d9ddde4 to
9ff7c35
Compare
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
Signed-off-by: Alex Reid <[email protected]>
d4caf29 to
ec78b1d
Compare
…og#324) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Prior to this PR, users were required to lookup namespace and tables by supplying the uc catalog name in the namespace identifier which isn't proper and lead to problems. This PR implements the REST client flow of configuring calls to the API with a defined prefix containing the catalog name. The catalog name is now part of the API paths and broken apart from the namespace. Client (passes warehouse parameter) -> Server Config Endpoint (response has override for URL prefix) -> Client Subsequent calls to the API now has url prefixed with `/catalogs/{warehouse/catalog-name}` This PR "binds" the spark catalog to a UC catalog using the client config endpoint. Users must now add to their catalog configurations something like (example in spark): `"spark.sql.catalog.<spark-catalog-name>.warehouse": "<catalog-name>"` and now address tables like `<spark-catalog-name>.<namespace-name>.<table-name>` This should address unitycatalog#182 and parts of unitycatalog#3. --------- Signed-off-by: Alex Reid <[email protected]> Signed-off-by: Joseph Mocker <[email protected]>
…og#324) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Prior to this PR, users were required to lookup namespace and tables by supplying the uc catalog name in the namespace identifier which isn't proper and lead to problems. This PR implements the REST client flow of configuring calls to the API with a defined prefix containing the catalog name. The catalog name is now part of the API paths and broken apart from the namespace. Client (passes warehouse parameter) -> Server Config Endpoint (response has override for URL prefix) -> Client Subsequent calls to the API now has url prefixed with `/catalogs/{warehouse/catalog-name}` This PR "binds" the spark catalog to a UC catalog using the client config endpoint. Users must now add to their catalog configurations something like (example in spark): `"spark.sql.catalog.<spark-catalog-name>.warehouse": "<catalog-name>"` and now address tables like `<spark-catalog-name>.<namespace-name>.<table-name>` This should address unitycatalog#182 and parts of unitycatalog#3. --------- Signed-off-by: Alex Reid <[email protected]> (cherry picked from commit 3bf4a01)
#742) **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [x] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** Prior to this PR, users were required to lookup namespace and tables by supplying the uc catalog name in the namespace identifier which isn't proper and lead to problems. This PR implements the REST client flow of configuring calls to the API with a defined prefix containing the catalog name. The catalog name is now part of the API paths and broken apart from the namespace. Client (passes warehouse parameter) -> Server Config Endpoint (response has override for URL prefix) -> Client Subsequent calls to the API now has url prefixed with `/catalogs/{warehouse/catalog-name}` This PR "binds" the spark catalog to a UC catalog using the client config endpoint. Users must now add to their catalog configurations something like (example in spark): `"spark.sql.catalog.<spark-catalog-name>.warehouse": "<catalog-name>"` and now address tables like `<spark-catalog-name>.<namespace-name>.<table-name>` This should address #182 and parts of #3. --------- Signed-off-by: Alex Reid <[email protected]> (cherry picked from commit 3bf4a01) **PR Checklist** - [ ] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [ ] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated **Description of changes** <!-- Please state what you've changed and how it might affect the users. --> --------- Signed-off-by: Alex Reid <[email protected]>
The property was added for supporting Unity catalog. They changed the behavior to respect warehouse property in unitycatalog/unitycatalog#324.
The property was added for supporting Unity catalog. They changed the behavior to respect warehouse property in unitycatalog/unitycatalog#324.
PR Checklist
docsis updatedDescription of changes
Prior to this PR, users were required to lookup namespace and tables by supplying the uc catalog name in the namespace identifier which isn't proper and lead to problems. This PR implements the REST client flow of configuring calls to the API with a defined prefix containing the catalog name. The catalog name is now part of the API paths and broken apart from the namespace.
Client (passes warehouse parameter) -> Server Config Endpoint (response has override for URL prefix) -> Client
Subsequent calls to the API now has url prefixed with
/catalogs/{warehouse/catalog-name}This PR "binds" the spark catalog to a UC catalog using the client config endpoint. Users must now add to their catalog configurations something like (example in spark):
"spark.sql.catalog.<spark-catalog-name>.warehouse": "<catalog-name>"and now address tables like<spark-catalog-name>.<namespace-name>.<table-name>This should address #182 and parts of #3.