-
Notifications
You must be signed in to change notification settings - Fork 735
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
Added OCT
, REPEAT
scalar functions.
#3092
Conversation
Thanks for the contribution! Please review the labels and make any necessary changes. |
1 similar comment
Thanks for the contribution! Please review the labels and make any necessary changes. |
Codecov Report
@@ Coverage Diff @@
## main #3092 +/- ##
======================================
- Coverage 68% 68% -1%
======================================
Files 652 658 +6
Lines 34329 34519 +190
======================================
+ Hits 23488 23549 +61
- Misses 10841 10970 +129
Continue to review full report at Codecov.
|
} | ||
|
||
fn return_type(&self, args: &[DataType]) -> Result<DataType> { | ||
if !args[0].is_integer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
args[0] can be DataType::null.
if args[0] is String, we can cast it into Int64 using cast_with_type
MySQL support explicit cast:
select oct('56');
select oct('56a');
select oct(null);
))); | ||
} | ||
|
||
if !args[1].is_integer() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's just accept args[1]
as unsigned integer
| String
| Null
.
Then we can cast column[1] to UInt64Column to reduce the matches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cast is not expensive because it's vectorized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we can cast column[1] to UInt64Column to reduce the matches.
Will this cause unnecessary memory allocation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I think it's ok. The old column memory will be dropped immediately if no reference.
In most case, the second column is a DataColumn::Constant
, so we can use let times = columns[1].to_minimal_array().cast_with_type(&DataType::UInt64)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we already wrote the match macro, it's ok to not change that :)
Let's add String|Null support!
} | ||
|
||
fn return_type(&self, args: &[DataType]) -> Result<DataType> { | ||
if !matches!(args[0], DataType::String) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataType::Null can be supported.
select repeat(s, 0) from strings_repeat_sample_3; | ||
select repeat(s, -5) from strings_repeat_sample_3; | ||
|
||
drop table strings_repeat_sample_3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newline needed.
for n in $times { | ||
let value = n.and_then(|n| { | ||
if *n >= 0 { | ||
Some($input_string.repeat(*n as usize)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding max_repeat_times
check. I don't want this to be an oom killer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumps [crc32fast](https://github.com/srijs/rust-crc32fast) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/srijs/rust-crc32fast/releases) - [Commits](srijs/rust-crc32fast@v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: crc32fast dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com>
Add helper methods `DataType::is_integer`, `DataType::is_signed_integer`, `DataType::is_unsigned_integer`, `DataValue::is_integer`, `DataValue::is_signed_integer` and `DataValue::is_unsigned_integer`.
done. 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
Wait for another reviewer approval |
I hereby agree to the terms of the CLA available at: https://databend.rs/policies/cla/
Summary
Added
OCT
,REPEAT
scalar functions.Added helper methods:
DataType::is_integer
DataType::is_signed_integer
DataType::is_unsigned_integer
DataValue::is_integer
DataValue::is_signed_integer
DataValue::is_unsigned_integer
Changelog
Related Issues
fixes #3074, fixes #3068, fixes #3055
Test Plan
Unit Tests
Stateless Tests