This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch branch-46
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/branch-46 by this push:
     new 0877c9930c Fix broken `serde` feature (#15124) (#15227)
0877c9930c is described below

commit 0877c9930cb52e7e83307c347852d3f77779bbfe
Author: Andrew Lamb <[email protected]>
AuthorDate: Fri Mar 14 14:58:50 2025 -0400

    Fix broken `serde` feature (#15124) (#15227)
    
    * Fix broked `serde` feature
    
    * Test `serde` feature
    
    * consolidate serde test into core_integration, update run
    
    ---------
    
    Co-authored-by: Vadim Piven <[email protected]>
---
 .github/workflows/rust.yml                |  2 +-
 Cargo.lock                                |  1 +
 datafusion/core/Cargo.toml                |  7 ++++++-
 datafusion/core/tests/core_integration.rs |  5 +++++
 datafusion/core/tests/serde/mod.rs        | 34 +++++++++++++++++++++++++++++++
 5 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 99aaa7d6f2..f9a8a456fb 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -183,7 +183,7 @@ jobs:
         with:
           rust-version: stable
       - name: Run tests (excluding doctests)
-        run: cargo test --profile ci --exclude datafusion-examples --exclude 
ffi_example_table_provider --exclude datafusion-benchmarks --workspace --lib 
--tests --bins --features avro,json,backtrace,integration-tests
+        run: cargo test --profile ci --exclude datafusion-examples --exclude 
ffi_example_table_provider --exclude datafusion-benchmarks --workspace --lib 
--tests --bins --features serde,avro,json,backtrace,integration-tests
       - name: Verify Working Directory Clean
         run: git diff --exit-code
 
diff --git a/Cargo.lock b/Cargo.lock
index 7c81dd99c8..d1f63ef001 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -453,6 +453,7 @@ source = 
"registry+https://github.com/rust-lang/crates.io-index";
 checksum = "85934a9d0261e0fa5d4e2a5295107d743b543a6e0484a835d4b8db2da15306f9"
 dependencies = [
  "bitflags 2.8.0",
+ "serde",
 ]
 
 [[package]]
diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml
index 438e2600a6..27e2617393 100644
--- a/datafusion/core/Cargo.toml
+++ b/datafusion/core/Cargo.toml
@@ -73,7 +73,12 @@ recursive_protection = [
     "datafusion-physical-optimizer/recursive_protection",
     "datafusion-sql/recursive_protection",
 ]
-serde = ["dep:serde"]
+serde = [
+    "dep:serde",
+    # Enable `#[cfg_attr(feature = "serde", derive(serde::Serialize, 
serde::Deserialize))]`
+    # statements in `arrow-schema` crate
+    "arrow-schema/serde",
+]
 string_expressions = ["datafusion-functions/string_expressions"]
 unicode_expressions = [
     "datafusion-sql/unicode_expressions",
diff --git a/datafusion/core/tests/core_integration.rs 
b/datafusion/core/tests/core_integration.rs
index 66b4103160..9bcb9e41f8 100644
--- a/datafusion/core/tests/core_integration.rs
+++ b/datafusion/core/tests/core_integration.rs
@@ -42,8 +42,13 @@ mod custom_sources_cases;
 /// Run all tests that are found in the `optimizer` directory
 mod optimizer;
 
+/// Run all tests that are found in the `physical_optimizer` directory
 mod physical_optimizer;
 
+/// Run all tests that are found in the `serde` directory
+mod serde;
+
+/// Run all tests that are found in the `catalog` directory
 mod catalog;
 
 #[cfg(test)]
diff --git a/datafusion/core/tests/serde/mod.rs 
b/datafusion/core/tests/serde/mod.rs
new file mode 100644
index 0000000000..05dde7a541
--- /dev/null
+++ b/datafusion/core/tests/serde/mod.rs
@@ -0,0 +1,34 @@
+// 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.
+
+/// Ensure `serde` feature from `arrow-schema` crate is re-exported.
+#[test]
+#[cfg(feature = "serde")]
+fn ensure_serde_support() {
+    use datafusion::arrow::datatypes::DataType;
+
+    #[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
+    struct WrappingStruct(DataType);
+
+    let boolean = WrappingStruct(DataType::Boolean);
+
+    let serialized = serde_json::to_string(&boolean).unwrap();
+    assert_eq!("\"Boolean\"", serialized);
+
+    let deserialized = serde_json::from_str(&serialized).unwrap();
+    assert_eq!(boolean, deserialized);
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to