You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Vitor-Avila (via GitHub)" <gi...@apache.org> on 2024/01/11 15:59:42 UTC

[PR] fix(BigQuery): Support special characters in column/metric names used in ORDER BY [superset]

Vitor-Avila opened a new pull request, #26461:
URL: https://github.com/apache/superset/pull/26461

   ### SUMMARY
   The `BigQueryEngineSpec` has `allows_hidden_cc_in_orderby` set to `True`, so the `ORDER BY` statement uses the actual metric/dimension alias, rather than its SQL expression (implementation PR: https://github.com/apache/superset/pull/17196).
   
   In case the metric alias has a special characters (like accents or Chinese characters for example), the query will throw an error.
   
   Fixes https://github.com/apache/superset/issues/26459
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   **Before:**
   
   https://github.com/apache/superset/assets/96086495/3db44c50-1fbb-4809-a123-cd4ea23f65ca
   
   **After:**
   
   https://github.com/apache/superset/assets/96086495/36a0745a-0f67-4130-934a-2abc77b0ff70
   
   
   
   
   ### TESTING INSTRUCTIONS
   1. Create a dataset from a BQ connection.
   2. Use it to create a **Table** chart.
   3. Add any column as its dimension, and create a metric named `métric` using `COUNT(*)` as its SQL expression.
   
   ### ADDITIONAL INFORMATION
   - [X] Has associated issue: https://github.com/apache/superset/issues/26459
   - [ ] 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(BigQuery): Support special characters in column/metric names used in ORDER BY [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #26461:
URL: https://github.com/apache/superset/pull/26461#issuecomment-1887484827

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/26461?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: `3 lines` in your changes are missing coverage. Please review.
   > Comparison is base [(`ea4e9a6`)](https://app.codecov.io/gh/apache/superset/commit/ea4e9a6403086d4e1de84e8197c08e8114dceeed?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 69.16% compared to head [(`fd96bd6`)](https://app.codecov.io/gh/apache/superset/pull/26461?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) 56.20%.
   > Report is 3 commits behind head on master.
   
   | [Files](https://app.codecov.io/gh/apache/superset/pull/26461?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/26461?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | 0.00% | [3 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/26461?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   #26461       +/-   ##
   ===========================================
   - Coverage   69.16%   56.20%   -12.97%     
   ===========================================
     Files        1948     1948               
     Lines       76054    76063        +9     
     Branches     8493     8493               
   ===========================================
   - Hits        52601    42748     -9853     
   - Misses      21273    31135     +9862     
     Partials     2180     2180               
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/26461/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/26461/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/26461/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/26461/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/26461/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [python](https://app.codecov.io/gh/apache/superset/pull/26461/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.87% <0.00%> (-26.99%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/26461/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/26461/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.87% <0.00%> (+<0.01%)` | :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/26461?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(BigQuery): Support special characters in column/metric names used in ORDER BY [superset]

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #26461:
URL: https://github.com/apache/superset/pull/26461#discussion_r1449216186


##########
superset/models/helpers.py:
##########
@@ -1974,7 +1974,9 @@ def get_sqla_query(  # pylint: disable=too-many-arguments,too-many-locals,too-ma
                 and db_engine_spec.allows_hidden_cc_in_orderby
                 and col.name in [select_col.name for select_col in select_exprs]
             ):
-                col = literal_column(col.name)
+                engine = self.database._get_sqla_engine()
+                quote = engine.dialect.identifier_preparer.quote
+                col = literal_column(quote(col.name))

Review Comment:
   Interesting. Typically the SQLAlchemy dialect should handle the quoting. Additionally it's unclear whether forceably quoting the column would be problematic when combined with an alias.
   
   @villebro do you have any insights on this? I see previously you registered https://github.com/sqlalchemy/sqlalchemy/issues/4730 related to SQLAlchemy not quoting.



-- 
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(BigQuery): Support special characters in column/metric names used in ORDER BY [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas merged PR #26461:
URL: https://github.com/apache/superset/pull/26461


-- 
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