-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement create/get/delete/list table metadata methods (#28)
- Loading branch information
Showing
15 changed files
with
412 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from typing import Optional | ||
|
||
from ._json_model import JsonModel | ||
|
||
|
||
class PagedResult(JsonModel): | ||
continuation_token: Optional[str] | ||
"""A token which allows the user to resume a query at the next item in the matching results. | ||
When querying, a token will be returned if a query may be | ||
continued. To obtain the next page of results, pass the token to the service | ||
on a subsequent request. The service will respond with a new continuation | ||
token. To paginate results, continue sending requests with the newest | ||
continuation token provided by the service, until this value is null. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
from ._api_info import ApiInfo, Operation, OperationsV1 | ||
from ._create_table_request import CreateTableRequest | ||
from ._column import Column | ||
from ._column_type import ColumnType | ||
from ._data_type import DataType | ||
from ._order_by import OrderBy | ||
from ._paged_tables import PagedTables | ||
from ._table_metadata import TableMetadata | ||
|
||
# flake8: noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Dict, Optional | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
from ._column_type import ColumnType | ||
from ._data_type import DataType | ||
|
||
|
||
class Column(JsonModel): | ||
"""Defines a single column in a table.""" | ||
|
||
name: str | ||
"""The column name, which must be unique across all columns in the table.""" | ||
|
||
data_type: DataType | ||
"""The data type of the column.""" | ||
|
||
column_type: ColumnType = ColumnType.Normal | ||
"""The column type. Defaults to ColumnType.Normal.""" | ||
|
||
properties: Optional[Dict[str, str]] = None | ||
"""User-defined properties associated with the column.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from enum import Enum | ||
|
||
|
||
class ColumnType(str, Enum): | ||
"""Represents the different column types for a table column.""" | ||
|
||
Normal = "NORMAL" | ||
"""The column has no special properties. This is the default.""" | ||
|
||
Index = "INDEX" | ||
"""The column provides a unique value per row. Each table must provide | ||
exactly one INDEX column. The column's :class:`.DataType` must be INT32, | ||
INT64, or TIMESTAMP.""" | ||
|
||
Nullable = "NULLABLE" | ||
"""Rows may contain null values for this column. When appending rows, | ||
NULLABLE columns may be left out entirely, in which case all rows being | ||
appended will use null values for that column.""" |
22 changes: 22 additions & 0 deletions
22
nisystemlink/clients/dataframe/models/_create_table_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Dict, List, Optional | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
from ._column import Column | ||
|
||
|
||
class CreateTableRequest(JsonModel): | ||
"""Contains information needed to create a table, including its properties and column definitions.""" | ||
|
||
columns: List[Column] | ||
"""The list of columns in the table. Exactly one column must have a :class:`.ColumnType` of INDEX.""" | ||
|
||
name: Optional[str] = None | ||
"""The name to associate with the table. When not specified, a name will be | ||
assigned from the table's ID.""" | ||
|
||
properties: Optional[Dict[str, str]] = None | ||
"""User-defined properties to associate with the table.""" | ||
|
||
workspace: Optional[str] = None | ||
"""The workspace to create the table in. Uses the default workspace when not specified.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from enum import Enum | ||
|
||
|
||
class DataType(str, Enum): | ||
"""Represents the different data types for a table column.""" | ||
|
||
Bool = "BOOL" | ||
"""32-bit IEEE 754 floating-point number.""" | ||
|
||
Float32 = "FLOAT32" | ||
"""32-bit IEEE 754 floating-point number.""" | ||
|
||
Float64 = "FLOAT64" | ||
"""64-bit IEEE 754 floating-point number.""" | ||
|
||
Int32 = "INT32" | ||
"""32-bit signed integers.""" | ||
|
||
Int64 = "INT64" | ||
"""64-bit signed integers.""" | ||
|
||
String = "STRING" | ||
"""Arbitrary string data.""" | ||
|
||
Timestamp = "TIMESTAMP" | ||
"""Date and time represented in UTC with millisecond precision.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from typing import Literal | ||
|
||
# TODO: Migrate to Enum when this change is released: https://github.com/prkumar/uplink/pull/282 | ||
OrderBy = Literal[ | ||
"CREATED_AT", "METADATA_MODIFIED_AT", "NAME", "NUMBER_OF_ROWS", "ROWS_MODIFIED_AT" | ||
] | ||
"""Possible options for sorting when querying tables. | ||
* ``CREATED_AT``: The date and time the table was created. | ||
* ``METADATA_MODIFIED_AT``: The date and time the table's metadata properties were modified. | ||
* ``NAME``: The name of the table. | ||
* ``NUMBER_OF_ROWS``: The number of rows of data in the table. | ||
* ``ROWS_MODIFIED_AT``: Date and time rows were most recently appended to the table. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from typing import List | ||
|
||
from nisystemlink.clients.core._uplink._paged_result import PagedResult | ||
|
||
from ._table_metadata import TableMetadata | ||
|
||
|
||
class PagedTables(PagedResult): | ||
"""The response for a table query containing the matched tables.""" | ||
|
||
tables: List[TableMetadata] | ||
"""The list of tables returned by the query.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from datetime import datetime | ||
from typing import Dict, List | ||
|
||
from nisystemlink.clients.core._uplink._json_model import JsonModel | ||
|
||
from ._column import Column | ||
|
||
|
||
class TableMetadata(JsonModel): | ||
"""Contains information about a table, including its properties and column definitions.""" | ||
|
||
columns: List[Column] | ||
"""The list of columns in the table.""" | ||
|
||
created_at: datetime | ||
"""The date and time the table was created.""" | ||
|
||
id: str | ||
"""The table's unique identifier.""" | ||
|
||
metadata_modified_at: datetime | ||
"""The date and time the table's metadata was last modified.""" | ||
|
||
metadata_revision: int | ||
"""The table's metadata revision number, incremented each time the metadata is modified.""" | ||
|
||
name: str | ||
"""The name associated with the table.""" | ||
|
||
properties: Dict[str, str] | ||
"""User-defined properties associated with the table.""" | ||
|
||
row_count: int | ||
"""The number of rows in the table.""" | ||
|
||
rows_modified_at: datetime | ||
"""The date and time the table's data was last modified.""" | ||
|
||
supports_append: bool | ||
"""Whether the table supports appending additional rows of data.""" | ||
|
||
workspace: str | ||
"""The workspace the table belongs to.""" |
Oops, something went wrong.