Skip to content
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 key related methods to MultiTableMetadata #894

Closed
amontanez24 opened this issue Jul 8, 2022 · 0 comments · Fixed by #937
Closed

Add key related methods to MultiTableMetadata #894

amontanez24 opened this issue Jul 8, 2022 · 0 comments · Fixed by #937
Assignees
Labels
feature request Request for a new feature
Milestone

Comments

@amontanez24
Copy link
Contributor

Problem Description

As a user, it would be useful to be able to programmatically set primary keys, sequence keys, sequences indices and alternate keys for specific table in my MultiTableMetadata.

Expected behavior

  • Add set_primary_key(table_name, id) method
    • Under the hood should call SingleTableMetadata.set_primary_key for the right table
    • Parameters:
      • table_name: string that is the name of the table to add the primary key for
      • id: string of column name that is going to be the primary key, or tuple string column names
    • Warnings:
      • If there is already a key raise this warnings
        Warning: There is an existing primary key 'user_id'. This key will be removed.
    • Errors:
      • Same errors as in the single table case
      • If the table doesn't exist raise the following error
        Error: Unknown table name ('userss')
>>> metadata.set_primary_key(table_name='users', id='user_id')

>>> metadata.set_primary_key(table_name='users', id=('first_name', 'last_name'))
Warning: There is an existing primary key 'user_id'. This key will be removed.

>>> metadata.set_primary_key(table_name='userss', id='uuid')
Error: Unknown table name ('userss')

>>> metadata.set_primary_key(table_name='users', id='uuid')
Error: Unknown key value 'uuid'. Keys should be columns that exist in the table.
  • Add set_sequence_key(table_name, id) method
    • Parameters:
      • table_name: string that is the name of the table
      • id: string of column name that is going to be the sequence key
    • Under the hood should call SingleTableMetadata.set_sequence_key for the right table
    • Warnings:
      • raise the following warning
        Warning: Sequential modeling is not yet supported on SDV Multi Table models.
>>> metadata.set_sequence_key(table_name='users', id='patient_id')
Warning: Sequential modeling is not yet supported on SDV Multi Table models.
  • Add set_sequence_index(table_name, column_name) method
    • Parameters:
      • table_name: string that is the name of the table
      • column_name: string of column name that is going to be the sequence index
    • Under the hood should call SingleTableMetadata.set_sequence_index for the right table
    • Errors:
      • Same errors as in the single table case
      • If the table doesn't exist raise an error
    • Warnings:
      • Raise the following warning
        Warning: Sequential modeling is not yet supported on SDV Multi Table models.
>>> metadata.set_sequence_index(table_name='users', column_name='timestamp')
Warning: Sequential modeling is not yet supported on SDV Multi Table models.

>>> metadata.set_sequence_index(table_name='userss', column_name='timestamp')
Error: Unknown table name ('userss')

>>> metadata.set_sequence_index(table_name='users', column_name='timestampp')
Error: Unknown index value 'timestamp'. Index should be a column that exists in the table.
  • Add add_alternate_keys(table_name, ids) method
    • Parameters:
      • table_name: string that is the name of the table
      • ids: A list of strings or tuples of string that represent column names
      • Under the hood should call SingleTableMetadata.add_alternate_keys for the right table
    • Errors:
      • Same errors as in single table case
      • If the table doesn't exist raise an error
>>> metadata.add_alternate_keys(table_name='users', ids=['username', 'email'])

>>> metadata.add_alternate_keys(table_name='users',
        ids=[('first_name', 'last_name'), 'ssn')])

>>> metadata.add_alternate_keys(table_name='userss', ids='uuid')
Error: Unknown table name ('userss')

>>> metadata.add_primary_key(table_name='users', column_names=['uuid'])
Error: Unknown primary key value 'uuid'. Keys should be columns that exist in the table.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants