From 45cb6f9ec1574d51b237e933a8e018c1893ab62b Mon Sep 17 00:00:00 2001 From: Raz Luvaton <16746759+rluvaton@users.noreply.github.com> Date: Sun, 5 Jan 2025 11:45:18 +0200 Subject: [PATCH] extract json_funcs expressions to folders based on spark grouping --- native/spark-expr/src/json_funcs/mod.rs | 20 +++++++++++++++++++ .../src/{ => json_funcs}/to_json.rs | 4 ++-- native/spark-expr/src/lib.rs | 4 ++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 native/spark-expr/src/json_funcs/mod.rs rename native/spark-expr/src/{ => json_funcs}/to_json.rs (99%) diff --git a/native/spark-expr/src/json_funcs/mod.rs b/native/spark-expr/src/json_funcs/mod.rs new file mode 100644 index 000000000..de3037590 --- /dev/null +++ b/native/spark-expr/src/json_funcs/mod.rs @@ -0,0 +1,20 @@ +// 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. + +mod to_json; + +pub use to_json::ToJson; diff --git a/native/spark-expr/src/to_json.rs b/native/spark-expr/src/json_funcs/to_json.rs similarity index 99% rename from native/spark-expr/src/to_json.rs rename to native/spark-expr/src/json_funcs/to_json.rs index 91b46c6f0..3389ea3a0 100644 --- a/native/spark-expr/src/to_json.rs +++ b/native/spark-expr/src/json_funcs/to_json.rs @@ -19,7 +19,7 @@ // of the Spark-specific compatibility features that we need (including // being able to specify Spark-compatible cast from all types to string) -use crate::cast::SparkCastOptions; +use crate::SparkCastOptions; use crate::{spark_cast, EvalMode}; use arrow_array::builder::StringBuilder; use arrow_array::{Array, ArrayRef, RecordBatch, StringArray, StructArray}; @@ -250,7 +250,7 @@ fn struct_to_json(array: &StructArray, timezone: &str) -> Result { #[cfg(test)] mod test { - use crate::to_json::struct_to_json; + use crate::json_funcs::to_json::struct_to_json; use arrow_array::types::Int32Type; use arrow_array::{Array, PrimitiveArray, StringArray}; use arrow_array::{ArrayRef, BooleanArray, Int32Array, StructArray}; diff --git a/native/spark-expr/src/lib.rs b/native/spark-expr/src/lib.rs index f35873100..95e2fa7fb 100644 --- a/native/spark-expr/src/lib.rs +++ b/native/spark-expr/src/lib.rs @@ -55,9 +55,9 @@ pub use negative::{create_negate_expr, NegativeExpr}; mod normalize_nan; mod temporal; +mod json_funcs; pub mod test_common; pub mod timezone; -mod to_json; mod unbound; pub use unbound::UnboundColumn; pub mod utils; @@ -70,11 +70,11 @@ pub use cast::{spark_cast, Cast, SparkCastOptions}; pub use comet_scalar_funcs::create_comet_physical_fun; pub use error::{SparkError, SparkResult}; pub use if_expr::IfExpr; +pub use json_funcs::*; pub use list::{ArrayInsert, GetArrayStructFields, ListExtract}; pub use regexp::RLike; pub use structs::{CreateNamedStruct, GetStructField}; pub use temporal::{DateTruncExpr, HourExpr, MinuteExpr, SecondExpr, TimestampTruncExpr}; -pub use to_json::ToJson; /// Spark supports three evaluation modes when evaluating expressions, which affect /// the behavior when processing input values that are invalid or would result in an