diff --git a/docs/src/rest.yaml b/docs/src/rest.yaml index a5cb33be..0e0dbfc5 100644 --- a/docs/src/rest.yaml +++ b/docs/src/rest.yaml @@ -4152,6 +4152,69 @@ components: type: string description: Optional transaction identifier + PartitionTransform: + type: object + description: Well-known partition transform + required: + - type + properties: + type: + type: string + description: Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) + num_buckets: + type: integer + description: Number of buckets for bucket transforms + width: + type: integer + description: Truncation width for truncate transforms + + PartitionField: + type: object + description: Partition field definition + required: + - field_id + - source_ids + - result_type + properties: + field_id: + type: string + description: Unique identifier for this partition field (must not be renamed) + example: "event_year" + source_ids: + type: array + items: + type: integer + description: Field IDs of the source columns in the schema + example: [1] + transform: + $ref: '#/components/schemas/PartitionTransform' + description: Well-known partition transform. Exactly one of transform or expression must be specified. + expression: + type: string + description: DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified. + example: "date_part('year', col0)" + result_type: + $ref: '#/components/schemas/JsonArrowDataType' + description: The output type of the partition value (JsonArrowDataType format) + example: {"type": "int32"} + + PartitionSpec: + type: object + description: Partition spec definition + required: + - id + - fields + properties: + id: + type: integer + description: The spec version ID + example: 1 + fields: + type: array + items: + $ref: '#/components/schemas/PartitionField' + description: Array of partition field definitions + responses: ListNamespacesResponse: description: A list of namespaces diff --git a/java/lance-namespace-apache-client/README.md b/java/lance-namespace-apache-client/README.md index de27f9fa..008ac94c 100644 --- a/java/lance-namespace-apache-client/README.md +++ b/java/lance-namespace-apache-client/README.md @@ -319,6 +319,9 @@ Class | Method | HTTP request | Description - [MultiMatchQuery](docs/MultiMatchQuery.md) - [NamespaceExistsRequest](docs/NamespaceExistsRequest.md) - [NewColumnTransform](docs/NewColumnTransform.md) + - [PartitionField](docs/PartitionField.md) + - [PartitionSpec](docs/PartitionSpec.md) + - [PartitionTransform](docs/PartitionTransform.md) - [PhraseQuery](docs/PhraseQuery.md) - [QueryTableRequest](docs/QueryTableRequest.md) - [QueryTableRequestColumns](docs/QueryTableRequestColumns.md) diff --git a/java/lance-namespace-apache-client/api/openapi.yaml b/java/lance-namespace-apache-client/api/openapi.yaml index cf73d266..25347ff3 100644 --- a/java/lance-namespace-apache-client/api/openapi.yaml +++ b/java/lance-namespace-apache-client/api/openapi.yaml @@ -6169,6 +6169,63 @@ components: transaction_id: description: Optional transaction identifier type: string + PartitionTransform: + description: Well-known partition transform + properties: + type: + description: "Transform type (identity, year, month, day, hour, bucket,\ + \ multi_bucket, truncate)" + type: string + num_buckets: + description: Number of buckets for bucket transforms + type: integer + width: + description: Truncation width for truncate transforms + type: integer + required: + - type + PartitionField: + description: Partition field definition + properties: + field_id: + description: Unique identifier for this partition field (must not be renamed) + example: event_year + type: string + source_ids: + description: Field IDs of the source columns in the schema + example: + - 1 + items: + type: integer + type: array + transform: + $ref: '#/components/schemas/PartitionTransform' + expression: + description: "DataFusion SQL expression using col0, col1, ... as column\ + \ references. Exactly one of transform or expression must be specified." + example: "date_part('year', col0)" + type: string + result_type: + $ref: '#/components/schemas/JsonArrowDataType' + required: + - field_id + - result_type + - source_ids + PartitionSpec: + description: Partition spec definition + properties: + id: + description: The spec version ID + example: 1 + type: integer + fields: + description: Array of partition field definitions + items: + $ref: '#/components/schemas/PartitionField' + type: array + required: + - fields + - id QueryTableRequest_columns: description: | Optional columns to return. Provide either column_names or column_aliases, not both. diff --git a/java/lance-namespace-apache-client/docs/PartitionField.md b/java/lance-namespace-apache-client/docs/PartitionField.md new file mode 100644 index 00000000..253ec1a8 --- /dev/null +++ b/java/lance-namespace-apache-client/docs/PartitionField.md @@ -0,0 +1,18 @@ + + +# PartitionField + +Partition field definition + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**fieldId** | **String** | Unique identifier for this partition field (must not be renamed) | | +|**sourceIds** | **List<Integer>** | Field IDs of the source columns in the schema | | +|**transform** | [**PartitionTransform**](PartitionTransform.md) | Well-known partition transform. Exactly one of transform or expression must be specified. | [optional] | +|**expression** | **String** | DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified. | [optional] | +|**resultType** | [**JsonArrowDataType**](JsonArrowDataType.md) | The output type of the partition value (JsonArrowDataType format) | | + + + diff --git a/java/lance-namespace-apache-client/docs/PartitionSpec.md b/java/lance-namespace-apache-client/docs/PartitionSpec.md new file mode 100644 index 00000000..f15edea4 --- /dev/null +++ b/java/lance-namespace-apache-client/docs/PartitionSpec.md @@ -0,0 +1,15 @@ + + +# PartitionSpec + +Partition spec definition + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **Integer** | The spec version ID | | +|**fields** | [**List<PartitionField>**](PartitionField.md) | Array of partition field definitions | | + + + diff --git a/java/lance-namespace-apache-client/docs/PartitionTransform.md b/java/lance-namespace-apache-client/docs/PartitionTransform.md new file mode 100644 index 00000000..eed54592 --- /dev/null +++ b/java/lance-namespace-apache-client/docs/PartitionTransform.md @@ -0,0 +1,16 @@ + + +# PartitionTransform + +Well-known partition transform + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **String** | Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) | | +|**numBuckets** | **Integer** | Number of buckets for bucket transforms | [optional] | +|**width** | **Integer** | Truncation width for truncate transforms | [optional] | + + + diff --git a/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionField.java b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionField.java new file mode 100644 index 00000000..babcd65a --- /dev/null +++ b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionField.java @@ -0,0 +1,325 @@ +/* + * 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. + */ +package org.lance.namespace.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** Partition field definition */ +@JsonPropertyOrder({ + PartitionField.JSON_PROPERTY_FIELD_ID, + PartitionField.JSON_PROPERTY_SOURCE_IDS, + PartitionField.JSON_PROPERTY_TRANSFORM, + PartitionField.JSON_PROPERTY_EXPRESSION, + PartitionField.JSON_PROPERTY_RESULT_TYPE +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.12.0") +public class PartitionField { + public static final String JSON_PROPERTY_FIELD_ID = "field_id"; + @javax.annotation.Nonnull private String fieldId; + + public static final String JSON_PROPERTY_SOURCE_IDS = "source_ids"; + @javax.annotation.Nonnull private List sourceIds = new ArrayList<>(); + + public static final String JSON_PROPERTY_TRANSFORM = "transform"; + @javax.annotation.Nullable private PartitionTransform transform; + + public static final String JSON_PROPERTY_EXPRESSION = "expression"; + @javax.annotation.Nullable private String expression; + + public static final String JSON_PROPERTY_RESULT_TYPE = "result_type"; + @javax.annotation.Nonnull private JsonArrowDataType resultType; + + public PartitionField() {} + + public PartitionField fieldId(@javax.annotation.Nonnull String fieldId) { + + this.fieldId = fieldId; + return this; + } + + /** + * Unique identifier for this partition field (must not be renamed) + * + * @return fieldId + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_FIELD_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFieldId() { + return fieldId; + } + + @JsonProperty(JSON_PROPERTY_FIELD_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFieldId(@javax.annotation.Nonnull String fieldId) { + this.fieldId = fieldId; + } + + public PartitionField sourceIds(@javax.annotation.Nonnull List sourceIds) { + + this.sourceIds = sourceIds; + return this; + } + + public PartitionField addSourceIdsItem(Integer sourceIdsItem) { + if (this.sourceIds == null) { + this.sourceIds = new ArrayList<>(); + } + this.sourceIds.add(sourceIdsItem); + return this; + } + + /** + * Field IDs of the source columns in the schema + * + * @return sourceIds + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_SOURCE_IDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getSourceIds() { + return sourceIds; + } + + @JsonProperty(JSON_PROPERTY_SOURCE_IDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setSourceIds(@javax.annotation.Nonnull List sourceIds) { + this.sourceIds = sourceIds; + } + + public PartitionField transform(@javax.annotation.Nullable PartitionTransform transform) { + + this.transform = transform; + return this; + } + + /** + * Well-known partition transform. Exactly one of transform or expression must be specified. + * + * @return transform + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TRANSFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PartitionTransform getTransform() { + return transform; + } + + @JsonProperty(JSON_PROPERTY_TRANSFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTransform(@javax.annotation.Nullable PartitionTransform transform) { + this.transform = transform; + } + + public PartitionField expression(@javax.annotation.Nullable String expression) { + + this.expression = expression; + return this; + } + + /** + * DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform + * or expression must be specified. + * + * @return expression + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_EXPRESSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getExpression() { + return expression; + } + + @JsonProperty(JSON_PROPERTY_EXPRESSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpression(@javax.annotation.Nullable String expression) { + this.expression = expression; + } + + public PartitionField resultType(@javax.annotation.Nonnull JsonArrowDataType resultType) { + + this.resultType = resultType; + return this; + } + + /** + * The output type of the partition value (JsonArrowDataType format) + * + * @return resultType + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_RESULT_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public JsonArrowDataType getResultType() { + return resultType; + } + + @JsonProperty(JSON_PROPERTY_RESULT_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setResultType(@javax.annotation.Nonnull JsonArrowDataType resultType) { + this.resultType = resultType; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionField partitionField = (PartitionField) o; + return Objects.equals(this.fieldId, partitionField.fieldId) + && Objects.equals(this.sourceIds, partitionField.sourceIds) + && Objects.equals(this.transform, partitionField.transform) + && Objects.equals(this.expression, partitionField.expression) + && Objects.equals(this.resultType, partitionField.resultType); + } + + @Override + public int hashCode() { + return Objects.hash(fieldId, sourceIds, transform, expression, resultType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionField {\n"); + sb.append(" fieldId: ").append(toIndentedString(fieldId)).append("\n"); + sb.append(" sourceIds: ").append(toIndentedString(sourceIds)).append("\n"); + sb.append(" transform: ").append(toIndentedString(transform)).append("\n"); + sb.append(" expression: ").append(toIndentedString(expression)).append("\n"); + sb.append(" resultType: ").append(toIndentedString(resultType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `field_id` to the URL query string + if (getFieldId() != null) { + try { + joiner.add( + String.format( + "%sfield_id%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getFieldId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `source_ids` to the URL query string + if (getSourceIds() != null) { + for (int i = 0; i < getSourceIds().size(); i++) { + try { + joiner.add( + String.format( + "%ssource_ids%s%s=%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode(String.valueOf(getSourceIds().get(i)), "UTF-8") + .replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + } + + // add `transform` to the URL query string + if (getTransform() != null) { + joiner.add(getTransform().toUrlQueryString(prefix + "transform" + suffix)); + } + + // add `expression` to the URL query string + if (getExpression() != null) { + try { + joiner.add( + String.format( + "%sexpression%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getExpression()), "UTF-8") + .replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `result_type` to the URL query string + if (getResultType() != null) { + joiner.add(getResultType().toUrlQueryString(prefix + "result_type" + suffix)); + } + + return joiner.toString(); + } +} diff --git a/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionSpec.java b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionSpec.java new file mode 100644 index 00000000..c6305d94 --- /dev/null +++ b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionSpec.java @@ -0,0 +1,203 @@ +/* + * 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. + */ +package org.lance.namespace.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** Partition spec definition */ +@JsonPropertyOrder({PartitionSpec.JSON_PROPERTY_ID, PartitionSpec.JSON_PROPERTY_FIELDS}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.12.0") +public class PartitionSpec { + public static final String JSON_PROPERTY_ID = "id"; + @javax.annotation.Nonnull private Integer id; + + public static final String JSON_PROPERTY_FIELDS = "fields"; + @javax.annotation.Nonnull private List fields = new ArrayList<>(); + + public PartitionSpec() {} + + public PartitionSpec id(@javax.annotation.Nonnull Integer id) { + + this.id = id; + return this; + } + + /** + * The spec version ID + * + * @return id + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(@javax.annotation.Nonnull Integer id) { + this.id = id; + } + + public PartitionSpec fields(@javax.annotation.Nonnull List fields) { + + this.fields = fields; + return this; + } + + public PartitionSpec addFieldsItem(PartitionField fieldsItem) { + if (this.fields == null) { + this.fields = new ArrayList<>(); + } + this.fields.add(fieldsItem); + return this; + } + + /** + * Array of partition field definitions + * + * @return fields + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_FIELDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getFields() { + return fields; + } + + @JsonProperty(JSON_PROPERTY_FIELDS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFields(@javax.annotation.Nonnull List fields) { + this.fields = fields; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionSpec partitionSpec = (PartitionSpec) o; + return Objects.equals(this.id, partitionSpec.id) + && Objects.equals(this.fields, partitionSpec.fields); + } + + @Override + public int hashCode() { + return Objects.hash(id, fields); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionSpec {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `id` to the URL query string + if (getId() != null) { + try { + joiner.add( + String.format( + "%sid%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getId()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `fields` to the URL query string + if (getFields() != null) { + for (int i = 0; i < getFields().size(); i++) { + if (getFields().get(i) != null) { + joiner.add( + getFields() + .get(i) + .toUrlQueryString( + String.format( + "%sfields%s%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format("%s%d%s", containerPrefix, i, containerSuffix)))); + } + } + } + + return joiner.toString(); + } +} diff --git a/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionTransform.java b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionTransform.java new file mode 100644 index 00000000..73dc3f30 --- /dev/null +++ b/java/lance-namespace-apache-client/src/main/java/org/lance/namespace/model/PartitionTransform.java @@ -0,0 +1,238 @@ +/* + * 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. + */ +package org.lance.namespace.model; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.Objects; +import java.util.StringJoiner; + +/** Well-known partition transform */ +@JsonPropertyOrder({ + PartitionTransform.JSON_PROPERTY_TYPE, + PartitionTransform.JSON_PROPERTY_NUM_BUCKETS, + PartitionTransform.JSON_PROPERTY_WIDTH +}) +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.12.0") +public class PartitionTransform { + public static final String JSON_PROPERTY_TYPE = "type"; + @javax.annotation.Nonnull private String type; + + public static final String JSON_PROPERTY_NUM_BUCKETS = "num_buckets"; + @javax.annotation.Nullable private Integer numBuckets; + + public static final String JSON_PROPERTY_WIDTH = "width"; + @javax.annotation.Nullable private Integer width; + + public PartitionTransform() {} + + public PartitionTransform type(@javax.annotation.Nonnull String type) { + + this.type = type; + return this; + } + + /** + * Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) + * + * @return type + */ + @javax.annotation.Nonnull + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + public PartitionTransform numBuckets(@javax.annotation.Nullable Integer numBuckets) { + + this.numBuckets = numBuckets; + return this; + } + + /** + * Number of buckets for bucket transforms + * + * @return numBuckets + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NUM_BUCKETS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getNumBuckets() { + return numBuckets; + } + + @JsonProperty(JSON_PROPERTY_NUM_BUCKETS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumBuckets(@javax.annotation.Nullable Integer numBuckets) { + this.numBuckets = numBuckets; + } + + public PartitionTransform width(@javax.annotation.Nullable Integer width) { + + this.width = width; + return this; + } + + /** + * Truncation width for truncate transforms + * + * @return width + */ + @javax.annotation.Nullable + @JsonProperty(JSON_PROPERTY_WIDTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getWidth() { + return width; + } + + @JsonProperty(JSON_PROPERTY_WIDTH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWidth(@javax.annotation.Nullable Integer width) { + this.width = width; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionTransform partitionTransform = (PartitionTransform) o; + return Objects.equals(this.type, partitionTransform.type) + && Objects.equals(this.numBuckets, partitionTransform.numBuckets) + && Objects.equals(this.width, partitionTransform.width); + } + + @Override + public int hashCode() { + return Objects.hash(type, numBuckets, width); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionTransform {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" numBuckets: ").append(toIndentedString(numBuckets)).append("\n"); + sb.append(" width: ").append(toIndentedString(width)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Convert the instance into URL query string. + * + * @return URL query string + */ + public String toUrlQueryString() { + return toUrlQueryString(null); + } + + /** + * Convert the instance into URL query string. + * + * @param prefix prefix of the query string + * @return URL query string + */ + public String toUrlQueryString(String prefix) { + String suffix = ""; + String containerSuffix = ""; + String containerPrefix = ""; + if (prefix == null) { + // style=form, explode=true, e.g. /pet?name=cat&type=manx + prefix = ""; + } else { + // deepObject style e.g. /pet?id[name]=cat&id[type]=manx + prefix = prefix + "["; + suffix = "]"; + containerSuffix = "]"; + containerPrefix = "["; + } + + StringJoiner joiner = new StringJoiner("&"); + + // add `type` to the URL query string + if (getType() != null) { + try { + joiner.add( + String.format( + "%stype%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getType()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `num_buckets` to the URL query string + if (getNumBuckets() != null) { + try { + joiner.add( + String.format( + "%snum_buckets%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getNumBuckets()), "UTF-8") + .replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + // add `width` to the URL query string + if (getWidth() != null) { + try { + joiner.add( + String.format( + "%swidth%s=%s", + prefix, + suffix, + URLEncoder.encode(String.valueOf(getWidth()), "UTF-8").replaceAll("\\+", "%20"))); + } catch (UnsupportedEncodingException e) { + // Should never happen, UTF-8 is always supported + throw new RuntimeException(e); + } + } + + return joiner.toString(); + } +} diff --git a/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionField.java b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionField.java new file mode 100644 index 00000000..dc5f6102 --- /dev/null +++ b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionField.java @@ -0,0 +1,233 @@ +/* + * 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. + */ +package org.lance.namespace.server.springboot.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.annotation.Generated; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Partition field definition */ +@Schema(name = "PartitionField", description = "Partition field definition") +@Generated( + value = "org.openapitools.codegen.languages.SpringCodegen", + comments = "Generator version: 7.12.0") +public class PartitionField { + + private String fieldId; + + @Valid private List sourceIds = new ArrayList<>(); + + private PartitionTransform transform; + + private String expression; + + private JsonArrowDataType resultType; + + public PartitionField() { + super(); + } + + /** Constructor with only required parameters */ + public PartitionField(String fieldId, List sourceIds, JsonArrowDataType resultType) { + this.fieldId = fieldId; + this.sourceIds = sourceIds; + this.resultType = resultType; + } + + public PartitionField fieldId(String fieldId) { + this.fieldId = fieldId; + return this; + } + + /** + * Unique identifier for this partition field (must not be renamed) + * + * @return fieldId + */ + @NotNull + @Schema( + name = "field_id", + example = "event_year", + description = "Unique identifier for this partition field (must not be renamed)", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("field_id") + public String getFieldId() { + return fieldId; + } + + public void setFieldId(String fieldId) { + this.fieldId = fieldId; + } + + public PartitionField sourceIds(List sourceIds) { + this.sourceIds = sourceIds; + return this; + } + + public PartitionField addSourceIdsItem(Integer sourceIdsItem) { + if (this.sourceIds == null) { + this.sourceIds = new ArrayList<>(); + } + this.sourceIds.add(sourceIdsItem); + return this; + } + + /** + * Field IDs of the source columns in the schema + * + * @return sourceIds + */ + @NotNull + @Schema( + name = "source_ids", + example = "[1]", + description = "Field IDs of the source columns in the schema", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("source_ids") + public List getSourceIds() { + return sourceIds; + } + + public void setSourceIds(List sourceIds) { + this.sourceIds = sourceIds; + } + + public PartitionField transform(PartitionTransform transform) { + this.transform = transform; + return this; + } + + /** + * Well-known partition transform. Exactly one of transform or expression must be specified. + * + * @return transform + */ + @Valid + @Schema( + name = "transform", + description = + "Well-known partition transform. Exactly one of transform or expression must be specified.", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("transform") + public PartitionTransform getTransform() { + return transform; + } + + public void setTransform(PartitionTransform transform) { + this.transform = transform; + } + + public PartitionField expression(String expression) { + this.expression = expression; + return this; + } + + /** + * DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform + * or expression must be specified. + * + * @return expression + */ + @Schema( + name = "expression", + example = "date_part('year', col0)", + description = + "DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified.", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("expression") + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } + + public PartitionField resultType(JsonArrowDataType resultType) { + this.resultType = resultType; + return this; + } + + /** + * The output type of the partition value (JsonArrowDataType format) + * + * @return resultType + */ + @NotNull + @Valid + @Schema( + name = "result_type", + example = "{type=int32}", + description = "The output type of the partition value (JsonArrowDataType format)", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("result_type") + public JsonArrowDataType getResultType() { + return resultType; + } + + public void setResultType(JsonArrowDataType resultType) { + this.resultType = resultType; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionField partitionField = (PartitionField) o; + return Objects.equals(this.fieldId, partitionField.fieldId) + && Objects.equals(this.sourceIds, partitionField.sourceIds) + && Objects.equals(this.transform, partitionField.transform) + && Objects.equals(this.expression, partitionField.expression) + && Objects.equals(this.resultType, partitionField.resultType); + } + + @Override + public int hashCode() { + return Objects.hash(fieldId, sourceIds, transform, expression, resultType); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionField {\n"); + sb.append(" fieldId: ").append(toIndentedString(fieldId)).append("\n"); + sb.append(" sourceIds: ").append(toIndentedString(sourceIds)).append("\n"); + sb.append(" transform: ").append(toIndentedString(transform)).append("\n"); + sb.append(" expression: ").append(toIndentedString(expression)).append("\n"); + sb.append(" resultType: ").append(toIndentedString(resultType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionSpec.java b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionSpec.java new file mode 100644 index 00000000..577d01bc --- /dev/null +++ b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionSpec.java @@ -0,0 +1,143 @@ +/* + * 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. + */ +package org.lance.namespace.server.springboot.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.annotation.Generated; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; + +import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Partition spec definition */ +@Schema(name = "PartitionSpec", description = "Partition spec definition") +@Generated( + value = "org.openapitools.codegen.languages.SpringCodegen", + comments = "Generator version: 7.12.0") +public class PartitionSpec { + + private Integer id; + + @Valid private List<@Valid PartitionField> fields = new ArrayList<>(); + + public PartitionSpec() { + super(); + } + + /** Constructor with only required parameters */ + public PartitionSpec(Integer id, List<@Valid PartitionField> fields) { + this.id = id; + this.fields = fields; + } + + public PartitionSpec id(Integer id) { + this.id = id; + return this; + } + + /** + * The spec version ID + * + * @return id + */ + @NotNull + @Schema( + name = "id", + example = "1", + description = "The spec version ID", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("id") + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public PartitionSpec fields(List<@Valid PartitionField> fields) { + this.fields = fields; + return this; + } + + public PartitionSpec addFieldsItem(PartitionField fieldsItem) { + if (this.fields == null) { + this.fields = new ArrayList<>(); + } + this.fields.add(fieldsItem); + return this; + } + + /** + * Array of partition field definitions + * + * @return fields + */ + @NotNull + @Valid + @Schema( + name = "fields", + description = "Array of partition field definitions", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("fields") + public List<@Valid PartitionField> getFields() { + return fields; + } + + public void setFields(List<@Valid PartitionField> fields) { + this.fields = fields; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionSpec partitionSpec = (PartitionSpec) o; + return Objects.equals(this.id, partitionSpec.id) + && Objects.equals(this.fields, partitionSpec.fields); + } + + @Override + public int hashCode() { + return Objects.hash(id, fields); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionSpec {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" fields: ").append(toIndentedString(fields)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionTransform.java b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionTransform.java new file mode 100644 index 00000000..eca77f74 --- /dev/null +++ b/java/lance-namespace-springboot-server/src/main/java/org/lance/namespace/server/springboot/model/PartitionTransform.java @@ -0,0 +1,156 @@ +/* + * 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. + */ +package org.lance.namespace.server.springboot.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.annotation.Generated; +import jakarta.validation.constraints.*; + +import java.util.*; +import java.util.Objects; + +/** Well-known partition transform */ +@Schema(name = "PartitionTransform", description = "Well-known partition transform") +@Generated( + value = "org.openapitools.codegen.languages.SpringCodegen", + comments = "Generator version: 7.12.0") +public class PartitionTransform { + + private String type; + + private Integer numBuckets; + + private Integer width; + + public PartitionTransform() { + super(); + } + + /** Constructor with only required parameters */ + public PartitionTransform(String type) { + this.type = type; + } + + public PartitionTransform type(String type) { + this.type = type; + return this; + } + + /** + * Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) + * + * @return type + */ + @NotNull + @Schema( + name = "type", + description = + "Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate)", + requiredMode = Schema.RequiredMode.REQUIRED) + @JsonProperty("type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public PartitionTransform numBuckets(Integer numBuckets) { + this.numBuckets = numBuckets; + return this; + } + + /** + * Number of buckets for bucket transforms + * + * @return numBuckets + */ + @Schema( + name = "num_buckets", + description = "Number of buckets for bucket transforms", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("num_buckets") + public Integer getNumBuckets() { + return numBuckets; + } + + public void setNumBuckets(Integer numBuckets) { + this.numBuckets = numBuckets; + } + + public PartitionTransform width(Integer width) { + this.width = width; + return this; + } + + /** + * Truncation width for truncate transforms + * + * @return width + */ + @Schema( + name = "width", + description = "Truncation width for truncate transforms", + requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @JsonProperty("width") + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartitionTransform partitionTransform = (PartitionTransform) o; + return Objects.equals(this.type, partitionTransform.type) + && Objects.equals(this.numBuckets, partitionTransform.numBuckets) + && Objects.equals(this.width, partitionTransform.width); + } + + @Override + public int hashCode() { + return Objects.hash(type, numBuckets, width); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartitionTransform {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" numBuckets: ").append(toIndentedString(numBuckets)).append("\n"); + sb.append(" width: ").append(toIndentedString(width)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/python/lance_namespace_urllib3_client/README.md b/python/lance_namespace_urllib3_client/README.md index 8d1b643f..8420ad5b 100644 --- a/python/lance_namespace_urllib3_client/README.md +++ b/python/lance_namespace_urllib3_client/README.md @@ -299,6 +299,9 @@ Class | Method | HTTP request | Description - [MultiMatchQuery](docs/MultiMatchQuery.md) - [NamespaceExistsRequest](docs/NamespaceExistsRequest.md) - [NewColumnTransform](docs/NewColumnTransform.md) + - [PartitionField](docs/PartitionField.md) + - [PartitionSpec](docs/PartitionSpec.md) + - [PartitionTransform](docs/PartitionTransform.md) - [PhraseQuery](docs/PhraseQuery.md) - [QueryTableRequest](docs/QueryTableRequest.md) - [QueryTableRequestColumns](docs/QueryTableRequestColumns.md) diff --git a/python/lance_namespace_urllib3_client/docs/PartitionField.md b/python/lance_namespace_urllib3_client/docs/PartitionField.md new file mode 100644 index 00000000..5ac30126 --- /dev/null +++ b/python/lance_namespace_urllib3_client/docs/PartitionField.md @@ -0,0 +1,34 @@ +# PartitionField + +Partition field definition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field_id** | **str** | Unique identifier for this partition field (must not be renamed) | +**source_ids** | **List[int]** | Field IDs of the source columns in the schema | +**transform** | [**PartitionTransform**](PartitionTransform.md) | Well-known partition transform. Exactly one of transform or expression must be specified. | [optional] +**expression** | **str** | DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified. | [optional] +**result_type** | [**JsonArrowDataType**](JsonArrowDataType.md) | The output type of the partition value (JsonArrowDataType format) | + +## Example + +```python +from lance_namespace_urllib3_client.models.partition_field import PartitionField + +# TODO update the JSON string below +json = "{}" +# create an instance of PartitionField from a JSON string +partition_field_instance = PartitionField.from_json(json) +# print the JSON string representation of the object +print(PartitionField.to_json()) + +# convert the object into a dict +partition_field_dict = partition_field_instance.to_dict() +# create an instance of PartitionField from a dict +partition_field_from_dict = PartitionField.from_dict(partition_field_dict) +``` +[[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/python/lance_namespace_urllib3_client/docs/PartitionSpec.md b/python/lance_namespace_urllib3_client/docs/PartitionSpec.md new file mode 100644 index 00000000..75b7b140 --- /dev/null +++ b/python/lance_namespace_urllib3_client/docs/PartitionSpec.md @@ -0,0 +1,31 @@ +# PartitionSpec + +Partition spec definition + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | The spec version ID | +**fields** | [**List[PartitionField]**](PartitionField.md) | Array of partition field definitions | + +## Example + +```python +from lance_namespace_urllib3_client.models.partition_spec import PartitionSpec + +# TODO update the JSON string below +json = "{}" +# create an instance of PartitionSpec from a JSON string +partition_spec_instance = PartitionSpec.from_json(json) +# print the JSON string representation of the object +print(PartitionSpec.to_json()) + +# convert the object into a dict +partition_spec_dict = partition_spec_instance.to_dict() +# create an instance of PartitionSpec from a dict +partition_spec_from_dict = PartitionSpec.from_dict(partition_spec_dict) +``` +[[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/python/lance_namespace_urllib3_client/docs/PartitionTransform.md b/python/lance_namespace_urllib3_client/docs/PartitionTransform.md new file mode 100644 index 00000000..b1999b28 --- /dev/null +++ b/python/lance_namespace_urllib3_client/docs/PartitionTransform.md @@ -0,0 +1,32 @@ +# PartitionTransform + +Well-known partition transform + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type** | **str** | Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) | +**num_buckets** | **int** | Number of buckets for bucket transforms | [optional] +**width** | **int** | Truncation width for truncate transforms | [optional] + +## Example + +```python +from lance_namespace_urllib3_client.models.partition_transform import PartitionTransform + +# TODO update the JSON string below +json = "{}" +# create an instance of PartitionTransform from a JSON string +partition_transform_instance = PartitionTransform.from_json(json) +# print the JSON string representation of the object +print(PartitionTransform.to_json()) + +# convert the object into a dict +partition_transform_dict = partition_transform_instance.to_dict() +# create an instance of PartitionTransform from a dict +partition_transform_from_dict = PartitionTransform.from_dict(partition_transform_dict) +``` +[[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/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/__init__.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/__init__.py index aa08ee50..82938ab9 100644 --- a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/__init__.py +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/__init__.py @@ -123,6 +123,9 @@ from lance_namespace_urllib3_client.models.multi_match_query import MultiMatchQuery from lance_namespace_urllib3_client.models.namespace_exists_request import NamespaceExistsRequest from lance_namespace_urllib3_client.models.new_column_transform import NewColumnTransform +from lance_namespace_urllib3_client.models.partition_field import PartitionField +from lance_namespace_urllib3_client.models.partition_spec import PartitionSpec +from lance_namespace_urllib3_client.models.partition_transform import PartitionTransform from lance_namespace_urllib3_client.models.phrase_query import PhraseQuery from lance_namespace_urllib3_client.models.query_table_request import QueryTableRequest from lance_namespace_urllib3_client.models.query_table_request_columns import QueryTableRequestColumns diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/__init__.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/__init__.py index e85e8f5c..c7470f24 100644 --- a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/__init__.py +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/__init__.py @@ -100,6 +100,9 @@ from lance_namespace_urllib3_client.models.multi_match_query import MultiMatchQuery from lance_namespace_urllib3_client.models.namespace_exists_request import NamespaceExistsRequest from lance_namespace_urllib3_client.models.new_column_transform import NewColumnTransform +from lance_namespace_urllib3_client.models.partition_field import PartitionField +from lance_namespace_urllib3_client.models.partition_spec import PartitionSpec +from lance_namespace_urllib3_client.models.partition_transform import PartitionTransform from lance_namespace_urllib3_client.models.phrase_query import PhraseQuery from lance_namespace_urllib3_client.models.query_table_request import QueryTableRequest from lance_namespace_urllib3_client.models.query_table_request_columns import QueryTableRequestColumns diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_field.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_field.py new file mode 100644 index 00000000..4957cac2 --- /dev/null +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_field.py @@ -0,0 +1,103 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from lance_namespace_urllib3_client.models.json_arrow_data_type import JsonArrowDataType +from lance_namespace_urllib3_client.models.partition_transform import PartitionTransform +from typing import Optional, Set +from typing_extensions import Self + +class PartitionField(BaseModel): + """ + Partition field definition + """ # noqa: E501 + field_id: StrictStr = Field(description="Unique identifier for this partition field (must not be renamed)") + source_ids: List[StrictInt] = Field(description="Field IDs of the source columns in the schema") + transform: Optional[PartitionTransform] = Field(default=None, description="Well-known partition transform. Exactly one of transform or expression must be specified.") + expression: Optional[StrictStr] = Field(default=None, description="DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified.") + result_type: JsonArrowDataType = Field(description="The output type of the partition value (JsonArrowDataType format)") + __properties: ClassVar[List[str]] = ["field_id", "source_ids", "transform", "expression", "result_type"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PartitionField from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of transform + if self.transform: + _dict['transform'] = self.transform.to_dict() + # override the default output from pydantic by calling `to_dict()` of result_type + if self.result_type: + _dict['result_type'] = self.result_type.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PartitionField from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "field_id": obj.get("field_id"), + "source_ids": obj.get("source_ids"), + "transform": PartitionTransform.from_dict(obj["transform"]) if obj.get("transform") is not None else None, + "expression": obj.get("expression"), + "result_type": JsonArrowDataType.from_dict(obj["result_type"]) if obj.get("result_type") is not None else None + }) + return _obj + + diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_spec.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_spec.py new file mode 100644 index 00000000..c79395c6 --- /dev/null +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_spec.py @@ -0,0 +1,97 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt +from typing import Any, ClassVar, Dict, List +from lance_namespace_urllib3_client.models.partition_field import PartitionField +from typing import Optional, Set +from typing_extensions import Self + +class PartitionSpec(BaseModel): + """ + Partition spec definition + """ # noqa: E501 + id: StrictInt = Field(description="The spec version ID") + fields: List[PartitionField] = Field(description="Array of partition field definitions") + __properties: ClassVar[List[str]] = ["id", "fields"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PartitionSpec from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in fields (list) + _items = [] + if self.fields: + for _item_fields in self.fields: + if _item_fields: + _items.append(_item_fields.to_dict()) + _dict['fields'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PartitionSpec from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "fields": [PartitionField.from_dict(_item) for _item in obj["fields"]] if obj.get("fields") is not None else None + }) + return _obj + + diff --git a/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_transform.py b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_transform.py new file mode 100644 index 00000000..911034e8 --- /dev/null +++ b/python/lance_namespace_urllib3_client/lance_namespace_urllib3_client/models/partition_transform.py @@ -0,0 +1,91 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class PartitionTransform(BaseModel): + """ + Well-known partition transform + """ # noqa: E501 + type: StrictStr = Field(description="Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate)") + num_buckets: Optional[StrictInt] = Field(default=None, description="Number of buckets for bucket transforms") + width: Optional[StrictInt] = Field(default=None, description="Truncation width for truncate transforms") + __properties: ClassVar[List[str]] = ["type", "num_buckets", "width"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional[Self]: + """Create an instance of PartitionTransform from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of PartitionTransform from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "type": obj.get("type"), + "num_buckets": obj.get("num_buckets"), + "width": obj.get("width") + }) + return _obj + + diff --git a/python/lance_namespace_urllib3_client/test/test_partition_field.py b/python/lance_namespace_urllib3_client/test/test_partition_field.py new file mode 100644 index 00000000..903ce578 --- /dev/null +++ b/python/lance_namespace_urllib3_client/test/test_partition_field.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from lance_namespace_urllib3_client.models.partition_field import PartitionField + +class TestPartitionField(unittest.TestCase): + """PartitionField unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PartitionField: + """Test PartitionField + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PartitionField` + """ + model = PartitionField() + if include_optional: + return PartitionField( + field_id = 'event_year', + source_ids = [1], + transform = lance_namespace_urllib3_client.models.partition_transform.PartitionTransform( + type = '', + num_buckets = 56, + width = 56, ), + expression = 'date_part('year', col0)', + result_type = {type=int32} + ) + else: + return PartitionField( + field_id = 'event_year', + source_ids = [1], + result_type = {type=int32}, + ) + """ + + def testPartitionField(self): + """Test PartitionField""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/lance_namespace_urllib3_client/test/test_partition_spec.py b/python/lance_namespace_urllib3_client/test/test_partition_spec.py new file mode 100644 index 00000000..045c9e07 --- /dev/null +++ b/python/lance_namespace_urllib3_client/test/test_partition_spec.py @@ -0,0 +1,74 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from lance_namespace_urllib3_client.models.partition_spec import PartitionSpec + +class TestPartitionSpec(unittest.TestCase): + """PartitionSpec unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PartitionSpec: + """Test PartitionSpec + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PartitionSpec` + """ + model = PartitionSpec() + if include_optional: + return PartitionSpec( + id = 1, + fields = [ + lance_namespace_urllib3_client.models.partition_field.PartitionField( + field_id = 'event_year', + source_ids = [1], + transform = lance_namespace_urllib3_client.models.partition_transform.PartitionTransform( + type = '', + num_buckets = 56, + width = 56, ), + expression = 'date_part('year', col0)', + result_type = {type=int32}, ) + ] + ) + else: + return PartitionSpec( + id = 1, + fields = [ + lance_namespace_urllib3_client.models.partition_field.PartitionField( + field_id = 'event_year', + source_ids = [1], + transform = lance_namespace_urllib3_client.models.partition_transform.PartitionTransform( + type = '', + num_buckets = 56, + width = 56, ), + expression = 'date_part('year', col0)', + result_type = {type=int32}, ) + ], + ) + """ + + def testPartitionSpec(self): + """Test PartitionSpec""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/lance_namespace_urllib3_client/test/test_partition_transform.py b/python/lance_namespace_urllib3_client/test/test_partition_transform.py new file mode 100644 index 00000000..e7eaa1db --- /dev/null +++ b/python/lance_namespace_urllib3_client/test/test_partition_transform.py @@ -0,0 +1,54 @@ +# coding: utf-8 + +""" + Lance Namespace Specification + + This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from lance_namespace_urllib3_client.models.partition_transform import PartitionTransform + +class TestPartitionTransform(unittest.TestCase): + """PartitionTransform unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> PartitionTransform: + """Test PartitionTransform + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `PartitionTransform` + """ + model = PartitionTransform() + if include_optional: + return PartitionTransform( + type = '', + num_buckets = 56, + width = 56 + ) + else: + return PartitionTransform( + type = '', + ) + """ + + def testPartitionTransform(self): + """Test PartitionTransform""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/rust/lance-namespace-reqwest-client/README.md b/rust/lance-namespace-reqwest-client/README.md index d4f5a427..de004c25 100644 --- a/rust/lance-namespace-reqwest-client/README.md +++ b/rust/lance-namespace-reqwest-client/README.md @@ -221,6 +221,9 @@ Class | Method | HTTP request | Description - [MultiMatchQuery](docs/MultiMatchQuery.md) - [NamespaceExistsRequest](docs/NamespaceExistsRequest.md) - [NewColumnTransform](docs/NewColumnTransform.md) + - [PartitionField](docs/PartitionField.md) + - [PartitionSpec](docs/PartitionSpec.md) + - [PartitionTransform](docs/PartitionTransform.md) - [PhraseQuery](docs/PhraseQuery.md) - [QueryTableRequest](docs/QueryTableRequest.md) - [QueryTableRequestColumns](docs/QueryTableRequestColumns.md) diff --git a/rust/lance-namespace-reqwest-client/docs/PartitionField.md b/rust/lance-namespace-reqwest-client/docs/PartitionField.md new file mode 100644 index 00000000..226b1c05 --- /dev/null +++ b/rust/lance-namespace-reqwest-client/docs/PartitionField.md @@ -0,0 +1,15 @@ +# PartitionField + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**field_id** | **String** | Unique identifier for this partition field (must not be renamed) | +**source_ids** | **Vec** | Field IDs of the source columns in the schema | +**transform** | Option<[**models::PartitionTransform**](PartitionTransform.md)> | Well-known partition transform. Exactly one of transform or expression must be specified. | [optional] +**expression** | Option<**String**> | DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified. | [optional] +**result_type** | [**models::JsonArrowDataType**](JsonArrowDataType.md) | The output type of the partition value (JsonArrowDataType format) | + +[[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/PartitionSpec.md b/rust/lance-namespace-reqwest-client/docs/PartitionSpec.md new file mode 100644 index 00000000..f284aa23 --- /dev/null +++ b/rust/lance-namespace-reqwest-client/docs/PartitionSpec.md @@ -0,0 +1,12 @@ +# PartitionSpec + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **i32** | The spec version ID | +**fields** | [**Vec**](PartitionField.md) | Array of partition field definitions | + +[[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/PartitionTransform.md b/rust/lance-namespace-reqwest-client/docs/PartitionTransform.md new file mode 100644 index 00000000..9b396ea2 --- /dev/null +++ b/rust/lance-namespace-reqwest-client/docs/PartitionTransform.md @@ -0,0 +1,13 @@ +# PartitionTransform + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**r#type** | **String** | Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) | +**num_buckets** | Option<**i32**> | Number of buckets for bucket transforms | [optional] +**width** | Option<**i32**> | Truncation width for truncate transforms | [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/mod.rs b/rust/lance-namespace-reqwest-client/src/models/mod.rs index d515fae0..9d7a3888 100644 --- a/rust/lance-namespace-reqwest-client/src/models/mod.rs +++ b/rust/lance-namespace-reqwest-client/src/models/mod.rs @@ -170,6 +170,12 @@ pub mod namespace_exists_request; pub use self::namespace_exists_request::NamespaceExistsRequest; pub mod new_column_transform; pub use self::new_column_transform::NewColumnTransform; +pub mod partition_field; +pub use self::partition_field::PartitionField; +pub mod partition_spec; +pub use self::partition_spec::PartitionSpec; +pub mod partition_transform; +pub use self::partition_transform::PartitionTransform; pub mod phrase_query; pub use self::phrase_query::PhraseQuery; pub mod query_table_request; diff --git a/rust/lance-namespace-reqwest-client/src/models/partition_field.rs b/rust/lance-namespace-reqwest-client/src/models/partition_field.rs new file mode 100644 index 00000000..a608412a --- /dev/null +++ b/rust/lance-namespace-reqwest-client/src/models/partition_field.rs @@ -0,0 +1,46 @@ +/* + * Lance Namespace Specification + * + * This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PartitionField : Partition field definition +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PartitionField { + /// Unique identifier for this partition field (must not be renamed) + #[serde(rename = "field_id")] + pub field_id: String, + /// Field IDs of the source columns in the schema + #[serde(rename = "source_ids")] + pub source_ids: Vec, + /// Well-known partition transform. Exactly one of transform or expression must be specified. + #[serde(rename = "transform", skip_serializing_if = "Option::is_none")] + pub transform: Option>, + /// DataFusion SQL expression using col0, col1, ... as column references. Exactly one of transform or expression must be specified. + #[serde(rename = "expression", skip_serializing_if = "Option::is_none")] + pub expression: Option, + /// The output type of the partition value (JsonArrowDataType format) + #[serde(rename = "result_type")] + pub result_type: Box, +} + +impl PartitionField { + /// Partition field definition + pub fn new(field_id: String, source_ids: Vec, result_type: models::JsonArrowDataType) -> PartitionField { + PartitionField { + field_id, + source_ids, + transform: None, + expression: None, + result_type: Box::new(result_type), + } + } +} + diff --git a/rust/lance-namespace-reqwest-client/src/models/partition_spec.rs b/rust/lance-namespace-reqwest-client/src/models/partition_spec.rs new file mode 100644 index 00000000..0b0b3c6b --- /dev/null +++ b/rust/lance-namespace-reqwest-client/src/models/partition_spec.rs @@ -0,0 +1,34 @@ +/* + * Lance Namespace Specification + * + * This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PartitionSpec : Partition spec definition +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PartitionSpec { + /// The spec version ID + #[serde(rename = "id")] + pub id: i32, + /// Array of partition field definitions + #[serde(rename = "fields")] + pub fields: Vec, +} + +impl PartitionSpec { + /// Partition spec definition + pub fn new(id: i32, fields: Vec) -> PartitionSpec { + PartitionSpec { + id, + fields, + } + } +} + diff --git a/rust/lance-namespace-reqwest-client/src/models/partition_transform.rs b/rust/lance-namespace-reqwest-client/src/models/partition_transform.rs new file mode 100644 index 00000000..681db4c6 --- /dev/null +++ b/rust/lance-namespace-reqwest-client/src/models/partition_transform.rs @@ -0,0 +1,38 @@ +/* + * Lance Namespace Specification + * + * This OpenAPI specification is a part of the Lance namespace specification. It contains 2 parts: The `components/schemas`, `components/responses`, `components/examples`, `tags` sections define the request and response shape for each operation in a Lance Namespace across all implementations. See https://lance.org/format/namespace/operations for more details. The `servers`, `security`, `paths`, `components/parameters` sections are for the Lance REST Namespace implementation, which defines a complete REST server that can work with Lance datasets. See https://lance.org/format/namespace/rest for more details. + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// PartitionTransform : Well-known partition transform +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct PartitionTransform { + /// Transform type (identity, year, month, day, hour, bucket, multi_bucket, truncate) + #[serde(rename = "type")] + pub r#type: String, + /// Number of buckets for bucket transforms + #[serde(rename = "num_buckets", skip_serializing_if = "Option::is_none")] + pub num_buckets: Option, + /// Truncation width for truncate transforms + #[serde(rename = "width", skip_serializing_if = "Option::is_none")] + pub width: Option, +} + +impl PartitionTransform { + /// Well-known partition transform + pub fn new(r#type: String) -> PartitionTransform { + PartitionTransform { + r#type, + num_buckets: None, + width: None, + } + } +} +