Skip to content

Commit b4d89c4

Browse files
vadimpivenalamb
andcommitted
Fix broken serde feature (apache#15124)
* Fix broked `serde` feature * Test `serde` feature * consolidate serde test into core_integration, update run --------- Co-authored-by: Andrew Lamb <[email protected]>
1 parent d5ca830 commit b4d89c4

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

.github/workflows/rust.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ jobs:
183183
with:
184184
rust-version: stable
185185
- name: Run tests (excluding doctests)
186-
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
186+
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
187187
- name: Verify Working Directory Clean
188188
run: git diff --exit-code
189189

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion/core/Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ recursive_protection = [
7373
"datafusion-physical-optimizer/recursive_protection",
7474
"datafusion-sql/recursive_protection",
7575
]
76-
serde = ["dep:serde"]
76+
serde = [
77+
"dep:serde",
78+
# Enable `#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]`
79+
# statements in `arrow-schema` crate
80+
"arrow-schema/serde",
81+
]
7782
string_expressions = ["datafusion-functions/string_expressions"]
7883
unicode_expressions = [
7984
"datafusion-sql/unicode_expressions",

datafusion/core/tests/core_integration.rs

+5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,13 @@ mod custom_sources_cases;
4242
/// Run all tests that are found in the `optimizer` directory
4343
mod optimizer;
4444

45+
/// Run all tests that are found in the `physical_optimizer` directory
4546
mod physical_optimizer;
4647

48+
/// Run all tests that are found in the `serde` directory
49+
mod serde;
50+
51+
/// Run all tests that are found in the `catalog` directory
4752
mod catalog;
4853

4954
#[cfg(test)]

datafusion/core/tests/serde/mod.rs

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
/// Ensure `serde` feature from `arrow-schema` crate is re-exported.
19+
#[test]
20+
#[cfg(feature = "serde")]
21+
fn ensure_serde_support() {
22+
use datafusion::arrow::datatypes::DataType;
23+
24+
#[derive(Debug, PartialEq, serde::Serialize, serde::Deserialize)]
25+
struct WrappingStruct(DataType);
26+
27+
let boolean = WrappingStruct(DataType::Boolean);
28+
29+
let serialized = serde_json::to_string(&boolean).unwrap();
30+
assert_eq!("\"Boolean\"", serialized);
31+
32+
let deserialized = serde_json::from_str(&serialized).unwrap();
33+
assert_eq!(boolean, deserialized);
34+
}

0 commit comments

Comments
 (0)