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

fix(sqllab): Invalid start date #25133

Merged
merged 5 commits into from
Sep 1, 2023

Conversation

justinpark
Copy link
Member

@justinpark justinpark commented Aug 30, 2023

SUMMARY

Fixes #24790

Since /updated_since api migrate to v1 in #22611 , the startDttm format has been changed from a number to a string.

api/v1 legacy api
Superset superset-dev_-Airbnb-_Slack

Similar to #19605, it fails the conversion to a moment object. Since the Flask’s JSON serialization of decimals casts it to a string is actually correct as it preserves precision, so the frontend should expect strings.
This commit adds the extra parse logic in sqllab query sync to handle the floating value in the string format.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

After:

https://user-images.githubusercontent.com/1392866/264449407-c2015fe7-d1ef-48b4-9c98-60de6aa27c9c.png

Before:

https://user-images.githubusercontent.com/57723564/255794908-2b4a9005-00fc-4adc-95b0-d7a8a0fdee09.png

TESTING INSTRUCTIONS

Go to SQLLab and run a query
Go to Query history and check the start date column

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • 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

@@ -56,7 +56,10 @@ export default async function parseResponse<T extends ParseMethod = 'json'>(
// `json-bigint` could not handle floats well, see sidorares/json-bigint#62
// TODO: clean up after json-bigint>1.0.1 is released
json: cloneDeepWith(json, (value: any) =>
value?.isInteger?.() === false ? Number(value) : undefined,
value?.isInteger?.() === false ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinpark how is there any merit to casting this to a Decimal as opposed to a Number or are these types typically not used by the Superset frontend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I also concerned about the data inaccuracy issue since this will convert all float numbers in Number(even Decimal) which can drop some digits in a long form 234020423042304302.402 vs 234020423042304300 (=Number(234020423042304302.402))

I reverted this json-bigint modification and made the extra date value conversion logic in SqlLab instead.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Aug 30, 2023
@john-bodley
Copy link
Member

@justinpark I think your current implementation is safer, i.e., casting specific instances of stringified decimals to a Number as opposed to all.

@mdeshmu
Copy link
Contributor

mdeshmu commented Aug 31, 2023

@justinpark can you please also add a date component to "Started" in SQL Lab Query History as it is really difficult to identify what date query ran on with just time displayed.

@justinpark
Copy link
Member Author

@mdeshmu I added the date value in the format.
Screenshot 2023-08-31 at 10 07 55 AM

@mdeshmu
Copy link
Contributor

mdeshmu commented Sep 1, 2023

2023-08-31 19:37:53+05:30

@justinpark thanks for adding the date. We are using the above format in the Query History Tab.
Do we wanna keep it the same here for the sake of consistency?
I am fine with either though :)

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix @justinpark!

I like @mdeshmu suggestion to make the time format consistent with SQL -> Query History 👍🏼

@mdeshmu
Copy link
Contributor

mdeshmu commented Sep 1, 2023

@michael-s-molina Please include this PR in 3.0. Thanks.

@justinpark
Copy link
Member Author

justinpark thanks for adding the date. We are using the above format in the Query History Tab. Do we wanna keep it the same here for the sake of consistency? I am fine with either though :)

Sounds good. I changed to same format as Query History as well as from MM/DD/YYYY to L (which is like 09/04/1986 in local format, so date value comes first in eu countries)

Screenshot 2023-09-01 at 10 04 27 AM

@michael-s-molina michael-s-molina added the v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch label Sep 1, 2023
@justinpark justinpark merged commit 8b2a408 into apache:master Sep 1, 2023
26 checks passed
michael-s-molina pushed a commit that referenced this pull request Sep 5, 2023
darwinsubramaniam pushed a commit to darwinsubramaniam/superset that referenced this pull request Sep 7, 2023
@justinpark justinpark mentioned this pull request Sep 27, 2023
9 tasks
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
@mistercrunch mistercrunch added 🍒 3.0.3 🍒 3.0.4 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.1.0 labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v3.0 Label added by the release manager to track PRs to be included in the 3.0 branch 🍒 3.0.0 🍒 3.0.1 🍒 3.0.2 🍒 3.0.3 🍒 3.0.4 🚢 3.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQL lab shows invalid date for Started column in Query History
5 participants