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

✨ add type and sort columns to variables table #3362

Merged
merged 4 commits into from
Apr 2, 2024

Conversation

Marigold
Copy link
Contributor

@Marigold Marigold commented Mar 18, 2024

Grapher part of adding indicator type to MySQL and adding ordinal type. Here's ETL pull request.

Fixes #1690

@Marigold
Copy link
Contributor Author

@danyx23 we've agreed on using dimensions.values.values for ordinal variable categories, but @sophiamersmann had a good question about what this should look like in the database. This PR currently uses fields type and sort (specifically for storing an array of categories). We have a couple of options:

  1. Don't store sort field in MySQL at all and keep it only in JSON
  2. Keep it as it is
  3. Change type field to JSON and store it as {"type": "ordinal", "sort": ["a", "b", "c"]} - this is future-proof and flexible

What do you think?

@Marigold
Copy link
Contributor Author

There's another #2039 we had open back then. We should either merge them or simply kill the old one.

@sophiamersmann
Copy link
Member

I copy-pasted the code that I needed from #2039 into this PR, so I'm happy for it to be killed

@danyx23
Copy link
Contributor

danyx23 commented Mar 20, 2024

I think the current approach is good @Marigold. We'll probably query the type field much more often than the sort field in the DB, so having the type field as a column makes sense to me.

@Marigold Marigold marked this pull request as ready for review March 21, 2024 08:51
@Marigold
Copy link
Contributor Author

Thanks! @sophiamersmann I removed sort field from JSON and kept only dimensions.values.values there. Leaving this PR in your hands now. Once you merge it, I can merge the ETL part.

Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Nice!
I didn't realize that this would be so easy, and that we can just write a drop-in replacement of sortedUniqNonEmptyStringVals.

Also, 👑 to Mojmir for setting up the staging server with the staging indicator, that was super helpful to see this in action.

@sophiamersmann
Copy link
Member

Thanks for the review!

I pushed one more commit that updates Grapher's db types and asked Daniel to sign off on it. This is good to merge now, but I'll wait for the holidays to be over :)

@sophiamersmann sophiamersmann merged commit b93215d into master Apr 2, 2024
5 checks passed
@sophiamersmann sophiamersmann deleted the ordinal-types branch April 2, 2024 15:44
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

Successfully merging this pull request may close these issues.

Support custom ordering in scatterplot legend
4 participants