-
Notifications
You must be signed in to change notification settings - Fork 763
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: try split number cast function impl (#17155)
* chore: try split number cast function impl * divnull div0 only register once
- Loading branch information
Showing
12 changed files
with
431 additions
and
542 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
434 changes: 243 additions & 191 deletions
434
src/query/functions/src/scalars/arithmetic/src/arithmetic.rs
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/query/functions/src/scalars/integer_arithmetic/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "databend-functions-scalar-integer-basic-arithmetic" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
databend-common-expression = { workspace = true } | ||
databend-functions-scalar-numeric-basic-arithmetic = { workspace = true } | ||
match-template = { workspace = true } | ||
num-traits = { workspace = true } | ||
|
||
[package.metadata.cargo-machete] | ||
ignored = ["match-template"] |
51 changes: 51 additions & 0 deletions
51
src/query/functions/src/scalars/integer_arithmetic/src/integer_arithmetic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use databend_common_expression::arithmetics_type::ResultTypeOfBinary; | ||
use databend_common_expression::types::Number; | ||
use databend_common_expression::types::NumberDataType; | ||
use databend_common_expression::types::NumberType; | ||
use databend_common_expression::types::SimpleDomain; | ||
use databend_common_expression::types::ALL_INTEGER_TYPES; | ||
use databend_common_expression::types::F64; | ||
use databend_common_expression::vectorize_with_builder_2_arg; | ||
use databend_common_expression::with_integer_mapped_type; | ||
use databend_common_expression::FunctionDomain; | ||
use databend_common_expression::FunctionRegistry; | ||
use databend_functions_scalar_numeric_basic_arithmetic::numeric_basic_arithmetic::divide_function; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_basic_arithmetic; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_divide; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_intdiv; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_minus; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_modulo; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_multiply; | ||
use databend_functions_scalar_numeric_basic_arithmetic::register_plus; | ||
use databend_functions_scalar_numeric_basic_arithmetic::vectorize_modulo; | ||
use num_traits::AsPrimitive; | ||
|
||
pub fn register_integer_basic_arithmetic(registry: &mut FunctionRegistry) { | ||
for left in ALL_INTEGER_TYPES { | ||
for right in ALL_INTEGER_TYPES { | ||
with_integer_mapped_type!(|L| match left { | ||
NumberDataType::L => with_integer_mapped_type!(|R| match right { | ||
NumberDataType::R => { | ||
register_basic_arithmetic!(L, R, registry); | ||
} | ||
_ => unreachable!(), | ||
}), | ||
_ => unreachable!(), | ||
}); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/query/functions/src/scalars/integer_arithmetic/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2021 Datafuse Labs | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#![allow(clippy::arc_with_non_send_sync)] | ||
#![allow(clippy::uninlined_format_args)] | ||
#![allow(clippy::ptr_arg)] | ||
#![allow(clippy::type_complexity)] | ||
#![allow(internal_features)] | ||
#![feature(core_intrinsics)] | ||
#![feature(box_patterns)] | ||
#![feature(type_ascription)] | ||
#![feature(try_blocks)] | ||
#![feature(downcast_unchecked)] | ||
#![feature(str_internals)] | ||
|
||
pub mod integer_arithmetic; | ||
|
||
pub use integer_arithmetic::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.