Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/spark_expressions_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@

### misc_funcs

- [ ] aes_decrypt
- [x] aes_decrypt
- [ ] aes_encrypt
- [ ] assert_true
- [x] current_catalog
Expand Down
134 changes: 134 additions & 0 deletions native/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions native/spark-expr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ twox-hash = "2.1.2"
rand = { workspace = true }
hex = "0.4.3"
base64 = "0.22.1"
aes = "0.8.4"
aes-gcm = "0.10.3"
cbc = "0.1.2"
ecb = "0.1.2"

[dev-dependencies]
arrow = {workspace = true}
Expand Down
10 changes: 7 additions & 3 deletions native/spark-expr/src/comet_scalar_funcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ use crate::math_funcs::abs::abs;
use crate::math_funcs::checked_arithmetic::{checked_add, checked_div, checked_mul, checked_sub};
use crate::math_funcs::modulo_expr::spark_modulo;
use crate::{
spark_ceil, spark_decimal_div, spark_decimal_integral_div, spark_floor, spark_isnan,
spark_lpad, spark_make_decimal, spark_read_side_padding, spark_round, spark_rpad, spark_unhex,
spark_unscaled_value, EvalMode, SparkBitwiseCount, SparkContains, SparkDateDiff,
spark_aes_decrypt, spark_ceil, spark_decimal_div, spark_decimal_integral_div, spark_floor,
spark_isnan, spark_lpad, spark_make_decimal, spark_read_side_padding, spark_round, spark_rpad,
spark_unhex, spark_unscaled_value, EvalMode, SparkBitwiseCount, SparkContains, SparkDateDiff,
SparkDateTrunc, SparkMakeDate, SparkSizeFunc, SparkStringSpace,
};
use arrow::datatypes::DataType;
Expand Down Expand Up @@ -177,6 +177,10 @@ pub fn create_comet_physical_fun_with_eval_mode(
let func = Arc::new(abs);
make_comet_scalar_udf!("abs", func, without data_type)
}
"aes_decrypt" => {
let func = Arc::new(spark_aes_decrypt);
make_comet_scalar_udf!("aes_decrypt", func, without data_type)
}
"split" => {
let func = Arc::new(crate::string_funcs::spark_split);
make_comet_scalar_udf!("split", func, without data_type)
Expand Down
36 changes: 36 additions & 0 deletions native/spark-expr/src/downcast.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.

macro_rules! opt_downcast_arg {
($ARG:expr, $ARRAY_TYPE:ident) => {{
$ARG.as_any().downcast_ref::<$ARRAY_TYPE>()
}};
}

macro_rules! downcast_named_arg {
($ARG:expr, $NAME:expr, $ARRAY_TYPE:ident) => {{
$ARG.as_any().downcast_ref::<$ARRAY_TYPE>().ok_or_else(|| {
datafusion::common::internal_datafusion_err!(
"could not cast {} to {}",
$NAME,
std::any::type_name::<$ARRAY_TYPE>()
)
})?
}};
}

pub(crate) use {downcast_named_arg, opt_downcast_arg};
4 changes: 4 additions & 0 deletions native/spark-expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
// The lint makes easier for code reader/reviewer separate references clones from more heavyweight ones
#![deny(clippy::clone_on_ref_ptr)]

mod downcast;
mod error;
pub(crate) use downcast::{downcast_named_arg, opt_downcast_arg};

pub mod kernels;
pub use kernels::temporal::date_trunc_dyn;
Expand Down Expand Up @@ -58,6 +60,7 @@ pub use bloom_filter::{BloomFilterAgg, BloomFilterMightContain};
mod conditional_funcs;
mod conversion_funcs;
mod math_funcs;
mod misc_funcs;
mod nondetermenistic_funcs;

pub use array_funcs::*;
Expand All @@ -83,6 +86,7 @@ pub use math_funcs::{
spark_decimal_integral_div, spark_floor, spark_make_decimal, spark_round, spark_unhex,
spark_unscaled_value, CheckOverflow, NegativeExpr, NormalizeNaNAndZero,
};
pub use misc_funcs::spark_aes_decrypt;
pub use string_funcs::*;

/// Spark supports three evaluation modes when evaluating expressions, which affect
Expand Down
Loading