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

feat: introduce PROCTIME() #9088

Merged
merged 7 commits into from
Apr 12, 2023
Merged

feat: introduce PROCTIME() #9088

merged 7 commits into from
Apr 12, 2023

Conversation

yuhao-su
Copy link
Contributor

@yuhao-su yuhao-su commented Apr 10, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

  • Introduce processing time. Users can specify a processing time on SOURCE/TABLE now.
  • add a task local context for expression.

Checklist For Contributors

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
    - [ ] I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Checklist For Reviewers

  • I have requested macro/micro-benchmarks as this PR can affect performance substantially, and the results are shown.

Documentation

Click here for Documentation

Types of user-facing changes

  • SQL commands, functions, and operators

We can define a processing time on TABLE/SOURCE, which reflects the time a record is inserted in RisingWave.

CREATE TABLE t1 (proc_time Timestamptz as PROCTIME()) ;

Release note

@yuhao-su yuhao-su added the user-facing-changes Contains changes that are visible to users label Apr 10, 2023
@github-actions github-actions bot added type/feature and removed user-facing-changes Contains changes that are visible to users labels Apr 10, 2023
@yuhao-su yuhao-su requested a review from chenzl25 April 10, 2023 12:46
@codecov
Copy link

codecov bot commented Apr 10, 2023

Codecov Report

Merging #9088 (473ad8a) into main (351b1bc) will increase coverage by 0.00%.
The diff coverage is 80.43%.

@@           Coverage Diff            @@
##             main    #9088    +/-   ##
========================================
  Coverage   70.87%   70.88%            
========================================
  Files        1197     1198     +1     
  Lines      199011   199125   +114     
========================================
+ Hits       141057   141148    +91     
- Misses      57954    57977    +23     
Flag Coverage Δ
rust 70.88% <80.43%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/expr/src/error.rs 21.05% <ø> (ø)
src/expr/src/expr/build.rs 80.53% <0.00%> (-0.55%) ⬇️
src/frontend/src/expr/function_call.rs 88.73% <ø> (ø)
src/frontend/src/expr/type_inference/func.rs 83.23% <0.00%> (-0.20%) ⬇️
src/frontend/src/handler/create_table_as.rs 0.00% <0.00%> (ø)
src/expr/src/expr/expr_proctime.rs 62.50% <62.50%> (ø)
src/frontend/src/binder/expr/function.rs 89.40% <91.30%> (+0.01%) ⬆️
src/frontend/src/binder/mod.rs 92.17% <92.30%> (+0.87%) ⬆️
src/stream/src/executor/project.rs 87.72% <95.00%> (+0.89%) ⬆️
src/expr/src/expr/mod.rs 65.51% <100.00%> (+4.73%) ⬆️
... and 8 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yuhao-su yuhao-su added the user-facing-changes Contains changes that are visible to users label Apr 11, 2023
@github-actions github-actions bot removed the user-facing-changes Contains changes that are visible to users label Apr 11, 2023
Copy link
Member

@BugenZhao BugenZhao left a comment

Choose a reason for hiding this comment

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

Would you please add some tests? Rest LGTM.

src/expr/src/expr/expr_proc_time.rs Outdated Show resolved Hide resolved
@yuhao-su yuhao-su requested a review from BugenZhao April 11, 2023 08:14
@yuhao-su yuhao-su changed the title feat: introduce proc_time() feat: introduce PROCTIME() Apr 11, 2023
Copy link
Contributor

@chenzl25 chenzl25 left a comment

Choose a reason for hiding this comment

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

LGTM. Can not wait to use PROCTIME() to represent the process time temporal join syntax instead of NOW(). 😄

@yuhao-su yuhao-su mentioned this pull request Apr 12, 2023
8 tasks
@yuhao-su yuhao-su added this pull request to the merge queue Apr 12, 2023
@BugenZhao BugenZhao removed this pull request from the merge queue due to a manual request Apr 12, 2023
@BugenZhao BugenZhao added this pull request to the merge queue Apr 12, 2023
Merged via the queue into main with commit fd5334d Apr 12, 2023
@BugenZhao BugenZhao deleted the yuhao/proc_time branch April 12, 2023 06:05
Comment on lines +50 to +58
fn return_type(&self) -> DataType {
DataType::Timestamptz
}

async fn eval_v2(&self, input: &DataChunk) -> Result<ValueImpl> {
let proctime = CONTEXT
.try_with(|context| context.get_physical_time())
.map_err(|_| ExprError::Context)?;
let datum = Some(ScalarImpl::Int64(proctime as i64));
Copy link
Contributor

@xiangjinwu xiangjinwu Apr 12, 2023

Choose a reason for hiding this comment

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

Timestamptz is in microseconds but seems Epoch::physical_time is in milliseconds? And it seems to be since risingwave epoch rather than unix epoch

Copy link
Member

Choose a reason for hiding this comment

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

Good point. The interfaces of Epoch are ambiguous without including the time unit in the names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix in #9126

@github-actions github-actions bot added the user-facing-changes Contains changes that are visible to users label Apr 14, 2023
@CharlieSYH CharlieSYH added the 📖✓ Covered or will be covered in the user docs. label Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users 📖✓ Covered or will be covered in the user docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants