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

Other functions migrate to Function2 trait #4036

Merged
merged 5 commits into from Feb 2, 2022

Conversation

junli1026
Copy link
Contributor

@junli1026 junli1026 commented Jan 31, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Migrate other functions to Function2

Changelog

  • Improvement

Related Issues

Fixes #3974

Test Plan

Unit Tests

Stateless Tests

@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

1 similar comment
@databend-bot
Copy link
Member

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@vercel
Copy link

vercel bot commented Jan 31, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/databend/databend/253HGRXVucQphNZMBWXGfKWq6tYh
✅ Preview: Canceled

[Deployment for 21965c4 canceled]

@junli1026 junli1026 changed the base branch from main to datavalues-dev January 31, 2022 05:31
@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2022

Codecov Report

Merging #4036 (21965c4) into datavalues-dev (622025e) will increase coverage by 0%.
The diff coverage is 72%.

Impacted file tree graph

@@               Coverage Diff               @@
##           datavalues-dev   #4036    +/-   ##
===============================================
  Coverage              56%     56%            
===============================================
  Files                 841     841            
  Lines               45049   45155   +106     
===============================================
+ Hits                25605   25677    +72     
- Misses              19444   19478    +34     
Impacted Files Coverage Δ
common/functions/src/scalars/function_factory.rs 95% <ø> (-1%) ⬇️
common/functions/src/scalars/others/ignore.rs 18% <15%> (-3%) ⬇️
.../src/scalars/others/running_difference_function.rs 56% <60%> (-14%) ⬇️
common/datavalues2/src/columns/nullable/mod.rs 60% <66%> (-1%) ⬇️
common/functions/src/scalars/others/inet_aton.rs 68% <72%> (+<1%) ⬆️
common/functions/src/scalars/function2_adapter.rs 80% <88%> (+<1%) ⬆️
common/functions/src/scalars/others/inet_ntoa.rs 84% <94%> (+16%) ⬆️
common/functions/src/scalars/function2_factory.rs 96% <100%> (+<1%) ⬆️
common/functions/src/scalars/others/other.rs 92% <100%> (+3%) ⬆️
common/datavalues/src/arrays/string/builder.rs 75% <0%> (-13%) ⬇️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 622025e...21965c4. Read the comment docs.

SELECT '=== INET_ATON ===';
SELECT INET_ATON('10.0.5.9');
SELECT INET_ATON(NULL);
SELECT INET_ATON('hello');
Copy link
Member

Choose a reason for hiding this comment

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

Should we throw the exceptions if parsing failed?
We can have TRY_INET_ATON later to enable the catch of the error to be null.

@@ -120,7 +133,12 @@ impl Function2 for Function2Adapter {
}
};

let col = NullableColumn::new(col, validity);
let col = if col.is_nullable() {
let nullable_column: &NullableColumn = col.as_any().downcast_ref().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Series::static_cast

Ok(DataColumn::Constant(DataValue::UInt8(Some(0)), input_rows))
fn eval(&self, _columns: &ColumnsWithField, input_rows: usize) -> Result<ColumnRef> {
let return_type = type_primitive::UInt8Type::arc();
let return_value = DataValue::try_from(0_u8)?;
Copy link
Member

Choose a reason for hiding this comment

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

I just thought that we can return Boolean Column instead of U8 Column.

// For invalid input, the function returns null, so the nullable is true.
Ok(DataTypeAndNullable::create(&data_type, true))

if SUPPRESS_PARSE_ERROR {
Copy link
Member

Choose a reason for hiding this comment

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

Great!

return Ok(builder.build(input_rows));
}

if columns[0].column().data_type_id() == TypeID::Null {
Copy link
Member

Choose a reason for hiding this comment

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

It looks we already did it in the adaptor.

Copy link
Contributor Author

@junli1026 junli1026 Feb 2, 2022

Choose a reason for hiding this comment

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

I have passthrough_null is false for this case ...... 😢

@sundy-li sundy-li merged commit 86b6037 into datafuselabs:datavalues-dev Feb 2, 2022
@sundy-li
Copy link
Member

sundy-li commented Feb 2, 2022

LGTM

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

Successfully merging this pull request may close these issues.

None yet

4 participants