Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[explore] fetching of column values for filters not working with superset views #2810

Closed
3 tasks done
rumbin opened this issue May 24, 2017 · 5 comments · Fixed by #2816
Closed
3 tasks done

[explore] fetching of column values for filters not working with superset views #2810

rumbin opened this issue May 24, 2017 · 5 comments · Fixed by #2816

Comments

@rumbin
Copy link
Contributor

rumbin commented May 24, 2017

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.18.2

Expected results

Tables defined via SQL statement (superset view), e.g. via the visualize workflow from SQLLab, should behave like regular tables or views with respect to the filter select functionality in explore view.
I.e., fetching on distinct column values should succeed.

Actual results

Fetching of distinct column values fails because the SQL query is not run agains the superset view as a subquery, but against the table name. In general, this table is of course not known by the SQL server.

sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "test_superset_view" does not exist

Steps to reproduce

  • Create a superset view, e.g. via the visualize workflow from SQLLab and enable Filter Select for this table.
  • Explore the table and try to add a filter on any filterable column.
@mistercrunch
Copy link
Member

This looks postgres specific, can you please share the full stacktrace from the web server?

@rumbin
Copy link
Contributor Author

rumbin commented May 25, 2017

It is definitely not postgres specific. I just tested it with a fresh installation, using nothing but the default SQLite database.

Steps to reproduce

  • Run this query in SQLLab on the main (superset) database:
SELECT id,
       name
FROM main.ab_role
  • Create a superset view out of it via visualize, naming the table test_superset_view (just for further reference)
  • Enable Filter Select for this table
  • explore the table and try to select filters on either of the two columns
2017-05-25 07:08:35,381:ERROR:root:(sqlite3.OperationalError) no such table: test_superset_view [SQL: 'SELECT DISTINCT id AS id \nFROM test_superset_view\n LIMIT 10000 OFFSET 0']
Traceback (most recent call last):
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: test_superset_view

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/superset/views/base.py", line 49, in wraps
    return f(self, *args, **kwargs)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/flask_appbuilder/security/decorators.py", line 52, in wraps
    return f(self, *args, **kwargs)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/superset/views/core.py", line 1090, in filter
    payload = json.dumps(datasource.values_for_column(column))
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/superset/connectors/sqla/models.py", line 314, in values_for_column
    df = pd.read_sql_query(sql=sql, con=engine)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/pandas/io/sql.py", line 331, in read_sql_query
    parse_dates=parse_dates, chunksize=chunksize)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/pandas/io/sql.py", line 1084, in read_query
    result = self.execute(*args)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/pandas/io/sql.py", line 975, in execute
    return self.connectable.execute(*args, **kwargs)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 2064, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 939, in execute
    return self._execute_text(object, multiparams, params)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 1097, in _execute_text
    statement, parameters
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/opt/apps/superset/venv_py3_test/lib64/python3.4/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: test_superset_view [SQL: 'SELECT DISTINCT id AS id \nFROM test_superset_view\n LIMIT 10000 OFFSET 0']

As stated before: as far as I understand, the query should be run against the subquery that is defined by the superset view, rather than just against its table name.

@mistercrunch
Copy link
Member

Oh I understand now.

@mistercrunch
Copy link
Member

Here's the fix #2816

@rumbin
Copy link
Contributor Author

rumbin commented May 25, 2017

Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants