Skip to content

Commit

Permalink
chore: Followups for table query (#2435)
Browse files Browse the repository at this point in the history
* initial pickup

* lint

* done
  • Loading branch information
tssweeney authored Sep 20, 2024
1 parent a3c6136 commit 64136fd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
24 changes: 24 additions & 0 deletions weave/tests/trace/test_table_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ def test_table_query(client: WeaveClient):
assert result_digests == row_digests


def test_table_query_invalid_digest(client: WeaveClient):
res = client.server.table_query(
tsi.TableQueryReq(
project_id=client._project_id(),
digest="invalid",
)
)

assert res.rows == []


def test_table_query_filter_by_row_digests(client: WeaveClient):
digest, row_digests, data = generate_table_data(client, 10, 5)

Expand All @@ -73,6 +84,19 @@ def test_table_query_filter_by_row_digests(client: WeaveClient):
assert result_digests == filtered_digests


def test_table_query_invalid_row_digest(client: WeaveClient):
digest, row_digests, data = generate_table_data(client, 10, 10)
res = client.server.table_query(
tsi.TableQueryReq(
project_id=client._project_id(),
digest=digest,
filter=tsi.TableRowFilter(row_digests=["invalid"]),
)
)

assert res.rows == []


def test_table_query_limit(client: WeaveClient):
digest, row_digests, data = generate_table_data(client, 10, 5)

Expand Down
21 changes: 17 additions & 4 deletions weave/trace_server/trace_server_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,12 @@ class TableRowFilter(BaseModel):
row_digests: Optional[List[str]] = Field(
default=None,
description="List of row digests to filter by",
examples=[["row_digest_1", "row_digest_2"]],
examples=[
[
"aonareimsvtl13apimtalpa4435rpmgnaemrpgmarltarstaorsnte134avrims",
"aonareimsvtl13apimtalpa4435rpmgnaemrpgmarltarstaorsnte134avrims",
]
],
)


Expand All @@ -559,12 +564,20 @@ class TableQueryReq(BaseModel):
description="The ID of the project", examples=["my_entity/my_project"]
)
digest: str = Field(
description="The digest of the table to query", examples=["table_digest_123"]
description="The digest of the table to query",
examples=["aonareimsvtl13apimtalpa4435rpmgnaemrpgmarltarstaorsnte134avrims"],
)
filter: Optional[TableRowFilter] = Field(
default=None,
description="Optional filter to apply to the query. See `TableRowFilter` for more details.",
examples=[{"row_digests": ["row_digest_1", "row_digest_2"]}],
examples=[
{
"row_digests": [
"aonareimsvtl13apimtalpa4435rpmgnaemrpgmarltarstaorsnte134avrims",
"aonareimsvtl13apimtalpa4435rpmgnaemrpgmarltarstaorsnte134avrims",
]
}
],
)
limit: Optional[int] = Field(
default=None, description="Maximum number of rows to return", examples=[100]
Expand All @@ -576,7 +589,7 @@ class TableQueryReq(BaseModel):
)
sort_by: Optional[List[SortBy]] = Field(
default=None,
description="List of fields to sort by. Fields can be dot-separated to access dictionary values. No sorting uses the default table order.",
description="List of fields to sort by. Fields can be dot-separated to access dictionary values. No sorting uses the default table order (insertion order).",
examples=[[{"field": "col_a.prop_b", "order": "desc"}]],
)

Expand Down

0 comments on commit 64136fd

Please sign in to comment.