Skip to content

Commit

Permalink
fix: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwilcoxson-rel committed Aug 14, 2024
1 parent 409a119 commit 84c1ff3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/core/src/kernel/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ fn get_stats_field<'a>(schema: &'a StructType, stats_field_name: &str) -> Option
let dialect = sqlparser::dialect::GenericDialect {};
match sqlparser::parser::Parser::new(&dialect).try_with_sql(stats_field_name) {
Ok(mut parser) => match parser.parse_multipart_identifier() {
Ok(parts) => find_nested_field(schema, &parts, 0),
Ok(parts) => find_nested_field(schema, &parts),
Err(_) => schema.field(stats_field_name),
},
Err(_) => schema.field(stats_field_name),
Expand All @@ -779,17 +779,19 @@ fn get_stats_field<'a>(schema: &'a StructType, stats_field_name: &str) -> Option
fn find_nested_field<'a>(
schema: &'a StructType,
parts: &[sqlparser::ast::Ident],
part_idx: usize,
) -> Option<&'a StructField> {
let part_name = &parts[part_idx].value;
if parts.is_empty() {
return None;
}
let part_name = &parts[0].value;
match schema.field(part_name) {
Some(field) => {
if part_idx == parts.len() - 1 {
if parts.len() == 1 {
Some(field)
} else {
match field.data_type() {
DataType::Struct(struct_schema) => {
find_nested_field(struct_schema, parts, part_idx + 1)
find_nested_field(struct_schema, &parts[1..])
}
// Any part before the end must be a struct
_ => None,
Expand Down

0 comments on commit 84c1ff3

Please sign in to comment.