-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metadata validation #527
Add metadata validation #527
Conversation
if 'tables' not in metadata: | ||
raise ValueError( | ||
'Multi table reports expect metadata to contain a "tables" key with a mapping' | ||
' from table names to metadata for each table.' | ||
) | ||
for table_name, table_metadata in metadata['tables'].items(): | ||
if 'columns' not in table_metadata: | ||
raise ValueError( | ||
f'The metadata for table "{table_name}" is missing a "columns" key.' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@npatki should we error in the case where the metadata is malformed? More specifically, f a users gives metadata with an empty table or empty column, should we error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amontanez24 yeah that's probably a good idea. Though I'm neutral on whether or not there's an explicit error message for this case vs. the report just naturally crashing because it cannot access those key names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if 'tables' not in metadata: | ||
raise ValueError( | ||
'Multi table reports expect metadata to contain a "tables" key with a mapping' | ||
' from table names to metadata for each table.' | ||
) | ||
for table_name, table_metadata in metadata['tables'].items(): | ||
if 'columns' not in table_metadata: | ||
raise ValueError( | ||
f'The metadata for table "{table_name}" is missing a "columns" key.' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amontanez24 yeah that's probably a good idea. Though I'm neutral on whether or not there's an explicit error message for this case vs. the report just naturally crashing because it cannot access those key names.
CU-86ayrkg1a
Resolve #526