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

Filter on bool column not working properly in SQL Lab -> Explore #10098

Closed
2 of 3 tasks
dolorez opened this issue Jun 18, 2020 · 8 comments · Fixed by #14567
Closed
2 of 3 tasks

Filter on bool column not working properly in SQL Lab -> Explore #10098

dolorez opened this issue Jun 18, 2020 · 8 comments · Fixed by #14567
Labels
assigned:airbnb Assigned to the airbnb team !deprecated-label:bug Deprecated label - Use #bug instead .pinned Draws attention sqllab Namespace | Anything related to the SQL Lab

Comments

@dolorez
Copy link

dolorez commented Jun 18, 2020

When a query in SQL Lab is executed and a filter is applied to a boolean column, it errors out on datatype comparison (boolean vs string).
Note - the behavior

Expected results

The filter should work - the generated query should not enclose the field value in single quotes.

Actual results

The query generated encloses the filter value in single quotes so the where clause generated looks (some_bool_flag = 'true') and this that in turn generates type mismatch

How to reproduce the bug

  1. Go to SQL Lab -> SQL Editor
  2. Write a query that returns a boolean column
  3. Execute the query
  4. Click on Explore
  5. Scroll down to filters
  6. Add a filter on a boolean column and make sure you stay in Simple (not Custom SQL)
  7. Use equals and set filter value to "true" (without double quotes)
  8. Execute the query to see the error messge
  9. Click on menu -> View query to inspect that the filter value was enclosed in single quotes

Environment

(please complete the following information):

  • superset version: `superset version
    0.34.1
  • python version: python --version
    Python 3.6.9
  • node.js version: node -v
    v12.18.0
  • npm version: npm -v
    6.14.4

Checklist

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 there are any.
  • I have reproduced the issue with at least the latest released version of superset.
    I have no control over the environment :(
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

When the filter is entered using the Custom SQL instead of Simple, it works fine

@dolorez dolorez added the !deprecated-label:bug Deprecated label - Use #bug instead label Jun 18, 2020
@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.95. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@dolorez dolorez changed the title Filter not working properly in SQL Lab -> Explore Filter on bool column not working properly in SQL Lab -> Explore Jun 18, 2020
@rumbin
Copy link
Contributor

rumbin commented Jun 21, 2020

Could you add the type of database, please?

@dolorez
Copy link
Author

dolorez commented Jun 21, 2020

It's presto and that particular query goes to hive

@stale
Copy link

stale bot commented Aug 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Aug 22, 2020
@stale stale bot closed this as completed Aug 29, 2020
@bkyryliuk bkyryliuk reopened this Oct 14, 2020
@stale stale bot removed the inactive Inactive for >= 30 days label Oct 14, 2020
@bkyryliuk
Copy link
Member

bkyryliuk commented Oct 14, 2020

issue still persists on presto database. It's not possible to replicate for mysql as mysql interpret boolean as tinyint.

Selector looks like this:
image

Clicking on it results in:
image

Sqllab correctly sees the type of the column:
image

@etr2460, @john-bodley - curious if you have similar issue @ airbnb.

@bkyryliuk bkyryliuk added the .pinned Draws attention label Oct 14, 2020
@eugeniamz
Copy link

I see the same issue with Vertica DB. It does not show the option but if you choose the second one you have a TRUE but the first is empty. I work around by going to CUSTOM SQL but this should be resolved.
2020-10-28_18-07-06 (1)

@mistercrunch
Copy link
Member

Maybe we need conditional operators based on data type. BOOLEAN should only offer IS NULL IS TRUE and IS FALSE

@john-bodley
Copy link
Member

@junlincc @zuzana-vej I wonder if we should prioritize this, i.e., not being able to filter on a boolean column using IS TRUE, IS FALSE etc. seems fairly problematic.

@zuzana-vej zuzana-vej added the sqllab Namespace | Anything related to the SQL Lab label Apr 21, 2021
@junlincc junlincc added assigned:airbnb Assigned to the airbnb team bash! labels May 5, 2021
graceguo-supercat pushed a commit that referenced this issue May 18, 2021
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this issue Dec 17, 2021
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
QAlexBall pushed a commit to QAlexBall/superset that referenced this issue Dec 29, 2021
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this issue Mar 6, 2024
* Restrict operators when column is boolean

* refactor 'isOperatorRelevant' a little bit

* Include 'BOOLEAN' to handle presto

* Update tests

* number column should show bool operators

* fix test - some dbs translate true/false to 1/0

* Fix tests and add linting

* When column type is boolean, show bool operators

* Address PR comments - simplify conditions

* Fix a linting error

* Addressing PR comment - remove unused variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assigned:airbnb Assigned to the airbnb team !deprecated-label:bug Deprecated label - Use #bug instead .pinned Draws attention sqllab Namespace | Anything related to the SQL Lab
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants