schema_sentinel.metadata_manager.model.table API documentation

# schema_sentinel.metadata_manager.model.table

View Source

     1import json
     2
     3import sqlalchemy as db
     4from sqlalchemy import ForeignKey, select
     5
     6from . import CommonBase
     7
     8
     9class Table(CommonBase):
    10    __tablename__ = "tables"
    11    table_id = db.Column(db.String, primary_key=True)
    12    schema_id = db.Column(db.String, ForeignKey("schemas.schema_id"))
    13    table_name = db.Column(db.String)
    14
    15    table_owner = db.Column(db.String)
    16    table_type = db.Column(db.String, default="TABLE")
    17    is_transient = db.Column(db.String, default="N")
    18    clustering_key = db.Column(db.String)
    19    comment = db.Column(db.String)
    20    row_count = db.Column(db.Integer)
    21    bytes = db.Column(db.Integer)
    22    retention_time = db.Column(db.Integer)
    23    created = db.Column(db.String)
    24    last_altered = db.Column(db.String)
    25    last_ddl = db.Column(db.String)
    26    last_ddl_by = db.Column(db.String)
    27    auto_clustering_on = db.Column(db.String, default="OFF")
    28    change_tracking = db.Column(db.String, default="OFF")
    29    is_external = db.Column(db.String, default="N")
    30    enable_schema_evolution = db.Column(db.String, default="N")
    31    owner_role_type = db.Column(db.String)
    32    is_event = db.Column(db.String, default="N")
    33
    34    def save(self, session) -> None:
    35        if not session.execute(self.exists()).first():
    36            session.add(self)
    37            session.commit()
    38
    39    def exists(self) -> str:
    40        return select(Table).filter_by(table_id=self.table_id)
    41
    42    def __get_id__(self) -> str:
    43        id = json.loads(self.schema_id)
    44        id["table_name"] = self.table_name
    45        return json.dumps(id)

class Table(schema_sentinel.metadata_manager.model.CommonBase): View Source

    10class Table(CommonBase):
    11    __tablename__ = "tables"
    12    table_id = db.Column(db.String, primary_key=True)
    13    schema_id = db.Column(db.String, ForeignKey("schemas.schema_id"))
    14    table_name = db.Column(db.String)
    15
    16    table_owner = db.Column(db.String)
    17    table_type = db.Column(db.String, default="TABLE")
    18    is_transient = db.Column(db.String, default="N")
    19    clustering_key = db.Column(db.String)
    20    comment = db.Column(db.String)
    21    row_count = db.Column(db.Integer)
    22    bytes = db.Column(db.Integer)
    23    retention_time = db.Column(db.Integer)
    24    created = db.Column(db.String)
    25    last_altered = db.Column(db.String)
    26    last_ddl = db.Column(db.String)
    27    last_ddl_by = db.Column(db.String)
    28    auto_clustering_on = db.Column(db.String, default="OFF")
    29    change_tracking = db.Column(db.String, default="OFF")
    30    is_external = db.Column(db.String, default="N")
    31    enable_schema_evolution = db.Column(db.String, default="N")
    32    owner_role_type = db.Column(db.String)
    33    is_event = db.Column(db.String, default="N")
    34
    35    def save(self, session) -> None:
    36        if not session.execute(self.exists()).first():
    37            session.add(self)
    38            session.commit()
    39
    40    def exists(self) -> str:
    41        return select(Table).filter_by(table_id=self.table_id)
    42
    43    def __get_id__(self) -> str:
    44        id = json.loads(self.schema_id)
    45        id["table_name"] = self.table_name
    46        return json.dumps(id)

The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.

Table(**kwargs)

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in `kwargs`.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

table_id
schema_id
table_name
table_owner
table_type
is_transient
clustering_key
comment
row_count
bytes
retention_time
created
last_altered
last_ddl
last_ddl_by
auto_clustering_on
change_tracking
is_external
enable_schema_evolution
owner_role_type
is_event
def save(self, session) -> None: View Source

    35    def save(self, session) -> None:
    36        if not session.execute(self.exists()).first():
    37            session.add(self)
    38            session.commit()

def exists(self) -> str: View Source

    40    def exists(self) -> str:
    41        return select(Table).filter_by(table_id=self.table_id)