Skip to content

Commit 42afbc8

Browse files
authored
spec: get table under namespace (#42)
close #41
1 parent 59754f7 commit 42afbc8

12 files changed

Lines changed: 846 additions & 0 deletions

File tree

java/lance-catalog-apache-client/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Class | Method | HTTP request | Description
119119
*NamespaceApi* | [**getNamespace**](docs/NamespaceApi.md#getNamespace) | **GET** /v1/namespaces/{ns} | Get information about a namespace
120120
*NamespaceApi* | [**listNamespaces**](docs/NamespaceApi.md#listNamespaces) | **GET** /v1/namespaces | List all namespaces in the catalog.
121121
*NamespaceApi* | [**namespaceExists**](docs/NamespaceApi.md#namespaceExists) | **HEAD** /v1/namespaces/{ns} | Check if a namespace exists
122+
*TableApi* | [**getTable**](docs/TableApi.md#getTable) | **GET** /v1/namespaces/{ns}/tables/{table} | Get a table from the catalog
122123
*TableApi* | [**registerTable**](docs/TableApi.md#registerTable) | **POST** /v1/namespaces/{ns}/register | Register a new table in the given namespace. A table represents a lance dataset. In Lance catalog, a table must be hosted in a namespace.
123124

124125

java/lance-catalog-apache-client/api/openapi.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,37 @@ paths:
207207
x-content-type: application/json
208208
x-accepts:
209209
- application/json
210+
/v1/namespaces/{ns}/tables/{table}:
211+
get:
212+
description: Get a table's detailed information under a specified namespace
213+
from the catalog.
214+
operationId: GetTable
215+
parameters:
216+
- $ref: '#/components/parameters/namespace'
217+
- $ref: '#/components/parameters/table'
218+
responses:
219+
"200":
220+
$ref: '#/components/responses/GetTableResponse'
221+
"400":
222+
$ref: '#/components/responses/BadRequestErrorResponse'
223+
"401":
224+
$ref: '#/components/responses/UnauthorizedResponse'
225+
"403":
226+
$ref: '#/components/responses/ForbiddenResponse'
227+
"404":
228+
$ref: '#/components/responses/NotFoundResponse'
229+
"503":
230+
$ref: '#/components/responses/ServiceUnavailableResponse'
231+
"5XX":
232+
$ref: '#/components/responses/ServerErrorResponse'
233+
summary: Get a table from the catalog
234+
tags:
235+
- Table
236+
x-accepts:
237+
- application/json
238+
parameters:
239+
- $ref: '#/components/parameters/namespace'
240+
- $ref: '#/components/parameters/table'
210241
components:
211242
examples:
212243
ListNamespacesEmptyExample:
@@ -249,6 +280,15 @@ components:
249280
minimum: 1
250281
type: integer
251282
style: form
283+
table:
284+
description: A table name.
285+
explode: false
286+
in: path
287+
name: table
288+
required: true
289+
schema:
290+
type: string
291+
style: simple
252292
responses:
253293
CreateNamespaceResponse:
254294
content:

java/lance-catalog-apache-client/docs/TableApi.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,85 @@ All URIs are relative to *http://localhost:2333*
44

55
| Method | HTTP request | Description |
66
|------------- | ------------- | -------------|
7+
| [**getTable**](TableApi.md#getTable) | **GET** /v1/namespaces/{ns}/tables/{table} | Get a table from the catalog |
78
| [**registerTable**](TableApi.md#registerTable) | **POST** /v1/namespaces/{ns}/register | Register a new table in the given namespace. A table represents a lance dataset. In Lance catalog, a table must be hosted in a namespace. |
89

910

1011

12+
## getTable
13+
14+
> GetTableResponse getTable(ns, table)
15+
16+
Get a table from the catalog
17+
18+
Get a table's detailed information under a specified namespace from the catalog.
19+
20+
### Example
21+
22+
```java
23+
// Import classes:
24+
import com.lancedb.lance.catalog.client.apache.ApiClient;
25+
import com.lancedb.lance.catalog.client.apache.ApiException;
26+
import com.lancedb.lance.catalog.client.apache.Configuration;
27+
import com.lancedb.lance.catalog.client.apache.models.*;
28+
import com.lancedb.lance.catalog.client.apache.api.TableApi;
29+
30+
public class Example {
31+
public static void main(String[] args) {
32+
ApiClient defaultClient = Configuration.getDefaultApiClient();
33+
defaultClient.setBasePath("http://localhost:2333");
34+
35+
TableApi apiInstance = new TableApi(defaultClient);
36+
String ns = "ns_example"; // String | The name of the namespace.
37+
String table = "table_example"; // String | A table name.
38+
try {
39+
GetTableResponse result = apiInstance.getTable(ns, table);
40+
System.out.println(result);
41+
} catch (ApiException e) {
42+
System.err.println("Exception when calling TableApi#getTable");
43+
System.err.println("Status code: " + e.getCode());
44+
System.err.println("Reason: " + e.getResponseBody());
45+
System.err.println("Response headers: " + e.getResponseHeaders());
46+
e.printStackTrace();
47+
}
48+
}
49+
}
50+
```
51+
52+
### Parameters
53+
54+
55+
| Name | Type | Description | Notes |
56+
|------------- | ------------- | ------------- | -------------|
57+
| **ns** | **String**| The name of the namespace. | |
58+
| **table** | **String**| A table name. | |
59+
60+
### Return type
61+
62+
[**GetTableResponse**](GetTableResponse.md)
63+
64+
### Authorization
65+
66+
No authorization required
67+
68+
### HTTP request headers
69+
70+
- **Content-Type**: Not defined
71+
- **Accept**: application/json
72+
73+
74+
### HTTP response details
75+
| Status code | Description | Response headers |
76+
|-------------|-------------|------------------|
77+
| **200** | Table properties result when loading a table | - |
78+
| **400** | Indicates a bad request error. It could be caused by an unexpected request body format or other forms of request validation failure, such as invalid json. Usually serves application/json content, although in some cases simple text/plain content might be returned by the server's middleware. | - |
79+
| **401** | Unauthorized. The request lacks valid authentication credentials for the operation. | - |
80+
| **403** | Forbidden. Authenticated user does not have the necessary permissions. | - |
81+
| **404** | A server-side problem that means can not find the specified resource. | - |
82+
| **503** | The service is not ready to handle the request. The client should wait and retry. The service may additionally send a Retry-After header to indicate when to retry. | - |
83+
| **5XX** | A server-side problem that might not be addressable from the client side. Used for server 5xx errors without more specific documentation in individual routes. | - |
84+
85+
1186
## registerTable
1287

1388
> GetTableResponse registerTable(ns, registerTableRequest)

java/lance-catalog-apache-client/src/main/java/com/lancedb/lance/catalog/client/apache/api/TableApi.java

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,88 @@ public TableApi(ApiClient apiClient) {
4343
super(apiClient);
4444
}
4545

46+
/**
47+
* Get a table from the catalog Get a table's detailed information under a specified namespace
48+
* from the catalog.
49+
*
50+
* @param ns The name of the namespace. (required)
51+
* @param table A table name. (required)
52+
* @return GetTableResponse
53+
* @throws ApiException if fails to make API call
54+
*/
55+
public GetTableResponse getTable(String ns, String table) throws ApiException {
56+
return this.getTable(ns, table, Collections.emptyMap());
57+
}
58+
59+
/**
60+
* Get a table from the catalog Get a table's detailed information under a specified namespace
61+
* from the catalog.
62+
*
63+
* @param ns The name of the namespace. (required)
64+
* @param table A table name. (required)
65+
* @param additionalHeaders additionalHeaders for this call
66+
* @return GetTableResponse
67+
* @throws ApiException if fails to make API call
68+
*/
69+
public GetTableResponse getTable(String ns, String table, Map<String, String> additionalHeaders)
70+
throws ApiException {
71+
Object localVarPostBody = null;
72+
73+
// verify the required parameter 'ns' is set
74+
if (ns == null) {
75+
throw new ApiException(400, "Missing the required parameter 'ns' when calling getTable");
76+
}
77+
78+
// verify the required parameter 'table' is set
79+
if (table == null) {
80+
throw new ApiException(400, "Missing the required parameter 'table' when calling getTable");
81+
}
82+
83+
// create path and map variables
84+
String localVarPath =
85+
"/v1/namespaces/{ns}/tables/{table}"
86+
.replaceAll(
87+
"\\{" + "ns" + "\\}", apiClient.escapeString(apiClient.parameterToString(ns)))
88+
.replaceAll(
89+
"\\{" + "table" + "\\}",
90+
apiClient.escapeString(apiClient.parameterToString(table)));
91+
92+
StringJoiner localVarQueryStringJoiner = new StringJoiner("&");
93+
String localVarQueryParameterBaseName;
94+
List<Pair> localVarQueryParams = new ArrayList<Pair>();
95+
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
96+
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
97+
Map<String, String> localVarCookieParams = new HashMap<String, String>();
98+
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
99+
100+
localVarHeaderParams.putAll(additionalHeaders);
101+
102+
final String[] localVarAccepts = {"application/json"};
103+
final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
104+
105+
final String[] localVarContentTypes = {};
106+
107+
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
108+
109+
String[] localVarAuthNames = new String[] {};
110+
111+
TypeReference<GetTableResponse> localVarReturnType = new TypeReference<GetTableResponse>() {};
112+
return apiClient.invokeAPI(
113+
localVarPath,
114+
"GET",
115+
localVarQueryParams,
116+
localVarCollectionQueryParams,
117+
localVarQueryStringJoiner.toString(),
118+
localVarPostBody,
119+
localVarHeaderParams,
120+
localVarCookieParams,
121+
localVarFormParams,
122+
localVarAccept,
123+
localVarContentType,
124+
localVarAuthNames,
125+
localVarReturnType);
126+
}
127+
46128
/**
47129
* Register a new table in the given namespace. A table represents a lance dataset. In Lance
48130
* catalog, a table must be hosted in a namespace.

0 commit comments

Comments
 (0)