Apache DataFusion SQL Query Engine
Fix broken `serde` feature (#15124)
Vadim Pivenf31ddd6940cb
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.ymlindex 4a3aaab884..4618600585 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 Cleanrun: git diff --exit-codediff --git a/Cargo.lock b/Cargo.lockindex 2dc3698e36..87275112d2 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.tomlindex af029b1776..fd1fd4164d 100644--- a/datafusion/core/Cargo.toml+++ b/datafusion/core/Cargo.toml@@ -79,7 +79,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.rsindex 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` directorymod optimizer;+/// Run all tests that are found in the `physical_optimizer` directorymod physical_optimizer;+/// Run all tests that are found in the `serde` directory+mod serde;++/// Run all tests that are found in the `catalog` directorymod catalog;#[cfg(test)]diff --git a/datafusion/core/tests/serde/mod.rs b/datafusion/core/tests/serde/mod.rsnew file mode 100644index 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);+}