Skip to content

Commit 04f2fb8

Browse files
escape rename check for static schema streams
1 parent 001215b commit 04f2fb8

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

src/event/format/json.rs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,37 @@ impl EventFormat for Event {
9494
})?
9595
};
9696

97-
// Detect schema conflicts using raw inferred schema vs existing stream schema
98-
// Pass the actual values and schema_version to check if values can be coerced to existing types
99-
let conflicts = detect_schema_conflicts(
100-
&raw_inferred_schema,
101-
stream_schema,
102-
&value_arr,
103-
schema_version,
104-
);
105-
106-
// If there are conflicts, rename the fields in JSON values
107-
let value_arr = if !conflicts.is_empty() {
108-
rename_conflicting_fields_in_json(value_arr, &conflicts)
109-
} else {
97+
let value_arr = if static_schema_flag {
11098
value_arr
111-
};
99+
} else {
100+
// Detect schema conflicts using raw inferred schema vs existing stream schema
101+
// Pass the actual values and schema_version to check if values can be coerced to existing types
102+
let conflicts = detect_schema_conflicts(
103+
&raw_inferred_schema,
104+
stream_schema,
105+
&value_arr,
106+
schema_version,
107+
);
112108

113-
// Per-record fallback: catches batches with mixed JSON types for the
114-
// same field, which the batch-level detect_schema_conflicts misses
115-
// because arrow's inference picks one winning type (string over bool).
116-
// Internally short-circuits when this can't apply (single-record
117-
// batches, or no field-name collision at the same type).
118-
let value_arr = super::rename_per_record_type_mismatches(
119-
value_arr,
120-
&raw_inferred_schema,
121-
stream_schema,
122-
schema_version,
123-
);
109+
// If there are conflicts, rename the fields in JSON values
110+
let value_arr = if !conflicts.is_empty() {
111+
rename_conflicting_fields_in_json(value_arr, &conflicts)
112+
} else {
113+
value_arr
114+
};
115+
116+
// Per-record fallback: catches batches with mixed JSON types for the
117+
// same field, which the batch-level detect_schema_conflicts misses
118+
// because arrow's inference picks one winning type (string over bool).
119+
// Internally short-circuits when this can't apply (single-record
120+
// batches, or no field-name collision at the same type).
121+
super::rename_per_record_type_mismatches(
122+
value_arr,
123+
&raw_inferred_schema,
124+
stream_schema,
125+
schema_version,
126+
)
127+
};
124128

125129
// collect all the keys from all the json objects in the request body
126130
let fields =

0 commit comments

Comments
 (0)