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

Foreign Keys are added as Alternate Keys when upgrading #1143

Closed
pvk-developer opened this issue Dec 12, 2022 · 0 comments
Closed

Foreign Keys are added as Alternate Keys when upgrading #1143

pvk-developer opened this issue Dec 12, 2022 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@pvk-developer
Copy link
Member

Environment Details

  • SDV version: V1.0.0
  • Python version: 3.8
  • Operating System: MacOS Darwin

Error Description

When converting the load_demo metadata, this adds the foreign keys as alternate keys, which leads to erroring out later on validation while fitting.

Steps to reproduce

from sdv.demo import load_demo
from sdv.metadata import MultiTableMetadata

metadata, data = load_demo(metadata=True)
metadata.to_json('old_metadata.json')

MultiTableMetadata.upgrade_metadata('old_metadata.json', 'new_metadata.json')

mtm = MultiTableMetadata.load_from_json('new_metadata.json')
mtm

Here is the output of the mtm as json representation:

{
    "tables": {
        "users": {
            "columns": {
                "user_id": {
                    "sdtype": "numerical"
                },
                "country": {
                    "sdtype": "categorical"
                },
                "gender": {
                    "sdtype": "categorical"
                },
                "age": {
                    "sdtype": "numerical",
                    "computer_representation": "Int64"
                }
            },
            "primary_key": "user_id"
        },
        "sessions": {
            "alternate_keys": [
                "user_id"
            ],
            "columns": {
                "session_id": {
                    "sdtype": "numerical"
                },
                "user_id": {
                    "sdtype": "numerical"
                },
                "device": {
                    "sdtype": "categorical"
                },
                "os": {
                    "sdtype": "categorical"
                },
                "minutes": {
                    "sdtype": "numerical",
                    "computer_representation": "Int64"
                }
            },
            "primary_key": "session_id"
        },
        "transactions": {
            "alternate_keys": [
                "session_id"
            ],
            "columns": {
                "transaction_id": {
                    "sdtype": "numerical"
                },
                "session_id": {
                    "sdtype": "numerical"
                },
                "timestamp": {
                    "sdtype": "datetime",
                    "datetime_format": "%Y-%m-%dT%H:%M"
                },
                "amount": {
                    "sdtype": "numerical",
                    "computer_representation": "Float"
                },
                "cancelled": {
                    "sdtype": "boolean"
                }
            },
            "primary_key": "transaction_id"
        }
    },
    "relationships": [
        {
            "parent_table_name": "users",
            "parent_primary_key": "user_id",
            "child_table_name": "sessions",
            "child_foreign_key": "user_id"
        },
        {
            "parent_table_name": "sessions",
            "parent_primary_key": "session_id",
            "child_table_name": "transactions",
            "child_foreign_key": "session_id"
        }
    ],
    "SCHEMA_VERSION": "MULTI_TABLE_V1"
}
@pvk-developer pvk-developer added bug Something isn't working new Automatic label applied to new issues labels Dec 12, 2022
@npatki npatki removed the new Automatic label applied to new issues label Dec 13, 2022
@npatki npatki added this to the 1.0.0 milestone Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants