rich7420 commented on code in PR #4971:
URL: https://github.com/apache/datafusion-comet/pull/4971#discussion_r3969980424
##########
native/spark-expr/src/string_funcs/get_json_object.rs:
##########
@@ -320,50 +339,52 @@ struct SegmentVisitor<'a> {
}
impl<'de> Visitor<'de> for SegmentVisitor<'_> {
- type Value = Option<Value>;
+ type Value = PathResult;
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("a JSON value")
}
fn visit_bool<E>(self, _: bool) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_i64<E>(self, _: i64) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_u64<E>(self, _: u64) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_f64<E>(self, _: f64) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_str<E>(self, _: &str) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_unit<E>(self) -> Result<Self::Value, E> {
- Ok(None)
+ Ok(PathResult::default())
}
fn visit_map<A: MapAccess<'de>>(self, mut map: A) -> Result<Self::Value,
A::Error> {
let PathSegment::Field(name) = &self.segments[0] else {
IgnoredAny.visit_map(map)?;
- return Ok(None);
+ return Ok(PathResult::default());
};
- let mut found = None;
- // Every entry is visited so that a duplicated key resolves to its last
- // occurrence, as it would in a parsed object.
+ let mut found = PathResult::default();
while let Some(matched) = map.next_key_seed(KeySeed(name))? {
- if matched {
- found = map.next_value_seed(PathSeed {
+ if matched && !found.matched {
Review Comment:
This returns `1` for `{"a":[[{"b":1}]],"a":null}` with `$.a[*][*].b`, while
Spark 4.1.3 and the pre-change native UDF return SQL NULL. Could you preserve
Spark’s match decision here and add a regression test?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]