Skip to content

Commit 388c71c

Browse files
CreateTable, TableService and TableRepository
1 parent baff7dc commit 388c71c

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# TableRepository
2+
3+
## Persist Table Metadata { #createTable }
4+
5+
```java
6+
TableInfo createTable(
7+
CreateTable createTable)
8+
```
9+
10+
`createTable` creates a `TableInfo` with randomly-generated UUID as the table ID and the other metadata.
11+
12+
`createTable` prints out the following DEBUG message to the logs:
13+
14+
```text
15+
Creating table: [fullName]
16+
```
17+
18+
!!! danger "`MANAGED` tables are not supported yet"
19+
20+
`createTable` asserts that `storage_location` is specified for an [EXTERNAL](../server/CreateTable.md#EXTERNAL) table.
21+
22+
`createTable` persists the table's [properties](../server/CreateTable.md#properties) (to `uc_properties` table using `PropertyDAO`).
23+
24+
In the end, `createTable` persists the [table metadata](../server/CreateTable.md).
25+
26+
---
27+
28+
`createTable` is used when:
29+
30+
* `TableService` is requested to [create a table metadata](../server/TableService.md#createTable)

docs/server/CreateTable.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,22 @@
11
# CreateTable
2+
3+
`CreateTable` represents a request to create a new table instance (coming from [TableCli](../cli/TableCli.md#createTable)).
4+
5+
`CreateTable` is `POST`ed to `/tables` API endpoint of the [TableService](TableService.md#createTable) (to persist using [TableRepository](../persistent-storage/TableRepository.md#createTable)).
6+
7+
Property | Required | Description
8+
-|-|-
9+
`catalog_name` | ✅ | Name of parent catalog
10+
`columns` | ✅ | An array of `ColumnInfo`s of the table's columns
11+
`comment` | | User-provided free-form text description
12+
`data_source_format` | ✅ | Data source format:<ul><li>`DELTA`<li>`CSV`<li>`JSON`<li>`AVRO`<li>`PARQUET`<li>`ORC`<li>`TEXT`</ul>
13+
`name` | ✅ | Name of table, relative to parent schema.
14+
`properties` | ✅ | Name of table, relative to parent schema.
15+
`schema_name` | ✅ | Name of parent schema relative to its parent catalog
16+
`storage_location` | | Storage root URL<br>⛔️ Required for `EXTERNAL` tables
17+
`table_type` | ✅ | One of the following:<ul><li>`MANAGED` ([not supported by the Localhost Reference Server](../persistent-storage/TableRepository.md#createTable))<li>`EXTERNAL`</ul>
18+
19+
??? note "OpenAPI Generator"
20+
`CreateTable` was auto-generated using [OpenAPI Generator]({{ openapi.home }}) based on Unity Catalog's [OpenAPI specification]({{ uc.github }}/api/all.yaml).
21+
22+
[sbt-openapi-generator]({{ openapi.github }}/sbt-openapi-generator) 7.5.0 is used in the `client` sbt module of the `unitycatalog` project.

docs/server/TableService.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,23 @@
44

55
Method | URL | Handler | Params
66
-|-|-|-
7-
GET | `/tables` | [listTables](#listTables) | <ul><li>catalog_name</li><li>schema_name</li><li>max_results</li><li>page_token</li><li>omit_properties</li><li>omit_columns</ul>
7+
GET | `/tables` | [listTables](#listTables) | <ul><li>catalog_name<li>schema_name<li>max_results<li>page_token<li>omit_properties<li>omit_columns</ul>
88
POST | `/tables` | [createTable](#createTable) | JSON-ified [CreateTable](CreateTable.md)
9-
GET | `/tables/{full_name}` | [getTable](#getTable) | <ul><li>fullName</li></ul>
10-
DELETE | `/tables/{full_name}` | [deleteTable](#deleteTable) | <ul><li>fullName</li></ul>
9+
GET | `/tables/{full_name}` | [getTable](#getTable) | <ul><li>fullName</ul>
10+
DELETE | `/tables/{full_name}` | [deleteTable](#deleteTable) | <ul><li>fullName</ul>
1111

1212
```console
1313
$ http http://localhost:8081/api/2.1/unity-catalog/tables catalog_name==unity schema_name==default | jq '.tables[].name'
1414
"numbers"
1515
"marksheet_uniform"
1616
"marksheet"
1717
```
18+
19+
## Creating Table Metadata { #createTable }
20+
21+
```java
22+
HttpResponse createTable(
23+
CreateTable createTable)
24+
```
25+
26+
`createTable` requests the system-wide [TableRepository](#TABLE_REPOSITORY) instance to [persist](../persistent-storage/TableRepository.md#createTable) the given [table metadata](CreateTable.md).

0 commit comments

Comments
 (0)