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(expr): add missing basic exprs for timestamptz and bytea #10462

Merged
merged 4 commits into from
Jul 3, 2023

Conversation

xiangjinwu
Copy link
Contributor

@xiangjinwu xiangjinwu commented Jun 21, 2023

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

What's changed and what's your intention?

Added:

Not added:

Checklist

  • 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).
  • My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)

Documentation

  • My PR contains user-facing changes.

Types of user-facing changes

  • SQL commands, functions, and operators

Release note

Support some basic exprs for timestamptz and bytea:

  • timestamptz - timestamptz = interval
  • bytea CMP bytea = bool where CMP is =, <> (!=), <, <=, >, >=, is [not] distinct from
  • cast(bytea) = varchar
  • octet_length(bytea) = int32 (same as length(bytea))
  • bit_length(bytea) = int32

@github-actions github-actions bot added type/feature user-facing-changes Contains changes that are visible to users labels Jun 21, 2023
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #10462 (d1ad0f6) into main (43458ef) will decrease coverage by 0.01%.
The diff coverage is 44.18%.

@@            Coverage Diff             @@
##             main   #10462      +/-   ##
==========================================
- Coverage   70.51%   70.50%   -0.01%     
==========================================
  Files        1260     1260              
  Lines      215075   215113      +38     
==========================================
+ Hits       151651   151670      +19     
- Misses      63424    63443      +19     
Flag Coverage Δ
rust 70.50% <44.18%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
src/common/src/types/interval.rs 81.50% <0.00%> (-0.97%) ⬇️
src/expr/src/vector_op/timestamptz.rs 87.50% <14.28%> (-2.46%) ⬇️
src/expr/src/vector_op/length.rs 86.36% <64.28%> (-13.64%) ⬇️
src/expr/src/vector_op/cast.rs 91.49% <100.00%> (+0.01%) ⬆️
src/expr/src/vector_op/cmp.rs 80.10% <100.00%> (+0.44%) ⬆️

... and 5 files with indirect coverage changes

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

@xiangjinwu xiangjinwu added this pull request to the merge queue Jul 3, 2023
Merged via the queue into main with commit f310e46 Jul 3, 2023
35 of 36 checks passed
@xiangjinwu xiangjinwu deleted the feat-expr-missing-basics branch July 3, 2023 07:29
Comment on lines 23 to +32
#[function("octet_length(varchar) -> int32")]
pub fn octet_length(s: &str) -> i32 {
pub fn octet_length_str(s: &str) -> i32 {
s.as_bytes().len() as i32
}

#[function("length(bytea) -> int32")]
#[function("octet_length(bytea) -> int32")]
pub fn octet_length_bytea(s: &[u8]) -> i32 {
s.len() as i32
}
Copy link
Contributor

Choose a reason for hiding this comment

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

tip: You can use generic function to unify them.

#[function("length(bytea) -> int32")]
#[function("octet_length(bytea) -> int32")]
#[function("octet_length(varchar) -> int32")]
pub fn octet_length(s: impl AsRef<[u8]>) -> i32 {
    s.as_ref().len() as i32
}

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.

bug: timestamptz - timestamptz = interval unimplemented
4 participants