mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-21 23:13:05 +00:00
parent
7958e81918
commit
d30619a81f
@ -95,7 +95,6 @@ def ometa_to_orm(
|
||||
We are building the class dynamically using
|
||||
`type` and passing SQLAlchemy `Base` class
|
||||
as the bases tuple for inheritance.
|
||||
TODO: Remove the dialect once we solve the hierarchy service.db.schema.table. Check #3529
|
||||
"""
|
||||
|
||||
cols = {
|
||||
@ -103,14 +102,17 @@ def ometa_to_orm(
|
||||
for idx, col in enumerate(table.columns)
|
||||
}
|
||||
|
||||
schema_name = get_schema_name(schema)
|
||||
orm_name = f"{schema_name}_{table.name}".replace(".", "_")
|
||||
|
||||
# Type takes positional arguments in the form of (name, bases, dict)
|
||||
orm = type(
|
||||
table.fullyQualifiedName.__root__.replace(".", "_"), # Output class name
|
||||
orm_name, # Output class name
|
||||
(Base,), # SQLAlchemy declarative base
|
||||
{
|
||||
"__tablename__": str(table.name.__root__),
|
||||
"__table_args__": {
|
||||
"schema": get_schema_name(schema),
|
||||
"schema": schema_name,
|
||||
"extend_existing": True, # Recreates the table ORM object if it already exists. Useful for testing
|
||||
},
|
||||
**cols,
|
||||
|
@ -33,8 +33,10 @@ def _(element, compiler, **kw):
|
||||
|
||||
@compiles(LenFn, Dialects.SQLite)
|
||||
@compiles(LenFn, Dialects.Vertica)
|
||||
@compiles(LenFn, Dialects.Hive) # For some reason hive's dialect is in bytes...
|
||||
@compiles(LenFn, Dialects.Hive)
|
||||
@compiles(LenFn, Dialects.Postgres)
|
||||
@compiles(LenFn, Dialects.Databricks)
|
||||
@compiles(LenFn, Dialects.MySQL)
|
||||
@compiles(LenFn, Dialects.MariaDB)
|
||||
def _(element, compiler, **kw):
|
||||
return "LENGTH(%s)" % compiler.process(element.clauses, **kw)
|
||||
|
@ -34,7 +34,7 @@ class Dialects(Enum):
|
||||
and profiling data.
|
||||
"""
|
||||
|
||||
Hive = b"hive"
|
||||
Hive = b"hive" # Hive requires bytes
|
||||
Postgres = "postgresql"
|
||||
BigQuery = "bigquery"
|
||||
MySQL = "mysql"
|
||||
|
Loading…
x
Reference in New Issue
Block a user