You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "Quatters (via GitHub)" <gi...@apache.org> on 2025/06/08 05:09:39 UTC

[PR] fix(serialization): allow unicode in json serialization [superset]

Quatters opened a new pull request, #33720:
URL: https://github.com/apache/superset/pull/33720

   <!---
   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 -->
   PR changes the output of `json.dumps` to show unicode characters as they are, instead of using escape sequences.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   | Before | After|
   | - | - |
   | ![Снимок экрана 08 06 2025@2x](https://github.com/user-attachments/assets/8a3deef7-9d0c-40c1-8a1f-13afbe322034) | ![Снимок экрана 08 06 2025@2x](https://github.com/user-attachments/assets/58047f2e-573f-4016-ad0e-604160270f59) |
   
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [x] Has associated issue: 
   Fixes #19388 
   Fixes #22904
   - [ ] 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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-4041988768

   Rebased and cleaned up on the author's behalf. The branch had 11 commits (including several "Try to set collation" iterations and merge commits) — squashed down to a single clean commit with the net changes:
   
   - `superset/utils/json.py`: `ensure_ascii=False` added to `simplejson.dumps`
   - `tests/unit_tests/utils/json_tests.py`: unicode test added
   - `.github/workflows/bashlib.sh`: MySQL charset/collation updated to `utf8mb4`/`utf8mb4_0900_ai_ci`
   
   All pre-commit checks pass. Marking ready for review.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3181047242

   Looks like this needs conflict resolution and perhaps some migration work. I'll set it to draft for now.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "Quatters (via GitHub)" <gi...@apache.org>.
Quatters commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2983709339

   Done here


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #33720:
URL: https://github.com/apache/superset/pull/33720#discussion_r2155052035


##########
UPDATING.md:
##########
@@ -23,6 +23,9 @@ This file documents any backwards-incompatible changes in Superset and
 assists people when migrating to a new version.
 
 ## Next
+- [33720](https://github.com/apache/superset/pull/33720) If you're using MySQL as your metadata database for Superset, please

Review Comment:
   @michael-s-molina, I believe your Superset instance @Airbnb uses MySQL behind the scene. How do you feel about this `UPDATING.md` notice? Should we test this forward before merging? Would love to get your blessing on this approach.



-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #33720:
URL: https://github.com/apache/superset/pull/33720#discussion_r2155078534


##########
UPDATING.md:
##########
@@ -23,6 +23,9 @@ This file documents any backwards-incompatible changes in Superset and
 assists people when migrating to a new version.
 
 ## Next
+- [33720](https://github.com/apache/superset/pull/33720) If you're using MySQL as your metadata database for Superset, please

Review Comment:
   @villebro @sadpandajoe @rusackas Would this be a breaking change in your opinion?



-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2971702412

   re-running that test, just in case. 


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #33720:
URL: https://github.com/apache/superset/pull/33720#discussion_r2155075814


##########
UPDATING.md:
##########
@@ -23,6 +23,9 @@ This file documents any backwards-incompatible changes in Superset and
 assists people when migrating to a new version.
 
 ## Next
+- [33720](https://github.com/apache/superset/pull/33720) If you're using MySQL as your metadata database for Superset, please

Review Comment:
   > How do you feel about this UPDATING.md notice?
   
   I'm not sure if this would be considered a breaking change...
   
   >  Should we test this forward before merging?
   
   Definitely. We need to check what the update process looks like.



-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3075546602

   Resolved the conflict and currently re-running CI. Hopefully we can get this merged, pronto!


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "Quatters (via GitHub)" <gi...@apache.org>.
Quatters commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3121065240

   I think automatic migration as @sadpandajoe suggests is better even if it's not strictly required, to be sure that all users starting from version X applied this migration. This seems more consistent and less problems in the future.
   
   Therefore I plan to 
   1. Create a migration file that detects whether MySQL is being used and applies the actions suggested by @michael-s-molina.
   2. Write some tests to ensure the migration works correctly.
   3. Add a note in UPDATING.md stating that applying the migration requires downtime.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "Quatters (via GitHub)" <gi...@apache.org>.
Quatters commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3052424974

   Hi @mistercrunch, @michael-s-molina, any updates on this?


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3057188373

   > Hi @mistercrunch, @michael-s-molina, any updates on this?
   
   We were OOO due to the holidays but I added this item to our team's backlog. Hoping to test this in the next couple weeks.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2984946004

   @Quatters , thank for doing all the work here. This seems viable. I added a comment to check in with folks using MySQL as their metadata db to get their input/blessing on this approach.
   
   Note that this PR fixes user-visible issues around unicode handling with analytics databases.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2968369815

   This seems like a win to me, though seeing `test-mysql` fail in CI (assuming it's related to this change) shows that this change might have some upgrade implications.
   
   If there are indeed change management issues, it may require:
   - adding a line in 1UPDATING.md` about required checks/changes around the the future upgrades
   - [I'm hoping that's not the case but needs to be ruled-out] maybe this would require a database migration script to re-serialize/migrate the json that we have serialized in some/all databases (?)
   
   Related GPT thread -> https://chatgpt.com/share/684b5999-8d50-8010-ab53-d62e10188b50


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3882999171

   Anyone interested in brushing this up and getting it through? I'm closing out some old drafts, but this one looks like it had significant effort, so I'm a little hesitant in this case.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-4773898708

   @Quatters the `ensure_ascii=False` change seems like a good fix for the unicode display issue, but `test_position_json_emoji_is_ascii_safe_in_db` (tests/integration_tests/dashboards/test_update_emoji.py:92) asserts the opposite, that the stored string stays ASCII-safe, so it's red on test-mysql/postgres/sqlite. That test was added on purpose for the emoji-truncation bug, so we need to settle the conflict rather than just delete it.
   
   And @michael-s-molina's change request was waiting on the MySQL migration + UPDATING.md note we'd agreed to, which I don't see here yet. Is that still on your plate, or do you want a hand with the rebase to get CI re-running?


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3079685436

   I guess the question here is, if i'm using a mysql database and I don't run the migrations, will this break superset for me? If it does, probably better to just create a migration file and have it detect if the db is mysql and if it is, then run it, else just pass. 


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2977943667

   Related: https://chatgpt.com/share/68507758-62e8-8010-8f63-a73f6c1eed55
   
   Seems the connection string AND [maybe] the database settings need to be altered to support this (?)
   
   If we can make CI pass, add a note in `UPDATING.md`, and document that it's a requirement for MySQL somewhere I'm fine with the change.
   
   Other option would be to set `ensure_ascii=False` only for analytics database use cases, and keep it True for metadata database interaction, though that's probably confusing and maybe harder to maintain as we'd have different logic based on context...


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2984933502

   I don't think we need a db migration, except maybe for MySQL (unclear). In theory the json/simplejson implementation is compatible across the `ensure_ascii` setting. Now the issue seems to be that MySQL, depending on its setup and `CHARACTER_SET` default setting, chokes when getting unicode characters.


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on code in PR #33720:
URL: https://github.com/apache/superset/pull/33720#discussion_r2155075814


##########
UPDATING.md:
##########
@@ -23,6 +23,9 @@ This file documents any backwards-incompatible changes in Superset and
 assists people when migrating to a new version.
 
 ## Next
+- [33720](https://github.com/apache/superset/pull/33720) If you're using MySQL as your metadata database for Superset, please

Review Comment:
   > How do you feel about this UPDATING.md notice?
   
   I'm not sure if this would be considered a breaking change...
   
   >  Should we test this forward before merging?
   
   Definitely. We need to check what's the update process looks like.



-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed pull request #33720: fix(serialization): allow unicode in json serialization
URL: https://github.com/apache/superset/pull/33720


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-4042336596

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #33720:
URL: https://github.com/apache/superset/pull/33720#discussion_r2155667421


##########
UPDATING.md:
##########
@@ -23,6 +23,9 @@ This file documents any backwards-incompatible changes in Superset and
 assists people when migrating to a new version.
 
 ## Next
+- [33720](https://github.com/apache/superset/pull/33720) If you're using MySQL as your metadata database for Superset, please

Review Comment:
   yes, from my understanding you'd have to change the character set in your MySQL instance, and I'm unclear if switching the global setting is sufficient, or whether that global setting gets materialized into columns in which case you may have to change it for every column (?)



-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-2978330433

   Copilot's suggestions, FWIW:
   
   1. Migration Failure Fix
   Update the migration script to handle the foreign key constraint before dropping the column. Modify the script to drop the foreign key first and then the column:
   
   ```python
   from alembic import op
   import sqlalchemy as sa
   
   def upgrade():
       # Drop the foreign key constraint
       op.drop_constraint('slices_ibfk_1', 'slices', type_='foreignkey')
       # Drop the column
       op.drop_column('slices', 'druid_datasource_id')
   
   def downgrade():
       # Recreate the column (if needed during downgrade)
       op.add_column('slices', sa.Column('druid_datasource_id', sa.Integer(), nullable=True))
       # Recreate the foreign key constraint
       op.create_foreign_key('slices_ibfk_1', 'slices', 'druid_datasource', ['druid_datasource_id'], ['id'])
   ```
   
   2. Test Failure Fix
   The OperationalError indicates that the position_json column does not support certain Unicode characters. Ensure the column uses a character set that supports all Unicode characters (e.g., utf8mb4 for MySQL).
   
   Steps:
   
   * Update the database schema:
     ```sql
     ALTER TABLE dashboards MODIFY COLUMN position_json TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
     ```
    * Ensure the database connection is configured to use utf8mb4: Modify the connection string in your configuration:
      ```python
     SQLALCHEMY_DATABASE_URI = "mysql+pymysql://<user>:<password>@<host>/<db_name>?charset=utf8mb4"
     ```


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "michael-s-molina (via GitHub)" <gi...@apache.org>.
michael-s-molina commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-3078599846

   @Quatters @mistercrunch @rusackas I executed the following migration to convert our existing MySQL database to be adherent to the changes in this PR.
   
   Step 1: Backup Your Database First
   
   ```
   mysqldump -u your_username -p your_database_name > backup_$(date +%Y%m%d_%H%M%S).sql
   ```
   
   Step 2: Check Current State
   
   ```
   -- Check current database character set
   SHOW CREATE DATABASE your_database_name;
   
   -- Check all tables and their character sets
   SELECT TABLE_NAME, TABLE_COLLATION 
   FROM INFORMATION_SCHEMA.TABLES 
   WHERE TABLE_SCHEMA = 'your_database_name';
   
   -- Check all columns with character sets
   SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME, COLLATION_NAME, DATA_TYPE
   FROM INFORMATION_SCHEMA.COLUMNS 
   WHERE TABLE_SCHEMA = 'your_database_name' 
   AND CHARACTER_SET_NAME IS NOT NULL
   ORDER BY TABLE_NAME, COLUMN_NAME;
   ```
   
   Step 3: Change Database Default
   
   ```
   -- Change the database default character set
   ALTER DATABASE your_database_name 
   DEFAULT CHARACTER SET utf8mb4 
   COLLATE utf8mb4_0900_ai_ci;
   ```
   
   Step 4: Generate Conversion Commands for All Tables
   
   ```
   -- Generate ALTER TABLE commands for all tables
   SELECT CONCAT(
       'ALTER TABLE `', TABLE_NAME, 
       '` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;'
   ) AS conversion_command
   FROM INFORMATION_SCHEMA.TABLES 
   WHERE TABLE_SCHEMA = 'your_database_name' 
   AND TABLE_TYPE = 'BASE TABLE'
   ORDER BY TABLE_NAME;
   ```
   
   Step 5: Optional - Check Table Sizes Before Conversion
   
   ```
   SELECT 
       TABLE_NAME,
       TABLE_ROWS,
       ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024), 2) AS 'Size_MB',
       ROUND(AVG_ROW_LENGTH) AS 'Avg_Row_Length'
   FROM INFORMATION_SCHEMA.TABLES 
   WHERE TABLE_SCHEMA = 'your_database_name' 
   AND TABLE_TYPE = 'BASE TABLE'
   ORDER BY (DATA_LENGTH + INDEX_LENGTH);
   ```
   
   Step 6: Prepare for Conversion
   
   ```
   -- Disable foreign key checks temporarily (if you have foreign keys)
   SET FOREIGN_KEY_CHECKS = 0;
   
   -- Optional: Increase timeouts for large tables
   SET SESSION innodb_lock_wait_timeout = 300;
   SET SESSION lock_wait_timeout = 300;
   ```
   
   Step 7: Convert All Tables
   Replace your_database_name with your actual database name, then run the output from Step 4. Here's the template:
   
   ```
   -- Example conversion commands (replace with your actual table names)
   ALTER TABLE `table1` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
   ALTER TABLE `table2` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
   ALTER TABLE `table3` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;
   -- ... (continue for all tables)
   ```
   
   Step 8: Re-enable Constraints
   
   ```
   -- Re-enable foreign key checks
   SET FOREIGN_KEY_CHECKS = 1;
   ```
   
   Step 9: Verify the Conversion
   
   ```
   -- Verify database default
   SHOW CREATE DATABASE your_database_name;
   
   -- Verify all tables are converted
   SELECT TABLE_NAME, TABLE_COLLATION 
   FROM INFORMATION_SCHEMA.TABLES 
   WHERE TABLE_SCHEMA = 'your_database_name'
   AND TABLE_COLLATION != 'utf8mb4_0900_ai_ci';
   
   -- Should return no rows if all tables are converted
   
   -- Verify all character columns are converted
   SELECT TABLE_NAME, COLUMN_NAME, CHARACTER_SET_NAME, COLLATION_NAME
   FROM INFORMATION_SCHEMA.COLUMNS 
   WHERE TABLE_SCHEMA = 'your_database_name' 
   AND CHARACTER_SET_NAME IS NOT NULL
   AND CHARACTER_SET_NAME != 'utf8mb4';
   
   -- Should return no rows if all columns are converted
   ```
   
   Some observations:
   - You can't simply change the database default character set. If you do that, the setting will only be applicable to new tables.
   - This means that you need to convert all tables and their data to the new setting.
   - The process does not take very long time (100k rows in 17 seconds) but does require downtime. @Quatters this needs to be explicitly called in `UPDATING.md`.
   - We also need to mention the required change for the connection string in `UPDATING.md` as admins will not read the Configuring Superset docs.
   - After the migration, characters like 大盘 are rendered correctly but emojis like 😀🌟 are rendered as ???????? 


-- 
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(serialization): allow unicode in json serialization [superset]

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

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/33720?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   All modified and coverable lines are covered by tests :white_check_mark:
   > Project coverage is 51.76%. Comparing base [(`76d897e`)](https://app.codecov.io/gh/apache/superset/commit/76d897eaa2f9e137102bc194c2e3109c29d0348f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`e8ae854`)](https://app.codecov.io/gh/apache/superset/commit/e8ae854dcf654d087e28adbd5e3c378199705810?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   > Report is 1937 commits behind head on master.
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #33720      +/-   ##
   ==========================================
   - Coverage   60.48%   51.76%   -8.73%     
   ==========================================
     Files        1931      558    -1373     
     Lines       76236    40278   -35958     
     Branches     8568     4221    -4347     
   ==========================================
   - Hits        46114    20850   -25264     
   + Misses      28017    18870    -9147     
   + Partials     2105      558    -1547     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/33720/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/33720/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `47.22% <ø> (-1.94%)` | :arrow_down: |
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/33720/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/33720/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `50.97% <ø> (-2.83%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/33720/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `51.76% <ø> (-11.75%)` | :arrow_down: |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/33720/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (+42.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/33720?dropdown=coverage&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).
   
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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(serialization): allow unicode in json serialization [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #33720:
URL: https://github.com/apache/superset/pull/33720#issuecomment-4834993828

   Thanks for chasing this down @Quatters, the diagnosis here was spot on. Since it'd gone quiet, I took a crack at it on #41533 with a narrower approach: instead of flipping `ensure_ascii=False` globally (which tripped the `position_json` emoji guard from #39737 and would've needed a MySQL charset migration), it only changes the result-set `stringify` path so array/struct values render unicode, leaving the metadata escaping intact. Kept you on as co-author. I'll close this in favor of that one, but holler if you'd rather carry it forward yourself :)


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