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

Use iso year instead of normal year for alert__year #204

Merged
merged 1 commit into from
Dec 16, 2023

Conversation

jterry64
Copy link
Member

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Check the commit's or even all commits' message styles matches our requested structure.
  • Check your code additions will fail neither code linting checks nor unit test.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

For extracting alert__week from alert__date in the VIIRS analysis, we use a function that returns the iso week. The iso week can sometimes extend across years to keep week definitions consistent (e.g. December 2020 has a week 53 that extends into January 2021).

For the corresponding alert__year value, we're using a normal year function, not the iso year function. So in the case above, January 1st 2021 will return 2021 instead of 2020. So the date will be return as week 53 of 2021, when it should be week 53 of 2020.

Issue Number: GTC-2644

What is the new behavior?

Use a new extraction function that gets the iso year from the date.

Does this introduce a breaking change?

  • Yes
  • No

@@ -128,7 +128,7 @@ object FireAlertsDF {
val confCols = if (!aggCol.equals("burned_area__ha")) List($"confidence__cat") else List()

val fireCols = List(
year($"alert__date") as "alert__year",
expr("EXTRACT(YEAROFWEEK FROM alert__date)") as "alert__year",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks good.

Totally ignorable suggestion: is it worth making line 132 be more obviously fitting the semantics of line 131, by changing it to :

  expr("EXTRACT(WEEK FROM alert__date)") as "alert_week",

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 question, I will confirm later if that does the same thing, but might merge this to get it into the data update branch

@jterry64 jterry64 merged commit ff7fc3e into master Dec 16, 2023
5 checks passed
@jterry64 jterry64 deleted the bugfix/use_iso_year branch December 16, 2023 00:08
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.

2 participants