You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "xneg (via GitHub)" <gi...@apache.org> on 2023/01/26 14:02:10 UTC

[GitHub] [superset] xneg opened a new issue, #22870: Dashboards api is broken after migration from 1.3 to 2.0

xneg opened a new issue, #22870:
URL: https://github.com/apache/superset/issues/22870

   Hi!
   We've used Superset version 1.3 for the last year. Now we try to upgrade to version 2.0.
   Migration applied ok, most things are working but there is a problem with dashboards api. 
   
   When I send request to endpoint `/api/v1/dashboard/` I get this error:
   ` "Detected unaliased columns when generating joined load.  Make sure to use aliased=True or flat=True when using joined loading with with_polymorphic()."`
   
   Here is the stacktrace:
   ```
   Traceback (most recent call last):
     File "/app/superset/views/base.py", line 210, in wraps
       return f(self, *args, **kwargs)
     File "/app/superset/views/base_api.py", line 423, in get_list_headless
       duration, response = time_function(super().get_list_headless, **kwargs)
     File "/app/superset/utils/core.py", line 1524, in time_function
       response = func(*args, **kwargs)
     File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/api/__init__.py", line 1517, in get_list_headless
       count, lst = self.datamodel.query(
     File "/usr/local/lib/python3.8/site-packages/flask_appbuilder/models/sqla/interface.py", line 471, in query
       query_results = query.all()
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3373, in all
       return list(self)
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 3531, in __iter__
       context = self._compile_context()
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 4085, in _compile_context
       entity.setup_context(self, context)
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/query.py", line 4450, in setup_context
       loading._setup_entity_query(
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/loading.py", line 318, in _setup_entity_query
       value.setup(
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/interfaces.py", line 555, in setup
       strat.setup_query(
     File "/usr/local/lib/python3.8/site-packages/sqlalchemy/orm/strategies.py", line 1560, in setup_query
       raise sa_exc.InvalidRequestError(
   sqlalchemy.exc.InvalidRequestError: Detected unaliased columns when generating joined load.  Make sure to use aliased=True or flat=True when using joined loading with with_polymorphic().
   ```
   
   I investigated a bit in this and found that the problem was caused by this code from FAB:
   
   ```
   count, lst = self.datamodel.query(
               joined_filters,
               order_column,
               order_direction,
               page=page_index,
               page_size=page_size,
               select_columns=self.list_select_columns,
           )
   ```
   Specifically, line `select_columns=self.list_select_columns`. This list_select_columns comes from [here](https://github.com/apache/superset/blob/f8edcd7ae2f1a716505327770b5abaa7691c784a/superset/dashboards/api.py#L156).
   
   I'm not very strong in FAB ORM and SQLAlchemy. What I see is that schema of `dashboards` table hasn't changed. So I'm not sure why after migration it doesn't work as intended.
   Maybe someone could help me in this question?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] xneg commented on issue #22870: Dashboards api is broken after migration from 1.3 to 1.5

Posted by "xneg (via GitHub)" <gi...@apache.org>.
xneg commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1416715106

   @AAfghahi yes, sure it doesn't require any fixes in 2.0.2.
   > Though to get around the unique-ness clause, instead of creating a custom User, there is a way to use email aliases.
   
   Can you explain more in detail, please? What I've found in the first place and why I created custom User is this point from FAB docs:
   https://flask-appbuilder.readthedocs.io/en/latest/security.html#your-custom-security


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] rusackas commented on issue #22870: Dashboards api is broken after migration from 1.3 to 2.0

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1406926331

   Pinging @eschutho and @AAfghahi in case this indicates something that needs to be patched in 2.0.2. I'm guessing most people made it to 1.5 before upgrading to 2.0, so I'm wondering if there's something different when making that large of a leap.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] Step1N commented on issue #22870: Dashboards api is broken after migration from 1.3 to 1.5

Posted by "Step1N (via GitHub)" <gi...@apache.org>.
Step1N commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1737459991

   I am also getting same error after removing email unique constraint.
   
   Superset version 2.1  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Dashboards api is broken after migration from 1.3 to 1.5 [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed issue #22870: Dashboards api is broken after migration from 1.3 to 1.5
URL: https://github.com/apache/superset/issues/22870


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] xneg commented on issue #22870: Dashboards api is broken after migration from 1.3 to 2.0

Posted by "xneg (via GitHub)" <gi...@apache.org>.
xneg commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1410182582

   I finally localized the problem. This error was because I introduced our custom SecurityManager with custom User class:
   ```
   class CustomUser(User):
       __tablename__ = 'ab_user'
       email = Column(String(64), unique=False, nullable=False)
   
   
   class CustomSecurityManager(SupersetSecurityManager):
       user_model = CustomUser
   ```
   I've done this in the first place to overcome the issue with unique email constraint. It worked for version 1.3 but stopped since 1.5.
   So, maybe any suggestions on how properly remove unique email constraint?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [I] Dashboards api is broken after migration from 1.3 to 1.5 [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1922400337

   We're now on 3.1, on the verge of 4.0, and not supporting 2.x  or prior versions actively. If folks are experiencing this issue in current versions, please file a new issue with updated context and repro steps. Thank you for understanding :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] AAfghahi commented on issue #22870: Dashboards api is broken after migration from 1.3 to 1.5

Posted by "AAfghahi (via GitHub)" <gi...@apache.org>.
AAfghahi commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1416236495

   Since this is a custom feature I don't think that we are going to be able to fix it in 2.0.2. Though to get around the unique-ness clause, instead of creating a custom User, there is a way to use email aliases. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] xneg commented on issue #22870: Dashboards api is broken after migration from 1.3 to 2.0

Posted by "xneg (via GitHub)" <gi...@apache.org>.
xneg commented on issue #22870:
URL: https://github.com/apache/superset/issues/22870#issuecomment-1408498998

   To add more information.
   Here is the schema of `dashboards` table of 1.3 at our production
   ```
   create table public.dashboards
   (
       created_on      timestamp,
       changed_on      timestamp,
       id              serial
           primary key,
       dashboard_title varchar(500),
       position_json   text,
       created_by_fk   integer
           references public.ab_user,
       changed_by_fk   integer
           references public.ab_user,
       css             text,
       description     text,
       slug            varchar(255)
           constraint idx_unique_slug
               unique,
       json_metadata   text,
       published       boolean,
       uuid            uuid
           constraint uq_dashboards_uuid
               unique
   );
   ```
   Here is schema of the same table when I upgraded from 1.3 to 2.0
   ```
   create table public.dashboards
   (
       created_on            timestamp,
       changed_on            timestamp,
       id                    serial,
       dashboard_title       varchar(500),
       position_json         text,
       created_by_fk         integer
           references public.ab_user (id),
       changed_by_fk         integer
           references public.ab_user (id),
       css                   text,
       description           text,
       slug                  varchar(255),
       json_metadata         text,
       published             boolean,
       uuid                  uuid,
       certified_by          text,
       certification_details text,
       is_managed_externally boolean default false not null,
       external_url          text,
       primary key (),
       constraint idx_unique_slug
           unique (),
       constraint uq_dashboards_uuid
           unique ()
   );
   
   create unique index dashboards_pkey
       on public.dashboards using ??? (id);
   
   create unique index idx_unique_slug
       on public.dashboards using ??? (slug);
   
   create unique index uq_dashboards_uuid
       on public.dashboards using ??? (uuid);
   ```
   
   And this is the schema of the same table with fresh 2.0 installation
   ```
   create table public.dashboards
   (
       created_on            timestamp,
       changed_on            timestamp,
       id                    serial
           primary key,
       dashboard_title       varchar(500),
       position_json         text,
       created_by_fk         integer
           references public.ab_user,
       changed_by_fk         integer
           references public.ab_user,
       css                   text,
       description           text,
       slug                  varchar(255)
           constraint idx_unique_slug
               unique,
       json_metadata         text,
       published             boolean,
       uuid                  uuid
           constraint uq_dashboards_uuid
               unique,
       certified_by          text,
       certification_details text,
       is_managed_externally boolean default false not null,
       external_url          text
   );
   ```
   
   It seems to me that the problem is with these question marks after migration. Maybe it was not totally successful?
   ```
   create unique index dashboards_pkey
       on public.dashboards using ??? (id);
   
   create unique index idx_unique_slug
       on public.dashboards using ??? (slug);
   
   create unique index uq_dashboards_uuid
       on public.dashboards using ??? (uuid);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org