diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 000000000..51280e0f5 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,80 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Python Publish + +on: + release: + types: + - released + pull_request: + paths: + - .github/workflows/python-publish.yml + workflow_dispatch: + inputs: + mode: + description: "dry_run: build & test only, release: build & publish to PyPI" + required: true + default: "dry_run" + type: choice + options: + - dry_run + - release + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + id-token: write # Required for PyPI trusted publishing + contents: read + defaults: + run: + working-directory: python + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install uv + uses: astral-sh/setup-uv@v4 + + - name: Build lance-namespace-urllib3-client + working-directory: python/lance_namespace_urllib3_client + if: github.event_name == 'pull_request' || github.event.inputs.mode == 'dry_run' + run: | + uv build + + - name: Build lance-namespace + working-directory: python/lance_namespace + if: github.event_name == 'pull_request' || github.event.inputs.mode == 'dry_run' + run: | + uv build + + - name: Publish lance-namespace-urllib3-client to PyPI + if: | + (github.event_name == 'release' && github.event.action == 'released') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release') + working-directory: python/lance_namespace_urllib3_client + run: | + uv publish --trusted-publishing always + + - name: Publish lance-namespace to PyPI + if: | + (github.event_name == 'release' && github.event.action == 'released') || + (github.event_name == 'workflow_dispatch' && github.event.inputs.mode == 'release') + working-directory: python/lance_namespace + run: | + uv publish --trusted-publishing always \ No newline at end of file diff --git a/docs/src/spec/operations/alter-transaction.md b/docs/src/spec/operations/alter-transaction.md index 46ae9de4c..250a55bfa 100644 --- a/docs/src/spec/operations/alter-transaction.md +++ b/docs/src/spec/operations/alter-transaction.md @@ -9,7 +9,7 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:2025:2042" +--8<-- "src/spec/rest.yaml:2035:2052" ``` Supporting action schemas: @@ -28,22 +28,22 @@ Supporting action schemas: ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:2043:2054" +--8<-- "src/spec/rest.yaml:2053:2064" ``` ## Related Components Schema ### Set Status Action ```yaml ---8<-- "src/spec/rest.yaml:1963:1968" +--8<-- "src/spec/rest.yaml:1973:1978" ``` ### Set Property Action ```yaml ---8<-- "src/spec/rest.yaml:1969:1978" +--8<-- "src/spec/rest.yaml:1979:1988" ``` ### Unset Property Action ```yaml ---8<-- "src/spec/rest.yaml:1991:1998" +--8<-- "src/spec/rest.yaml:2001:2008" ``` diff --git a/docs/src/spec/operations/count-table-rows.md b/docs/src/spec/operations/count-table-rows.md index e27a00e05..6e417aaae 100644 --- a/docs/src/spec/operations/count-table-rows.md +++ b/docs/src/spec/operations/count-table-rows.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1359:1377" +--8<-- "src/spec/rest.yaml:1369:1387" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1378:1385" +--8<-- "src/spec/rest.yaml:1388:1395" ``` diff --git a/docs/src/spec/operations/create-table-index.md b/docs/src/spec/operations/create-table-index.md index bff5cc5af..b28ee84e2 100644 --- a/docs/src/spec/operations/create-table-index.md +++ b/docs/src/spec/operations/create-table-index.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1640:1705" +--8<-- "src/spec/rest.yaml:1650:1715" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1706:1723" +--8<-- "src/spec/rest.yaml:1716:1733" ``` diff --git a/docs/src/spec/operations/create-table.md b/docs/src/spec/operations/create-table.md index 4428932a9..1d6262f42 100644 --- a/docs/src/spec/operations/create-table.md +++ b/docs/src/spec/operations/create-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1877:1894" +--8<-- "src/spec/rest.yaml:1887:1904" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1895:1918" +--8<-- "src/spec/rest.yaml:1905:1928" ``` diff --git a/docs/src/spec/operations/delete-from-table.md b/docs/src/spec/operations/delete-from-table.md index de65cf81a..5f19c2b6f 100644 --- a/docs/src/spec/operations/delete-from-table.md +++ b/docs/src/spec/operations/delete-from-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1512:1528" +--8<-- "src/spec/rest.yaml:1522:1538" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1529:1539" +--8<-- "src/spec/rest.yaml:1539:1549" ``` diff --git a/docs/src/spec/operations/deregister-table.md b/docs/src/spec/operations/deregister-table.md index 3eab10f43..487868eb9 100644 --- a/docs/src/spec/operations/deregister-table.md +++ b/docs/src/spec/operations/deregister-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:2086:2095" +--8<-- "src/spec/rest.yaml:2096:2105" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:2096:2109" +--8<-- "src/spec/rest.yaml:2106:2119" ``` diff --git a/docs/src/spec/operations/describe-table-index-stats.md b/docs/src/spec/operations/describe-table-index-stats.md index bf5f36b3a..a3d4e30c5 100644 --- a/docs/src/spec/operations/describe-table-index-stats.md +++ b/docs/src/spec/operations/describe-table-index-stats.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1773:1789" +--8<-- "src/spec/rest.yaml:1783:1799" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1790:1813" +--8<-- "src/spec/rest.yaml:1800:1823" ``` diff --git a/docs/src/spec/operations/describe-table.md b/docs/src/spec/operations/describe-table.md index 0a9a27772..253a43d85 100644 --- a/docs/src/spec/operations/describe-table.md +++ b/docs/src/spec/operations/describe-table.md @@ -9,22 +9,22 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1320:1334" +--8<-- "src/spec/rest.yaml:1330:1344" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1335:1358" +--8<-- "src/spec/rest.yaml:1345:1368" ``` ## Related Components Schema ### Json Arrow Schema ```yaml ---8<-- "src/spec/rest.yaml:1814:1831" +--8<-- "src/spec/rest.yaml:1824:1841" ``` ### Json Arrow Schema ```yaml ---8<-- "src/spec/rest.yaml:1832:1852" +--8<-- "src/spec/rest.yaml:1842:1862" ``` diff --git a/docs/src/spec/operations/describe-transaction.md b/docs/src/spec/operations/describe-transaction.md index 3852bb1e6..6fdecd472 100644 --- a/docs/src/spec/operations/describe-transaction.md +++ b/docs/src/spec/operations/describe-transaction.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1943:1950" +--8<-- "src/spec/rest.yaml:1953:1960" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1951:1962" +--8<-- "src/spec/rest.yaml:1961:1972" ``` diff --git a/docs/src/spec/operations/drop-table.md b/docs/src/spec/operations/drop-table.md index 587ef10e9..88bb87787 100644 --- a/docs/src/spec/operations/drop-table.md +++ b/docs/src/spec/operations/drop-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:2055:2065" +--8<-- "src/spec/rest.yaml:2065:2075" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:2066:2085" +--8<-- "src/spec/rest.yaml:2076:2095" ``` diff --git a/docs/src/spec/operations/index.md b/docs/src/spec/operations/index.md index 0c87734a9..331f3ecb9 100644 --- a/docs/src/spec/operations/index.md +++ b/docs/src/spec/operations/index.md @@ -56,47 +56,47 @@ All error responses follow the JSON error response model based on [RFC-7807](htt ### 400 - Bad Request Error Response ```yaml ---8<-- "src/spec/rest.yaml:2423:2440" +--8<-- "src/spec/rest.yaml:2433:2450" ``` ### 401 - Unauthorized Error Response ```yaml ---8<-- "src/spec/rest.yaml:2441:2454" +--8<-- "src/spec/rest.yaml:2451:2464" ``` ### 403 - Forbidden Error Response ```yaml ---8<-- "src/spec/rest.yaml:2455:2468" +--8<-- "src/spec/rest.yaml:2465:2478" ``` ### 404 - Not Found Error Response ```yaml ---8<-- "src/spec/rest.yaml:2469:2483" +--8<-- "src/spec/rest.yaml:2479:2493" ``` ### 406 - Unsupported Operation Error Response ```yaml ---8<-- "src/spec/rest.yaml:2484:2497" +--8<-- "src/spec/rest.yaml:2494:2507" ``` ### 409 - Conflict Error Response ```yaml ---8<-- "src/spec/rest.yaml:2498:2511" +--8<-- "src/spec/rest.yaml:2508:2521" ``` ### 503 - Service Unavailable Error Response ```yaml ---8<-- "src/spec/rest.yaml:2512:2527" +--8<-- "src/spec/rest.yaml:2522:2537" ``` ### 5XX - Server Error Response ```yaml ---8<-- "src/spec/rest.yaml:2528:2544" +--8<-- "src/spec/rest.yaml:2538:2554" ``` \ No newline at end of file diff --git a/docs/src/spec/operations/insert-into-table.md b/docs/src/spec/operations/insert-into-table.md index 284c94db1..b8a9f2842 100644 --- a/docs/src/spec/operations/insert-into-table.md +++ b/docs/src/spec/operations/insert-into-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1386:1401" +--8<-- "src/spec/rest.yaml:1396:1411" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1402:1411" +--8<-- "src/spec/rest.yaml:1412:1421" ``` diff --git a/docs/src/spec/operations/list-table-indices.md b/docs/src/spec/operations/list-table-indices.md index ade781484..be5d662b6 100644 --- a/docs/src/spec/operations/list-table-indices.md +++ b/docs/src/spec/operations/list-table-indices.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1724:1738" +--8<-- "src/spec/rest.yaml:1734:1748" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1739:1749" +--8<-- "src/spec/rest.yaml:1749:1759" ``` diff --git a/docs/src/spec/operations/list-tables.md b/docs/src/spec/operations/list-tables.md index c017a1081..55547ae6e 100644 --- a/docs/src/spec/operations/list-tables.md +++ b/docs/src/spec/operations/list-tables.md @@ -9,12 +9,12 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1293:1304" +--8<-- "src/spec/rest.yaml:1303:1314" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1305:1319" +--8<-- "src/spec/rest.yaml:1315:1329" ``` ## Related Components Schema diff --git a/docs/src/spec/operations/merge-insert-into-table.md b/docs/src/spec/operations/merge-insert-into-table.md index f69f8d137..f84f19fc8 100644 --- a/docs/src/spec/operations/merge-insert-into-table.md +++ b/docs/src/spec/operations/merge-insert-into-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1412:1442" +--8<-- "src/spec/rest.yaml:1422:1452" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1443:1467" +--8<-- "src/spec/rest.yaml:1453:1477" ``` diff --git a/docs/src/spec/operations/query-table.md b/docs/src/spec/operations/query-table.md index c2d6b0fea..398d6c704 100644 --- a/docs/src/spec/operations/query-table.md +++ b/docs/src/spec/operations/query-table.md @@ -9,7 +9,7 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1540:1639" +--8<-- "src/spec/rest.yaml:1550:1649" ``` ## Response diff --git a/docs/src/spec/operations/register-table.md b/docs/src/spec/operations/register-table.md index 73e1239a5..7dadaf713 100644 --- a/docs/src/spec/operations/register-table.md +++ b/docs/src/spec/operations/register-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1265:1280" +--8<-- "src/spec/rest.yaml:1265:1290" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1281:1292" +--8<-- "src/spec/rest.yaml:1291:1302" ``` \ No newline at end of file diff --git a/docs/src/spec/operations/table-exists.md b/docs/src/spec/operations/table-exists.md index 0d0fc5884..a7e256dce 100644 --- a/docs/src/spec/operations/table-exists.md +++ b/docs/src/spec/operations/table-exists.md @@ -9,7 +9,7 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1919:1933" +--8<-- "src/spec/rest.yaml:1929:1943" ``` ## Response diff --git a/docs/src/spec/operations/update-table.md b/docs/src/spec/operations/update-table.md index 5ca7fa10d..3052f2d8d 100644 --- a/docs/src/spec/operations/update-table.md +++ b/docs/src/spec/operations/update-table.md @@ -9,10 +9,10 @@ ## Request Schema ```yaml ---8<-- "src/spec/rest.yaml:1468:1494" +--8<-- "src/spec/rest.yaml:1478:1504" ``` ## Response Schema ```yaml ---8<-- "src/spec/rest.yaml:1495:1511" +--8<-- "src/spec/rest.yaml:1505:1521" ``` diff --git a/docs/src/spec/rest.yaml b/docs/src/spec/rest.yaml index 1ff292669..581832d3e 100644 --- a/docs/src/spec/rest.yaml +++ b/docs/src/spec/rest.yaml @@ -1111,7 +1111,7 @@ components: description: | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: - * CREATE: the operation fails with 400. + * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. enum: @@ -1273,6 +1273,16 @@ components: type: string location: type: string + mode: + type: string + description: | + There are two modes when trying to register a table, + to differentiate the behavior when a table of the same name already exists: + * CREATE (default): the operation fails with 409. + * OVERWRITE: the existing table registration is replaced with the new registration. + enum: + - CREATE + - OVERWRITE properties: type: object additionalProperties: diff --git a/java/lance-namespace-adapter/src/main/java/com/lancedb/lance/namespace/adapter/ServerToClientRequest.java b/java/lance-namespace-adapter/src/main/java/com/lancedb/lance/namespace/adapter/ServerToClientRequest.java index 5d52f255a..b2dd8f397 100644 --- a/java/lance-namespace-adapter/src/main/java/com/lancedb/lance/namespace/adapter/ServerToClientRequest.java +++ b/java/lance-namespace-adapter/src/main/java/com/lancedb/lance/namespace/adapter/ServerToClientRequest.java @@ -113,6 +113,7 @@ public static RegisterTableRequest registerTable( converted.setId(request.getId()); converted.setLocation(request.getLocation()); converted.setProperties(request.getProperties()); + converted.setMode(RegisterTableRequest.ModeEnum.valueOf(request.getMode().getValue())); return converted; } diff --git a/java/lance-namespace-apache-client/api/openapi.yaml b/java/lance-namespace-apache-client/api/openapi.yaml index 220e5fc15..4a098edea 100644 --- a/java/lance-namespace-apache-client/api/openapi.yaml +++ b/java/lance-namespace-apache-client/api/openapi.yaml @@ -1606,7 +1606,7 @@ components: description: | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: - * CREATE: the operation fails with 400. + * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. enum: @@ -1789,6 +1789,7 @@ components: nullable: true RegisterTableRequest: example: + mode: CREATE location: location id: - id @@ -1802,6 +1803,16 @@ components: type: array location: type: string + mode: + description: | + There are two modes when trying to register a table, + to differentiate the behavior when a table of the same name already exists: + * CREATE (default): the operation fails with 409. + * OVERWRITE: the existing table registration is replaced with the new registration. + enum: + - CREATE + - OVERWRITE + type: string properties: additionalProperties: type: string diff --git a/java/lance-namespace-apache-client/docs/CreateNamespaceRequest.md b/java/lance-namespace-apache-client/docs/CreateNamespaceRequest.md index 29cb272ef..ef9f3aae4 100644 --- a/java/lance-namespace-apache-client/docs/CreateNamespaceRequest.md +++ b/java/lance-namespace-apache-client/docs/CreateNamespaceRequest.md @@ -8,7 +8,7 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| |**id** | **List<String>** | | [optional] | -|**mode** | [**ModeEnum**](#ModeEnum) | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] | +|**mode** | [**ModeEnum**](#ModeEnum) | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] | |**properties** | **Map<String, String>** | | [optional] | diff --git a/java/lance-namespace-apache-client/docs/RegisterTableRequest.md b/java/lance-namespace-apache-client/docs/RegisterTableRequest.md index f402f0aa6..e5d92a29a 100644 --- a/java/lance-namespace-apache-client/docs/RegisterTableRequest.md +++ b/java/lance-namespace-apache-client/docs/RegisterTableRequest.md @@ -9,7 +9,17 @@ |------------ | ------------- | ------------- | -------------| |**id** | **List<String>** | | [optional] | |**location** | **String** | | | +|**mode** | [**ModeEnum**](#ModeEnum) | There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. | [optional] | |**properties** | **Map<String, String>** | | [optional] | +## Enum: ModeEnum + +| Name | Value | +|---- | -----| +| CREATE | "CREATE" | +| OVERWRITE | "OVERWRITE" | + + + diff --git a/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/CreateNamespaceRequest.java b/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/CreateNamespaceRequest.java index 60ab5dc00..37cfdf80e 100644 --- a/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/CreateNamespaceRequest.java +++ b/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/CreateNamespaceRequest.java @@ -43,7 +43,7 @@ public class CreateNamespaceRequest { /** * There are three modes when trying to create a namespace, to differentiate the behavior when a - * namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: + * namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: * the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace * is dropped and a new empty namespace with this name is created. */ @@ -129,7 +129,7 @@ public CreateNamespaceRequest mode(@javax.annotation.Nullable ModeEnum mode) { /** * There are three modes when trying to create a namespace, to differentiate the behavior when a - * namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: + * namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: * the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace * is dropped and a new empty namespace with this name is created. * diff --git a/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/RegisterTableRequest.java b/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/RegisterTableRequest.java index 478615d95..f7f03f70a 100644 --- a/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/RegisterTableRequest.java +++ b/java/lance-namespace-apache-client/src/main/java/com/lancedb/lance/namespace/model/RegisterTableRequest.java @@ -13,9 +13,11 @@ */ package com.lancedb.lance.namespace.model; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -30,6 +32,7 @@ @JsonPropertyOrder({ RegisterTableRequest.JSON_PROPERTY_ID, RegisterTableRequest.JSON_PROPERTY_LOCATION, + RegisterTableRequest.JSON_PROPERTY_MODE, RegisterTableRequest.JSON_PROPERTY_PROPERTIES }) @javax.annotation.Generated( @@ -42,6 +45,46 @@ public class RegisterTableRequest { public static final String JSON_PROPERTY_LOCATION = "location"; @javax.annotation.Nonnull private String location; + /** + * There are two modes when trying to register a table, to differentiate the behavior when a table + * of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: + * the existing table registration is replaced with the new registration. + */ + public enum ModeEnum { + CREATE(String.valueOf("CREATE")), + + OVERWRITE(String.valueOf("OVERWRITE")); + + private String value; + + ModeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ModeEnum fromValue(String value) { + for (ModeEnum b : ModeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + public static final String JSON_PROPERTY_MODE = "mode"; + @javax.annotation.Nullable private ModeEnum mode; + public static final String JSON_PROPERTY_PROPERTIES = "properties"; @javax.annotation.Nullable private Map properties = new HashMap<>(); @@ -103,6 +146,32 @@ public void setLocation(@javax.annotation.Nonnull String location) { this.location = location; } + public RegisterTableRequest mode(@javax.annotation.Nullable ModeEnum mode) { + + this.mode = mode; + return this; + } + + /** + * There are two modes when trying to register a table, to differentiate the behavior when a table + * of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: + * the existing table registration is replaced with the new registration. + * + * @return mode + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ModeEnum getMode() { + return mode; + } + + @JsonProperty(JSON_PROPERTY_MODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMode(@javax.annotation.Nullable ModeEnum mode) { + this.mode = mode; + } + public RegisterTableRequest properties( @javax.annotation.Nullable Map properties) { @@ -147,12 +216,13 @@ public boolean equals(Object o) { RegisterTableRequest registerTableRequest = (RegisterTableRequest) o; return Objects.equals(this.id, registerTableRequest.id) && Objects.equals(this.location, registerTableRequest.location) + && Objects.equals(this.mode, registerTableRequest.mode) && Objects.equals(this.properties, registerTableRequest.properties); } @Override public int hashCode() { - return Objects.hash(id, location, properties); + return Objects.hash(id, location, mode, properties); } @Override @@ -161,6 +231,7 @@ public String toString() { sb.append("class RegisterTableRequest {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); sb.append("}"); return sb.toString(); @@ -245,6 +316,21 @@ public String toUrlQueryString(String prefix) { } } + // add `mode` to the URL query string + if (getMode() != null) { + try { + joiner.add( + String.format( + "%smode%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getMode()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + // add `properties` to the URL query string if (getProperties() != null) { for (String _key : getProperties().keySet()) { diff --git a/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/CreateNamespaceRequest.java b/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/CreateNamespaceRequest.java index 4f4f04ea9..8ccddd0c7 100644 --- a/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/CreateNamespaceRequest.java +++ b/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/CreateNamespaceRequest.java @@ -39,7 +39,7 @@ public class CreateNamespaceRequest { /** * There are three modes when trying to create a namespace, to differentiate the behavior when a - * namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: + * namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: * the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace * is dropped and a new empty namespace with this name is created. */ @@ -116,7 +116,7 @@ public CreateNamespaceRequest mode(ModeEnum mode) { /** * There are three modes when trying to create a namespace, to differentiate the behavior when a - * namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: + * namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: * the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace * is dropped and a new empty namespace with this name is created. * @@ -125,7 +125,7 @@ public CreateNamespaceRequest mode(ModeEnum mode) { @Schema( name = "mode", description = - "There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. ", + "There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. ", requiredMode = Schema.RequiredMode.NOT_REQUIRED) @JsonProperty("mode") public ModeEnum getMode() { diff --git a/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/RegisterTableRequest.java b/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/RegisterTableRequest.java index 32b49a8c4..5adc77724 100644 --- a/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/RegisterTableRequest.java +++ b/java/lance-namespace-springboot-server/src/main/java/com/lancedb/lance/namespace/server/springboot/model/RegisterTableRequest.java @@ -13,7 +13,9 @@ */ package com.lancedb.lance.namespace.server.springboot.model; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.v3.oas.annotations.media.Schema; import javax.annotation.Generated; @@ -37,6 +39,45 @@ public class RegisterTableRequest { private String location; + /** + * There are two modes when trying to register a table, to differentiate the behavior when a table + * of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: + * the existing table registration is replaced with the new registration. + */ + public enum ModeEnum { + CREATE("CREATE"), + + OVERWRITE("OVERWRITE"); + + private String value; + + ModeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ModeEnum fromValue(String value) { + for (ModeEnum b : ModeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + private ModeEnum mode; + @Valid private Map properties = new HashMap<>(); public RegisterTableRequest() { @@ -97,6 +138,32 @@ public void setLocation(String location) { this.location = location; } + public RegisterTableRequest mode(ModeEnum mode) { + this.mode = mode; + return this; + } + + /** + * There are two modes when trying to register a table, to differentiate the behavior when a table + * of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: + * the existing table registration is replaced with the new registration. + * + * @return mode + */ + @Schema( + name = "mode", + description = + "There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. ", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("mode") + public ModeEnum getMode() { + return mode; + } + + public void setMode(ModeEnum mode) { + this.mode = mode; + } + public RegisterTableRequest properties(Map properties) { this.properties = properties; return this; @@ -136,12 +203,13 @@ public boolean equals(Object o) { RegisterTableRequest registerTableRequest = (RegisterTableRequest) o; return Objects.equals(this.id, registerTableRequest.id) && Objects.equals(this.location, registerTableRequest.location) + && Objects.equals(this.mode, registerTableRequest.mode) && Objects.equals(this.properties, registerTableRequest.properties); } @Override public int hashCode() { - return Objects.hash(id, location, properties); + return Objects.hash(id, location, mode, properties); } @Override @@ -150,6 +218,7 @@ public String toString() { sb.append("class RegisterTableRequest {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" mode: ").append(toIndentedString(mode)).append("\n"); sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); sb.append("}"); return sb.toString(); diff --git a/python/lance_namespace/pyproject.toml b/python/lance_namespace/pyproject.toml index acd26c71e..f111721d8 100644 --- a/python/lance_namespace/pyproject.toml +++ b/python/lance_namespace/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lance-namespace" -version = "0.1.0" +version = "0.0.5" description = "Python client for Lance Namespace API" readme = "README.md" authors = [ diff --git a/python/lance_namespace_urllib3_client/docs/CreateNamespaceRequest.md b/python/lance_namespace_urllib3_client/docs/CreateNamespaceRequest.md index 9b11e7be5..9ba031eca 100644 --- a/python/lance_namespace_urllib3_client/docs/CreateNamespaceRequest.md +++ b/python/lance_namespace_urllib3_client/docs/CreateNamespaceRequest.md @@ -6,7 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **List[str]** | | [optional] -**mode** | **str** | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] +**mode** | **str** | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] **properties** | **Dict[str, str]** | | [optional] ## Example diff --git a/python/lance_namespace_urllib3_client/docs/RegisterTableRequest.md b/python/lance_namespace_urllib3_client/docs/RegisterTableRequest.md index 11fe2c99d..0b0970461 100644 --- a/python/lance_namespace_urllib3_client/docs/RegisterTableRequest.md +++ b/python/lance_namespace_urllib3_client/docs/RegisterTableRequest.md @@ -7,6 +7,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **List[str]** | | [optional] **location** | **str** | | +**mode** | **str** | There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. | [optional] **properties** | **Dict[str, str]** | | [optional] ## Example diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/create_namespace_request.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/create_namespace_request.py index 12d87f943..3be11fea6 100644 --- a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/create_namespace_request.py +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/create_namespace_request.py @@ -27,7 +27,7 @@ class CreateNamespaceRequest(BaseModel): CreateNamespaceRequest """ # noqa: E501 id: Optional[List[StrictStr]] = None - mode: Optional[StrictStr] = Field(default=None, description="There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. ") + mode: Optional[StrictStr] = Field(default=None, description="There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. ") properties: Optional[Dict[str, StrictStr]] = None __properties: ClassVar[List[str]] = ["id", "mode", "properties"] diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/register_table_request.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/register_table_request.py index cdcf6b7aa..af53a221d 100644 --- a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/register_table_request.py +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/register_table_request.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictStr +from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self @@ -28,8 +28,19 @@ class RegisterTableRequest(BaseModel): """ # noqa: E501 id: Optional[List[StrictStr]] = None location: StrictStr + mode: Optional[StrictStr] = Field(default=None, description="There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. ") properties: Optional[Dict[str, StrictStr]] = None - __properties: ClassVar[List[str]] = ["id", "location", "properties"] + __properties: ClassVar[List[str]] = ["id", "location", "mode", "properties"] + + @field_validator('mode') + def mode_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['CREATE', 'OVERWRITE']): + raise ValueError("must be one of enum values ('CREATE', 'OVERWRITE')") + return value model_config = ConfigDict( populate_by_name=True, @@ -84,6 +95,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "id": obj.get("id"), "location": obj.get("location"), + "mode": obj.get("mode"), "properties": obj.get("properties") }) return _obj diff --git a/python/lance_namespace_urllib3_client/test/test_register_table_request.py b/python/lance_namespace_urllib3_client/test/test_register_table_request.py index 25406b7a7..44b49eb0c 100644 --- a/python/lance_namespace_urllib3_client/test/test_register_table_request.py +++ b/python/lance_namespace_urllib3_client/test/test_register_table_request.py @@ -39,6 +39,7 @@ def make_instance(self, include_optional) -> RegisterTableRequest: '' ], location = '', + mode = 'CREATE', properties = { 'key' : '' } diff --git a/rust/lance-namespace-reqwest-client/docs/CreateNamespaceRequest.md b/rust/lance-namespace-reqwest-client/docs/CreateNamespaceRequest.md index 02f43d7e3..ad6043e6e 100644 --- a/rust/lance-namespace-reqwest-client/docs/CreateNamespaceRequest.md +++ b/rust/lance-namespace-reqwest-client/docs/CreateNamespaceRequest.md @@ -5,7 +5,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | Option<**Vec**> | | [optional] -**mode** | Option<**String**> | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] +**mode** | Option<**String**> | There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. | [optional] **properties** | Option<**std::collections::HashMap**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/rust/lance-namespace-reqwest-client/docs/RegisterTableRequest.md b/rust/lance-namespace-reqwest-client/docs/RegisterTableRequest.md index 55e3320c1..e516061f2 100644 --- a/rust/lance-namespace-reqwest-client/docs/RegisterTableRequest.md +++ b/rust/lance-namespace-reqwest-client/docs/RegisterTableRequest.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | Option<**Vec**> | | [optional] **location** | **String** | | +**mode** | Option<**String**> | There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. | [optional] **properties** | Option<**std::collections::HashMap**> | | [optional] [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/rust/lance-namespace-reqwest-client/src/models/create_namespace_request.rs b/rust/lance-namespace-reqwest-client/src/models/create_namespace_request.rs index d41830a65..7326f916d 100644 --- a/rust/lance-namespace-reqwest-client/src/models/create_namespace_request.rs +++ b/rust/lance-namespace-reqwest-client/src/models/create_namespace_request.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; pub struct CreateNamespaceRequest { #[serde(rename = "id", skip_serializing_if = "Option::is_none")] pub id: Option>, - /// There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. + /// There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. #[serde(rename = "mode", skip_serializing_if = "Option::is_none")] pub mode: Option, #[serde(rename = "properties", skip_serializing_if = "Option::is_none")] @@ -31,7 +31,7 @@ impl CreateNamespaceRequest { } } } -/// There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 400. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. +/// There are three modes when trying to create a namespace, to differentiate the behavior when a namespace of the same name already exists: * CREATE: the operation fails with 409. * EXIST_OK: the operation succeeds and the existing namespace is kept. * OVERWRITE: the existing namespace is dropped and a new empty namespace with this name is created. #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] pub enum Mode { #[serde(rename = "CREATE")] diff --git a/rust/lance-namespace-reqwest-client/src/models/register_table_request.rs b/rust/lance-namespace-reqwest-client/src/models/register_table_request.rs index de4d40449..65f8b2c63 100644 --- a/rust/lance-namespace-reqwest-client/src/models/register_table_request.rs +++ b/rust/lance-namespace-reqwest-client/src/models/register_table_request.rs @@ -17,6 +17,9 @@ pub struct RegisterTableRequest { pub id: Option>, #[serde(rename = "location")] pub location: String, + /// There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. + #[serde(rename = "mode", skip_serializing_if = "Option::is_none")] + pub mode: Option, #[serde(rename = "properties", skip_serializing_if = "Option::is_none")] pub properties: Option>, } @@ -26,8 +29,23 @@ impl RegisterTableRequest { RegisterTableRequest { id: None, location, + mode: None, properties: None, } } } +/// There are two modes when trying to register a table, to differentiate the behavior when a table of the same name already exists: * CREATE (default): the operation fails with 409. * OVERWRITE: the existing table registration is replaced with the new registration. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum Mode { + #[serde(rename = "CREATE")] + Create, + #[serde(rename = "OVERWRITE")] + Overwrite, +} + +impl Default for Mode { + fn default() -> Mode { + Self::Create + } +} diff --git a/uv.lock b/uv.lock index e5e76dad1..254659bb9 100644 --- a/uv.lock +++ b/uv.lock @@ -582,7 +582,7 @@ wheels = [ [[package]] name = "lance-namespace" -version = "0.1.0" +version = "0.0.5" source = { editable = "python/lance_namespace" } dependencies = [ { name = "lance-namespace-urllib3-client" },