MCPcopy Create free account
hub / github.com/douglance/devsql / json_to_data_row_with_meta

Function json_to_data_row_with_meta

crates/ccql/src/sql/composite_storage.rs:325–352  ·  view source on GitHub ↗

Convert a JSON object to a DataRow with metadata columns

(json: &JsonValue, file: &TranscriptFile)

Source from the content-addressed store, hash-verified

323
324/// Convert a JSON object to a DataRow with metadata columns
325fn json_to_data_row_with_meta(json: &JsonValue, file: &TranscriptFile) -> DataRow {
326 let mut map = BTreeMap::new();
327
328 map.insert(
329 "_source_file".to_string(),
330 Value::Str(file.source_file.clone()),
331 );
332 map.insert(
333 "_session_id".to_string(),
334 Value::Str(file.session_id.clone()),
335 );
336 if let Some(project) = &file.project {
337 map.insert("_project".to_string(), Value::Str(project.clone()));
338 }
339 if let Some(agent_id) = &file.agent_id {
340 map.insert("_agent_id".to_string(), Value::Str(agent_id.clone()));
341 }
342
343 if let JsonValue::Object(obj) = json {
344 for (key, value) in obj {
345 map.insert(key.clone(), json_value_to_glue_value(value));
346 }
347 }
348
349 flatten_usage_columns(json, &mut map);
350
351 DataRow::Map(map)
352}
353
354/// Inject flattened `model` / `usage_*` columns for assistant rows.
355///

Callers 1

scan_transcriptsMethod · 0.85

Calls 2

json_value_to_glue_valueFunction · 0.85
flatten_usage_columnsFunction · 0.85

Tested by

no test coverage detected