datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

Add `to_date` function

Open Tangruilin opened this issue 1 year ago • 18 comments

Which issue does this PR close?

Closes #8987 .

Rationale for this change

What changes are included in this PR?

Add to_date function, and change the protobuf file

Are these changes tested?

Not now, but it should be added in this PR.

Are there any user-facing changes?

Add a function named to_date, users can use select to_date(1243124); to try it.

Tangruilin avatar Jan 27 '24 09:01 Tangruilin

@Omega359 Hey! you can look it if you have time, I need you suggestion about the protobuf file and if there are something that i do not think about.

If it looks ok, I will write test code these days.

Thanks very much

Tangruilin avatar Jan 27 '24 10:01 Tangruilin

I haven't had time to look it over yet but first thing I did see was the use of Date64 - I can't see any good reason to use that vs Date32

Omega359 avatar Jan 27 '24 15:01 Omega359

I haven't had time to look it over yet but first thing I did see was the use of Date64 - I can't see any good reason to use that vs Date32

Date64 contains more number in my opinion. Maybe Date32 is better?

Tangruilin avatar Jan 28 '24 04:01 Tangruilin

Date64 contains more number in my opinion. Maybe Date32 is better?

    /// A signed 32-bit date representing the elapsed time since UNIX epoch (1970-01-01)
    /// in days (32 bits).
    Date32,
    /// A signed 64-bit date representing the elapsed time since UNIX epoch (1970-01-01)
    /// in milliseconds (64 bits). Values are evenly divisible by 86400000.
    Date64,

Date32 is the way.

Omega359 avatar Jan 28 '24 15:01 Omega359

Date64 contains more number in my opinion. Maybe Date32 is better?

    /// A signed 32-bit date representing the elapsed time since UNIX epoch (1970-01-01)
    /// in days (32 bits).
    Date32,
    /// A signed 64-bit date representing the elapsed time since UNIX epoch (1970-01-01)
    /// in milliseconds (64 bits). Values are evenly divisible by 86400000.
    Date64,

Date32 is the way.

Okey! I will change it to Date32 I may finish it these two days

Tangruilin avatar Jan 29 '24 13:01 Tangruilin

@alamb @Omega359 This PR is ready to be reviewed

Tangruilin avatar Jan 30 '24 13:01 Tangruilin

Hi @Tangruilin , could you add a function description in scalar_functions.md?

Weijun-H avatar Feb 05 '24 07:02 Weijun-H

Hi @Tangruilin , could you add a function description in scalar_functions.md?

I will do it today night

Tangruilin avatar Feb 06 '24 08:02 Tangruilin

cc @Omega359 do you happen to have some time to give this PR a look?

alamb avatar Feb 11 '24 11:02 alamb

Marking this PR as draft as it no longer seems to be waiting on feedback. Please mark it ready for review when it is ready for another look.

alamb avatar Feb 16 '24 11:02 alamb

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

Omega359 avatar Feb 16 '24 16:02 Omega359

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

I will work with it today

Tangruilin avatar Feb 18 '24 06:02 Tangruilin

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

I will work with it today

Unfortunately, I think the 36.0.0 https://lists.apache.org/thread/jhhtz9csocdxx1fzb5ysswjnq79x2fr5 RC has already been cut (so unless we find some problem with RC1 and make a new RC, this issue will have to wait until the next release)

alamb avatar Feb 19 '24 06:02 alamb

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

I will work with it today

Unfortunately, I think the 36.0.0 https://lists.apache.org/thread/jhhtz9csocdxx1fzb5ysswjnq79x2fr5 RC has already been cut (so unless we find some problem with RC1 and make a new RC, this issue will have to wait until the next release)

I am working with it now. it is a pity

Tangruilin avatar Feb 19 '24 06:02 Tangruilin

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

I will work with it today

Unfortunately, I think the 36.0.0 https://lists.apache.org/thread/jhhtz9csocdxx1fzb5ysswjnq79x2fr5 RC has already been cut (so unless we find some problem with RC1 and make a new RC, this issue will have to wait until the next release)

congratulation to 36.0

Tangruilin avatar Feb 19 '24 06:02 Tangruilin

@Tangruilin - Do you think you'll have time to complete this PR before v36 is released?

You can review it now

Tangruilin avatar Feb 20 '24 06:02 Tangruilin

@Omega359 You can review this PR now, thanks

Tangruilin avatar Feb 21 '24 02:02 Tangruilin

@Omega359 You can review this PR now, thanks

@Omega359 once you have reviewed this PR please let me know and I'll give it a final look too and hopefully merge it

Thank you for your work @Tangruilin

alamb avatar Feb 21 '24 07:02 alamb

@Omega359 The cargo test --doc command is passed on my mac. But the CI fail. I do not know why

Tangruilin avatar Feb 27 '24 16:02 Tangruilin

@Omega359 The cargo test --doc command is passed on my mac. But the CI fail. I do not know why

I think it's because you are attempting to include /// # use datafusion::prelude::*; which isn't imported in that module. You can't import it either because of #9277. As mentioned in my review you'll have to ignore that doc test until we move the functions out of this module to the new datafusion/functions area.

Omega359 avatar Feb 27 '24 17:02 Omega359

I think this PR looks good to me -- thank you @Tangruilin and @Omega359

There are several cleanup suggestions left outstanding from @Omega359 related to fixing up repeated tests / comments. Is this something you have time to fix @Tangruilin before we merge the PR? Otherwise we can do it as a follow on PR

I think i can fix it in this PR

Tangruilin avatar Feb 28 '24 16:02 Tangruilin

I think this PR looks good to me -- thank you @Tangruilin and @Omega359 There are several cleanup suggestions left outstanding from @Omega359 related to fixing up repeated tests / comments. Is this something you have time to fix @Tangruilin before we merge the PR? Otherwise we can do it as a follow on PR

I think i can fix it in this PR

Done

Tangruilin avatar Feb 28 '24 17:02 Tangruilin