diff --git a/datafusion/proto/build.rs b/datafusion/proto/build.rs index 9b1b4e393c70..7e59107ea4e7 100644 --- a/datafusion/proto/build.rs +++ b/datafusion/proto/build.rs @@ -55,7 +55,7 @@ fn build() -> Result<(), String> { let mut file = std::fs::OpenOptions::new() .write(true) .create(true) - .open("src/generated/datafusion.rs") + .open("src/generated/datafusion_json.rs") .unwrap(); file.write(proto.as_str().as_ref()).unwrap(); file.write(json.as_str().as_ref()).unwrap(); diff --git a/datafusion/proto/src/generated/mod.rs b/datafusion/proto/src/generated/mod.rs index 750ab315f223..f3154b265711 100644 --- a/datafusion/proto/src/generated/mod.rs +++ b/datafusion/proto/src/generated/mod.rs @@ -18,4 +18,10 @@ // include the generated protobuf source as a submodule #[allow(clippy::all)] #[rustfmt::skip] +#[cfg(not(feature = "json"))] pub mod datafusion; + +#[allow(clippy::all)] +#[rustfmt::skip] +#[cfg(feature = "json")] +pub mod datafusion_json; diff --git a/datafusion/proto/src/lib.rs b/datafusion/proto/src/lib.rs index 5f3bc47a9e66..7e009a846e69 100644 --- a/datafusion/proto/src/lib.rs +++ b/datafusion/proto/src/lib.rs @@ -24,7 +24,11 @@ pub mod from_proto; pub mod generated; pub mod logical_plan; pub mod to_proto; -use generated::datafusion as protobuf; + +#[cfg(not(feature = "json"))] +pub use generated::datafusion as protobuf; +#[cfg(feature = "json")] +pub use generated::datafusion_json as protobuf; #[cfg(doctest)] doc_comment::doctest!("../README.md", readme_example_test);