-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
401874b
commit 281b6cb
Showing
3 changed files
with
28 additions
and
24 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
17 changes: 17 additions & 0 deletions
17
backend_py/primary/primary/services/utils/summary_vector_table_helpers.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,17 @@ | ||
import pyarrow as pa | ||
|
||
from primary.services.service_exceptions import InvalidDataError, Service | ||
|
||
|
||
def validate_summary_vector_table(vector_table: pa.Table, vector_name: str, service: Service = Service.GENERAL) -> None: | ||
""" | ||
Check if the vector table is valid - single vector table should contain columns DATE, REAL, vector_name. | ||
Expect the pyarrow table to contain the following columns: DATE, REAL, vector_name. | ||
Raises InvalidDataError if the table does not contain the expected columns. | ||
""" | ||
expected_columns = {"DATE", "REAL", vector_name} | ||
if set(vector_table.column_names) != expected_columns: | ||
unexpected_columns = set(vector_table.column_names) - expected_columns | ||
raise InvalidDataError(f"Unexpected columns in table {unexpected_columns}", service) |