Skip to content

Conversation

@MRKKmrkk
Copy link

@MRKKmrkk MRKKmrkk commented Jan 8, 2024

What changes were proposed in this pull request?

Implement YESTERDAY UDF in Hive

Why are the changes needed?

In my daily work, I frequently need to examine data from the previous day. Currently, in Hive, the only available method to obtain the date of yesterday is by using calculations like date_sub(current_date, 1). It would be convenient if Hive could introduce a method named 'yesterday' to facilitate the quick and easy retrieval of the date corresponding to the previous day.

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

Created qtests as part of this change

@okumin
Copy link
Contributor

okumin commented Jan 10, 2024

Googling some database systems, I didn't find ones with YESTERDAY or a similar UDF. But I imagine this UDF would be helpful at this point. I'm not confident though.

@MRKKmrkk MRKKmrkk closed this Jan 10, 2024
@MRKKmrkk MRKKmrkk reopened this Jan 10, 2024
@MRKKmrkk
Copy link
Author

Googling some database systems, I didn't find ones with YESTERDAY or a similar UDF. But I imagine this UDF would be helpful at this point. I'm not confident though.

Thank you for your review! I understand your confusion, actually clickhouse has similar UDF: https://clickhouse.com/docs/en/sql-reference/functions/date-time-functions#yesterday, and this function is widely used by both me and my colleagues in our daily work.

@sonarqubecloud
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

7 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@MRKKmrkk
Copy link
Author

@okumin Could you please check if this fix is ok? Thanks.

@okumin
Copy link
Contributor

okumin commented Jan 15, 2024

@MRKKmrkk Thanks for sharing the use case. I'm putting some thoughts here.

  1. CI is failing. Could you please check this and this? I guess you need to generate the result using TestMiniLlapLocalCliDriver
  2. I put some minor comments
  3. I can personally give +1 if we resolve the above two points. But note that I am not a committer and you would need to find another person to take another look

@NDV(maxNdv = 1)
public class GenericUDFYesterday extends GenericUDF {

protected DateWritableV2 yesterday;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be private.

Comment on lines +45 to +51
public DateWritableV2 getYesterday() {
return yesterday;
}

public void setYesterday(DateWritableV2 yesterday) {
this.yesterday = yesterday;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should remove getYesterday and setYesterday as we never use it.

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.

@github-actions github-actions bot added the stale label Mar 26, 2024
@github-actions github-actions bot closed this Apr 2, 2024
@deniskuzZ deniskuzZ removed the stale label Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants