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 a UDF to extract the window start time from the message key #1674

Closed
apurvam opened this issue Jul 31, 2018 · 11 comments · Fixed by #1993
Closed

Add a UDF to extract the window start time from the message key #1674

apurvam opened this issue Jul 31, 2018 · 11 comments · Fixed by #1993

Comments

@apurvam
Copy link
Contributor

apurvam commented Jul 31, 2018

We should add a WINDOWSTARTTIME() UDF which returns the start time of the window if the underlying topic is windowed, or else return some sentinel value (like LONG_MAX) if it isn't.

Getting access to the window start time is generally useful, and we can't depend on ROWTIME for this piece of information. See #1497

@codestoned1
Copy link

Hey, I'm new to contributing. Can I try adding this?

@rodesai
Copy link
Contributor

rodesai commented Aug 9, 2018

@zlex7 go for it!

@apurvam
Copy link
Contributor Author

apurvam commented Aug 9, 2018

yes. thanks @zlex7 . I am assigning this to you.

@apurvam
Copy link
Contributor Author

apurvam commented Aug 9, 2018

Actually, I can't assign it to you for some reason. In any case, feel free to take a stab at it. You can follow the example from here to add a new UDF: https://github.com/confluentinc/ksql/pull/1611/files

@miguno
Copy link
Contributor

miguno commented Aug 14, 2018

Thanks for taking a stab at this, @zlex7 !

@rmoff
Copy link
Member

rmoff commented Sep 3, 2018

would be good to include WINDOWENDTIME for completeness :)

@blueedgenick
Copy link
Contributor

Thinking aloud, maybe a udf is not the best solution for this - how about we instead provide an additional pseudo-column that's automatically created on the output table, say WINDOWTIME, just like we do for the message key and timestamp already. I wonder if this would feel more natural?

@mjsax
Copy link
Member

mjsax commented Sep 3, 2018

I would recommend to return NULL if the UDF is applied to a non-windowed column. A sentinel value as LONG_MAX might not make much sense IMHO and could be miss-leading downstream.

@rmoff
Copy link
Member

rmoff commented Sep 4, 2018

@blueedgenick IMO a UDF would be a useful stop-gap solution for something that has in effect caused a regression in functionality. I think the discussion around UDF vs system column did take place, and TBH so long as we get it built sooner than later either would be fine :)

@apurvam
Copy link
Contributor Author

apurvam commented Sep 26, 2018

@big-andy-coates said he would take this on.

@big-andy-coates
Copy link
Contributor

Yep, I'm working on this... it's more involved than it might look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants