Skip to content
Snippets Groups Projects
Commit 39f683f1 authored by Leah Tacke genannt Unterberg's avatar Leah Tacke genannt Unterberg
Browse files

minor fix in sql representation

parent e7dd1ea0
Branches
No related tags found
No related merge requests found
from __future__ import annotations
from collections.abc import Callable, Generator, Mapping
from typing import TYPE_CHECKING
import pydantic
import sqlalchemy as sa
......@@ -8,7 +11,6 @@ from mitm_tooling.data_types import MITMDataType
from mitm_tooling.definition import MITMDefinition, ConceptProperties, OwnedRelations, ConceptName, MITM, get_mitm_def, \
RelationName
from mitm_tooling.definition.definition_tools import map_col_groups, ColGroupMaps
from mitm_tooling.extraction.sql.data_models import Queryable, TableName
from .intermediate_representation import Header, MITMData
from mitm_tooling.utilities.sql_utils import create_sa_engine, qualify
from mitm_tooling.utilities import python_utils
......@@ -16,6 +18,10 @@ from mitm_tooling.utilities.io_utils import FilePath
from sqlalchemy_utils.view import create_view
if TYPE_CHECKING:
from mitm_tooling.extraction.sql.data_models import Queryable
from mitm_tooling.extraction.sql.data_models.table_identifiers import TableName
SQL_REPRESENTATION_DEFAULT_SCHEMA = 'main'
......
......@@ -80,6 +80,7 @@ class SupersetTableDef(SupersetDefFile):
table_name: str
schema_name: str = pydantic.Field(alias='schema')
uuid: BetterUUID
database_uuid: BetterUUID
main_dttm_col: str | None = None
description: str | None = None
default_endpoint: str | None = None
......
......@@ -64,6 +64,7 @@ def infer_superset_dataset_def(sqlite_file_path: FilePath) -> SupersetDef:
meta, _ = connect_and_reflect(engine)
db_meta = DBMetaInfo.from_sa_meta(meta, default_schema=SQL_REPRESENTATION_DEFAULT_SCHEMA)
database_uuid = uuid.uuid4()
datasets = []
for schema_name, schema_tables in db_meta.db_structure.items():
for table_name, table in schema_tables.items():
......@@ -81,13 +82,13 @@ def infer_superset_dataset_def(sqlite_file_path: FilePath) -> SupersetDef:
dialect=engine.dialect)
))
datasets.append(
SupersetTableDef(table_name=table_name, schema_name=schema_name, uuid=uuid.uuid4(), columns=cols))
SupersetTableDef(table_name=table_name, schema_name=schema_name, uuid=uuid.uuid4(), database_uuid=database_uuid, columns=cols))
db_name = os.path.splitext(os.path.basename(sqlite_file_path))[0]
return SupersetDef(
database=SupersetDatabaseDef(database_name=db_name,
sqlalchemy_uri=tentative_superset_mount_url(db_name),
uuid=uuid.uuid4()),
uuid=database_uuid),
datasets=datasets)
......
[tool.poetry]
name = "mitm-tooling"
version = "0.3.0"
version = "0.3.1"
description = ""
authors = ["Leah Tacke genannt Unterberg <leah.tgu@pads.rwth-aachen.de>"]
readme = "README.md"
......@@ -13,7 +13,7 @@ pyyaml = "6.0.2"
genson = "^1.3.0"
sqlalchemy = { version = "^2.0.34", extras = ["postgresql-psycopg", "postgresql"] }
sqlalchemy-utils = "0.41.2"
sqlalchemy-utils = ">=0.38.0"
pandas = { version = "^2.0", extras = ["performance", "excel", "hdf5", "output_formatting", "computation", "postgresql", "mysql", "sql-other", "plot", "compression"] }
# visualization
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment