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 a Metadata.detect_from_ddl function #2212

Open
npatki opened this issue Sep 9, 2024 · 0 comments
Open

Add a Metadata.detect_from_ddl function #2212

npatki opened this issue Sep 9, 2024 · 0 comments
Labels
feature request Request for a new feature

Comments

@npatki
Copy link
Contributor

npatki commented Sep 9, 2024

Problem Description

In an upcoming version of SDV, we will be consolidating the Multi and Single table metadata objects into a streamlined Metadata object. Effectively, this object is the same as multi-table, so it includes functions that are suited for detecting multiple tables at once.

However, if you have a single table, it should still be usable without adding much friction. Currently, there is a SingleTableMetadata.detect_from_ddl function that has not been added to the consolidated Metadata object.

Expected behavior

Add a detect_from_ddl function to the Metadata object. This will work similarly to the existing function, but with slight modifications to work for both the single and multi-table cases.

To improve the usage of this function, we will make it a class function that ultimately returns an instance of the metadata object.

from sdv.metadata import Metadata

metadata = Metadata.detect_from_ddl(filepath=... db_type='ibm_db2', table_names=['...'])

Parameters:

  • (required) filepath: The location of the DDL file that contains the schema
  • (required) db_type: A string with the type of SQL variant. Currently only 'ibm_db2' is supported
  • table_names: A list of strings representing the table names to extract. For a single table, supply a list of 1 element.
    • (default) Consider all tables in the database
  • database_name: A string with the name of the database. In the DDL file, the database name is usually prepended to the table, such as users.transaction_log
    • (default) None: Don't consider any specific database

Functionality: Detect metadata for all the tables that the user has specified. If there is only 1 table specified, then only 1 table's information will be in the metadata. If there are multiple tables specified, then they will all be included in the metadata including any primary/foreign key relationships that we find between them.

Output: An instance of the metadata object with the detected metadata

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

No branches or pull requests

1 participant