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

Disable Strict Mode in SQL Lab #18065

Closed
FaidJalal19 opened this issue Jan 17, 2022 · 1 comment
Closed

Disable Strict Mode in SQL Lab #18065

FaidJalal19 opened this issue Jan 17, 2022 · 1 comment

Comments

@FaidJalal19
Copy link

Whenever I use GROUP BY in SQL Lab, I am getting an error stating

MySQL Error
mysql error: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column

How to disable the strict mode?

@betodealmeida
Copy link
Member

betodealmeida commented Jan 17, 2022

This is an issue with MySQL, not Superset. You can disable ONLY_FULL_GROUP_BY by doing something like this:

SET sql_mode=(SELECT REPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', ''));

Alternatively, you can fix your SQL to ensure that all non-aggregated columns are listed in the GROUP BY.

Before:

SELECT
  COUNT(*),  -- aggregation
  country,   -- non-aggregation, should be in the group by
  gender     -- non-aggregation, should be in the group by
FROM my_table
GROUP BY
  country;   -- missing "gender"

After:

SELECT
  COUNT(*),
  country,
  gender
FROM my_table
GROUP BY
  country,
  gender;  -- ADDED "gender"

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

No branches or pull requests

2 participants