You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hxxdraised (via GitHub)" <gi...@apache.org> on 2024/01/22 09:23:37 UTC
[PR] fix(time grain): time grain clickhouse db error [superset]
hxxdraised opened a new pull request, #26735:
URL: https://github.com/apache/superset/pull/26735
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
DB error on chart load when time granularity is set when the source is Clickhouse. Error example: ```Error: Orig exception: Code: 215.
DB::Exception: Column `Column2` is not under aggregate function and not in GROUP BY: While processing toStartOfDay(toDateTime(Column2)) AS Column2, count() AS count.```
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
before:

after:

### TESTING INSTRUCTIONS
1. Create ClickHouse database
2. Make table with temporal column
3. Install the Clickhouse driver via adding ```clickhouse-sqlalchemy==0.2.5``` line in `docker/requirements-local.txt`
4. Connect ClickHouse DB to superset
5. Create line chart from table datasource and select temporal column in X-Axis option
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [x] Has associated issue: [#26625](https://github.com/apache/superset/pull/26625)
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "zhaoyongjie (via GitHub)" <gi...@apache.org>.
zhaoyongjie commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-1906896683
@hxxdraised please post the original SQL and fixed SQL in the PR description for the reviewing. I guess that this issue is an known issue in CH SQL parser side, but there is a workaround to fix it in Superset side.
To create a verbose name in the Dataset level in Superset, and then the SQL snippet will be `toStartOfDay(toDateTime(Column2)) AS THE_NEW_VERBOSE_NAME`
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed pull request #26735: fix(time grain): time grain clickhouse db error
URL: https://github.com/apache/superset/pull/26735
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-2218727128
Thanks @round3d ! I'll go ahead and close this PR and the related issue. If anyone has issues and sees the need to reopen this, say the word!
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "zhaoyongjie (via GitHub)" <gi...@apache.org>.
zhaoyongjie commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-1906912547
> @hxxdraised please post the original SQL and fixed SQL in the PR description for the reviewing. I guess that this issue is an known issue in CH SQL parser side, but there is a workaround to fix it in Superset side.
>
> To create a verbose name in the Dataset level in Superset, and then the SQL snippet will be `toStartOfDay(toDateTime(Column2)) AS THE_NEW_VERBOSE_NAME`
<img width="1324" alt="image" src="https://github.com/apache/superset/assets/2016594/655441ff-0996-4d00-ae66-1e1b7145665a">
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-2040718854
Hi all! Just wondering if there's anyone sees a way to move forward on this, and close out the issue (which is getting pretty stale).
I'm also wondering if this is even still an issue, since `clickhouse-connect` was 0.5.3 at the time of reporting and is now on 0.7.7 - maybe we'll get lucky :D
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "TechAuditBI (via GitHub)" <gi...@apache.org>.
TechAuditBI commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-1911780342
@john-bodley @betodealmeida Should not we somehow connect this PR with SIPs 115 and 117?
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-1915915337
@TechAuditBI this change seems unrelated to SIP-115 and SIP-117. Personally—if we adopt the "shift left" mentatility—th necessary change should be made in the [clickhouse-connect](https://github.com/ClickHouse/clickhouse-connect) SQLAlchemy dialect.
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-1905962648
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
Attention: `1 lines` in your changes are missing coverage. Please review.
> Comparison is base [(`6443001`)](https://app.codecov.io/gh/apache/superset/commit/6443001cefa367445734efd9bcfdc5becf82846c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 69.07% compared to head [(`b4da5ce`)](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 59.22%.
> Report is 51 commits behind head on master.
| [Files](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/models/helpers.py](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | 50.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #26735 +/- ##
==========================================
- Coverage 69.07% 59.22% -9.85%
==========================================
Files 1930 1930
Lines 75279 75010 -269
Branches 8429 8429
==========================================
- Hits 51999 44428 -7571
- Misses 21133 28435 +7302
Partials 2147 2147
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.80% <75.00%> (+0.27%)` | :arrow_up: |
| [python](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `62.24% <75.00%> (-20.55%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/26735/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `56.38% <75.00%> (+0.36%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/26735?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "round3d (via GitHub)" <gi...@apache.org>.
round3d commented on PR #26735:
URL: https://github.com/apache/superset/pull/26735#issuecomment-2218461980
Hi @rusackas ,
I use clickhouse (v 5.7.30) with superset master and this isn't a problem for me with clickhouse-connect 0.7.16
The generated SQL works correctly and the group by is not the alias.

--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #26735:
URL: https://github.com/apache/superset/pull/26735#discussion_r1465361789
##########
superset/db_engine_specs/base.py:
##########
@@ -397,6 +397,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
# Can the catalog be changed on a per-query basis?
supports_dynamic_catalog = False
+ # Use column alias instead of aggregate function in GROUP BY
+ use_column_alias_in_groupby = False
Review Comment:
I'm surprised that the SQLAlchemy dialect doesn't handle this. The [`visit_label`](https://github.com/sqlalchemy/sqlalchemy/blob/main/lib/sqlalchemy/sql/compiler.py#L2479-L2526) method is likely relevant. Ideally we adopt the "shift left" mentality and have the underlying dialect (rather than Superset) handle this logic.
--
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: [PR] fix(time grain): time grain clickhouse db error [superset]
Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #26735:
URL: https://github.com/apache/superset/pull/26735#discussion_r1465335341
##########
superset/db_engine_specs/base.py:
##########
@@ -397,6 +397,9 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
# Can the catalog be changed on a per-query basis?
supports_dynamic_catalog = False
+ # Use column alias instead of aggregate function in GROUP BY
Review Comment:
```suggestion
# Use column alias instead of aggregate function in GROUP BY
```
--
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