mirror of https://github.com/apache/superset.git
fix(db-migration): new_dataset_models_take_2 error on postgres (#21417)
Co-authored-by: Ville Brofeldt <ville.brofeldt@apple.com>
This commit is contained in:
parent
cc38400d71
commit
2e5270cdb0
|
@ -636,14 +636,31 @@ def postprocess_columns(session: Session) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_joined_tables(offset, limit):
|
def get_joined_tables(offset, limit):
|
||||||
return (
|
|
||||||
sa.join(
|
# Import aliased from sqlalchemy
|
||||||
session.query(NewColumn)
|
from sqlalchemy.orm import aliased
|
||||||
|
|
||||||
|
# Create alias of NewColumn
|
||||||
|
new_column_alias = aliased(NewColumn)
|
||||||
|
# Get subquery and give it the alias "sl_colums_2"
|
||||||
|
subquery = (
|
||||||
|
session.query(new_column_alias)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.subquery("sl_columns"),
|
.subquery("sl_columns_2")
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
sa.join(
|
||||||
|
subquery,
|
||||||
|
NewColumn,
|
||||||
|
# Use column id from subquery
|
||||||
|
subquery.c.id == NewColumn.id,
|
||||||
|
)
|
||||||
|
.join(
|
||||||
dataset_column_association_table,
|
dataset_column_association_table,
|
||||||
dataset_column_association_table.c.column_id == NewColumn.id,
|
# Use column id from subquery
|
||||||
|
dataset_column_association_table.c.column_id == subquery.c.id,
|
||||||
)
|
)
|
||||||
.join(
|
.join(
|
||||||
NewDataset,
|
NewDataset,
|
||||||
|
@ -661,12 +678,14 @@ def postprocess_columns(session: Session) -> None:
|
||||||
.join(Database, Database.id == NewDataset.database_id)
|
.join(Database, Database.id == NewDataset.database_id)
|
||||||
.join(
|
.join(
|
||||||
TableColumn,
|
TableColumn,
|
||||||
TableColumn.uuid == NewColumn.uuid,
|
# Use column uuid from subquery
|
||||||
|
TableColumn.uuid == subquery.c.uuid,
|
||||||
isouter=True,
|
isouter=True,
|
||||||
)
|
)
|
||||||
.join(
|
.join(
|
||||||
SqlMetric,
|
SqlMetric,
|
||||||
SqlMetric.uuid == NewColumn.uuid,
|
# Use column uuid from subquery
|
||||||
|
SqlMetric.uuid == subquery.c.uuid,
|
||||||
isouter=True,
|
isouter=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue