feat(import): add Label field support for high-cardinality per-row data

Add support for Label-kind categories to handle high-cardinality
per-row fields like descriptions, IDs, and notes. These fields are
stored alongside regular categories but default to Axis::None and
are excluded from pivot category limits.

Changes:
- analyzer.rs: Label fields now default to accepted=true
- wizard.rs: Collect and process label fields during model building,
  attaching label values as coordinates for each cell
- category.rs: Add Label variant to CategoryKind enum
- types.rs: Add add_label_category() method and update category
  counting to only include Regular-kind categories

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/Qwen3.5-35B-A3B-GGUF:Q5_K_M)
This commit is contained in:
Edward Langley
2026-04-05 14:05:33 -07:00
parent 640fb353a1
commit 34df174b9b
4 changed files with 67 additions and 7 deletions

View File

@ -94,6 +94,11 @@ impl ImportPipeline {
.iter()
.filter(|p| p.accepted && p.kind == FieldKind::Measure)
.collect();
let labels: Vec<&FieldProposal> = self
.proposals
.iter()
.filter(|p| p.accepted && p.kind == FieldKind::Label)
.collect();
if categories.is_empty() {
return Err(anyhow!("At least one category must be accepted"));
@ -139,6 +144,11 @@ impl ImportPipeline {
model.add_category(derived_name)?;
}
// Create label categories (stored but not pivoted by default)
for lab in &labels {
model.add_label_category(&lab.field)?;
}
if !measures.is_empty() {
model.add_category("Measure")?;
if let Some(cat) = model.category_mut("Measure") {
@ -187,6 +197,28 @@ impl ImportPipeline {
continue;
}
// Attach label values as coords (missing labels become "").
for lab in &labels {
let val = map
.get(&lab.field)
.and_then(|v| v.as_str())
.map(|s| s.to_string())
.or_else(|| {
map.get(&lab.field).and_then(|v| {
if v.is_null() {
None
} else {
Some(v.to_string())
}
})
})
.unwrap_or_default();
if let Some(cat) = model.category_mut(&lab.field) {
cat.add_item(&val);
}
coords.push((lab.field.clone(), val));
}
for measure in &measures {
if let Some(val) = map.get(&measure.field).and_then(|v| v.as_f64()) {
let mut cell_coords = coords.clone();