Repository navigation
Conversation
Signed-off-by: Uros Stankovic <[email protected]>
49358c3 to
abdc6c1
Compare
| .setPort(url.getPort()) | ||
| .setScheme(url.getScheme()); | ||
| .setScheme(url.getScheme()) | ||
| .setBasePath(basePath); |
There was a problem hiding this comment.
This base path was set in ApiClient constructor to /api/2.1/unity-catalog, because ApiClient::getDefaultBaseUri is http://localhost:8080/api/2.1/unity-catalog, while we invoke updateBaseUri(getDefaultBaseUri()); in constructor, so base path was already set to /api/2.1/unity-catalog.
There was a problem hiding this comment.
If we don't set the /api/2.1/unity-catalog, what's the version (or base path) that the API call will go through by default ?
There was a problem hiding this comment.
Before this PR, base path was /api/2.1/unity-catalog, while after this PR, it is path from provided URL + /api/2.1/unity-catalog.
URL input 1:
https://databricks.workspace.com
Before: https://databricks.workspace.com/api/2.1/unity-catalog
After: https://databricks.workspace.com/api/2.1/unity-catalog
URL input 2
Before: https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/
After: https://onelake.table.fabric.microsoft.com/delta///api/2.1/unity-catalog/
There was a problem hiding this comment.
Okay, I think I got the point. Thanks for the information. Could you please help to add some unit tests to address this ? Seems like it's hard to get this context correctly. Thanks.
There was a problem hiding this comment.
Thanks, I added ApiClientFactoryTest and one method to test base URI for all APIs
There was a problem hiding this comment.
can you leave this context as a comment in the code on why basePath needs to be set? this is important context that should be captured in the code.
|
Hi @urosstan-db , thanks for the contributionn. Could you please help to check the |
| private ApiClientFactory() {} | ||
|
|
||
| public static ApiClient createApiClient(URI url, String token) { | ||
| String basePath = url.getPath() + BASE_PATH; |
There was a problem hiding this comment.
Why do we need to concat the url.getPath() and BASE_PATH to set the basePath for the ApiClient ?
There was a problem hiding this comment.
( since we've already set the host and port for the apiClient ).
There was a problem hiding this comment.
getPath returns the part of URI after host and port.
https://docs.oracle.com/javase/8/docs/api/java/net/URI.html
https://www.geeksforgeeks.org/java/uri-getpath-method-in-java-with-examples/
Since we set host and port only currently (prior to this PR), the path is just omitted in the final URL of ApiClient, which prevents us from connecting to the UC API registered at some endpoint with a path.
Signed-off-by: Uros Stankovic <[email protected]>
f40d81f to
aac2e39
Compare
Signed-off-by: Uros Stankovic <[email protected]>
79a22fb to
fe9cad4
Compare
openinx
left a comment
There was a problem hiding this comment.
LGTM, thanks @urosstan-db for the contribution !
| public void testApiClientBaseUri() { | ||
| String token = ""; | ||
|
|
||
| URI uriDatabricks = URI.create("https://adb-1234567890123456.3.azuredatabricks.net"); |
There was a problem hiding this comment.
which of these 2 cases passed before your changes to the factory?
I am trying to make sure that we are capturing in a test that the existing URLs are not broken.
There was a problem hiding this comment.
This URI passed, uriDatabricks, since it has no path in URL, while fabric failed
Signed-off-by: Uros Stankovic <[email protected]>
Signed-off-by: Uros Stankovic <[email protected]>
Signed-off-by: Uros Stankovic <[email protected]>
**PR Checklist** - Certain vendors may register UC API under a certain path (e.g. Microsoft Fabric API registers it under `https://onelake.table.fabric.microsoft.com/delta/<Workspace name or workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`) - New test suite added - This is a behavioural change, since if someone provided a URL earlier with a specific path, then the path would be just ignored (e.g., the fabric API I provided above would be translated to `https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`). But probably no users provide a URL with a path, since the UC API could not be hit prior to this fix. - Base URL prior this change was `api/2.1/unity-catalog/`, while now it is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/` **Description of changes** - In the API Client factory, set the base path of the provided URL where the UC API is registered. This code path is hit when we initialize `UCSingleCatalog`. - Behaviour prior this change caused failure on URIs with certain path: <img width="1852" height="194" alt="image" src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6" /> --------- Signed-off-by: Uros Stankovic <[email protected]> (cherry picked from commit 37f5755)
|
Successfully created backport PR for |
**PR Checklist** - Certain vendors may register UC API under a certain path (e.g. Microsoft Fabric API registers it under `https://onelake.table.fabric.microsoft.com/delta/<Workspace name or workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`) - New test suite added - This is a behavioural change, since if someone provided a URL earlier with a specific path, then the path would be just ignored (e.g., the fabric API I provided above would be translated to `https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`). But probably no users provide a URL with a path, since the UC API could not be hit prior to this fix. - Base URL prior this change was `api/2.1/unity-catalog/`, while now it is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/` **Description of changes** - In the API Client factory, set the base path of the provided URL where the UC API is registered. This code path is hit when we initialize `UCSingleCatalog`. - Behaviour prior this change caused failure on URIs with certain path: <img width="1852" height="194" alt="image" src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6" /> --------- Signed-off-by: Uros Stankovic <[email protected]> (cherry picked from commit 37f5755) Signed-off-by: Uros Stankovic <[email protected]>
) Backport of #1130 to `branch-0.3`. --- **PR Checklist** - Certain vendors may register UC API under a certain path (e.g. Microsoft Fabric API registers it under `https://onelake.table.fabric.microsoft.com/delta/<Workspace name or workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/`) - New test suite added - This is a behavioural change, since if someone provided a URL earlier with a specific path, then the path would be just ignored (e.g., the fabric API I provided above would be translated to `https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/`). But probably no users provide a URL with a path, since the UC API could not be hit prior to this fix. - Base URL prior this change was `api/2.1/unity-catalog/`, while now it is `basePathFromProvidedUrl` + `api/2.1/unity-catalog/` **Description of changes** - In the API Client factory, set the base path of the provided URL where the UC API is registered. This code path is hit when we initialize `UCSingleCatalog`. - Behaviour prior this change caused failure on URIs with certain path: <img width="1852" height="194" alt="image" src="https://github.com/user-attachments/assets/ae2d67cb-2d92-4483-bd4a-07ee961200e6" /> Signed-off-by: Uros Stankovic <[email protected]> Signed-off-by: Uros Stankovic <[email protected]> Co-authored-by: Uros Stankovic <[email protected]>
PR Checklist
https://onelake.table.fabric.microsoft.com/delta/<Workspace name or workspace ID>/<Item name or item ID>/api/2.1/unity-catalog/)https://onelake.table.fabric.microsoft.com/api/2.1/unity-catalog/). But probably no users provide a URL with a path, since the UC API could not be hit prior to this fix.api/2.1/unity-catalog/, while now it isbasePathFromProvidedUrl+api/2.1/unity-catalog/Description of changes
UCSingleCatalog.