From 64136fd92643b8fae9723f7a5d2ba45d10d45e28 Mon Sep 17 00:00:00 2001 From: Tim Sweeney Date: Fri, 20 Sep 2024 08:37:47 -0700 Subject: [PATCH] chore: Followups for table query (#2435) * initial pickup * lint * done --- weave/tests/trace/test_table_query.py | 24 ++++++++++++++++++++ weave/trace_server/trace_server_interface.py | 21 +++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/weave/tests/trace/test_table_query.py b/weave/tests/trace/test_table_query.py index 4cbffbb6a65..e617a3d70fd 100644 --- a/weave/tests/trace/test_table_query.py +++ b/weave/tests/trace/test_table_query.py @@ -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) @@ -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) diff --git a/weave/trace_server/trace_server_interface.py b/weave/trace_server/trace_server_interface.py index 880aded2a4b..5f6169d8bff 100644 --- a/weave/trace_server/trace_server_interface.py +++ b/weave/trace_server/trace_server_interface.py @@ -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", + ] + ], ) @@ -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] @@ -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"}]], )