Skip to content

Commit 5c5ae9d

Browse files
committed
expose JsonUnion DataType and JsonPath
1 parent d8a0bf1 commit 5c5ae9d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ impl From<i64> for JsonPath<'_> {
9797
}
9898

9999
#[derive(Debug)]
100-
enum JsonPathArgs<'a> {
100+
pub enum JsonPathArgs<'a> {
101101
Array(&'a ArrayRef),
102102
Scalars(Vec<JsonPath<'a>>),
103103
}
104104

105105
impl<'s> JsonPathArgs<'s> {
106-
fn extract_path(path_args: &'s [ColumnarValue]) -> DataFusionResult<Self> {
106+
pub fn extract_path(path_args: &'s [ColumnarValue]) -> DataFusionResult<Self> {
107107
// If there is a single argument as an array, we know how to handle it
108108
if let Some((ColumnarValue::Array(array), &[])) = path_args.split_first() {
109109
return Ok(Self::Array(array));

src/common_union.rs

+7
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ impl JsonUnion {
101101
}
102102
}
103103

104+
/// Get the `DataType` for a `JsonUnion`.
105+
/// This will be the data type of the result of `json_array->'field'`.
106+
#[must_use]
107+
pub fn json_union_data_type() -> DataType {
108+
JsonUnion::data_type()
109+
}
110+
104111
/// So we can do `collect::<JsonUnion>()`
105112
impl FromIterator<Option<JsonUnionField>> for JsonUnion {
106113
fn from_iter<I: IntoIterator<Item = Option<JsonUnionField>>>(iter: I) -> Self {

src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ mod json_length;
2020
mod json_object_keys;
2121
mod rewrite;
2222

23-
pub use common_union::{JsonUnionEncoder, JsonUnionValue};
23+
pub use common_union::{json_union_data_type, JsonUnionEncoder, JsonUnionValue};
24+
25+
pub use common::JsonPath;
2426

2527
pub mod functions {
2628
pub use crate::json_as_text::json_as_text;

0 commit comments

Comments
 (0)