milvus/pkg/util/typeutil
cai.zhang fc4982bd62
fix: prevent node panic when unsupported types used as ClusteringKey (#48184)
## Summary

Fixes #47540

- **Bug 1 (MixCoord panic):** `compactionInspector.analyzeScheduler` was
never initialized in production code. When FloatVector is used as
ClusteringKey, the `doAnalyze()` path calls `analyzeScheduler.Enqueue()`
on a nil pointer → panic. Fixed by passing `analyzeScheduler` to
`newCompactionInspector`.
- **Bug 2 (DataNode round-robin panic):** `validateClusteringKey()` had
no field type whitelist, so JSON/Bool/Array passed schema validation.
During clustering compaction, `NewScalarFieldValue()` panics on
unsupported types. Fixed by adding `IsClusteringKeyType()` check to
reject unsupported types at collection creation time.

## Test plan

- [x] `TestIsClusteringKeyType` — verifies supported/unsupported type
classification
- [x] `TestClusteringKey` — new sub-tests for JSON, Bool, Array as
ClusteringKey (all rejected)
- [ ] Existing `TestClusteringKey` sub-tests (normal, multiple keys,
vector key) still pass
- [ ] `TestCompactionPlanHandler*` tests pass with updated
`newCompactionInspector` signature

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 21:21:25 +08:00
..
backoff_timer.go
backoff_timer_test.go
cache.go
chan.go
convension.go enhance: support async write syncer for milvus logging (#45805) 2025-11-28 17:43:11 +08:00
conversion_test.go enhance: support async write syncer for milvus logging (#45805) 2025-11-28 17:43:11 +08:00
field_data.go enhance: timestamptz support groupby (#45762) 2025-11-21 18:39:05 +08:00
field_data_test.go
field_length_limit.go enhance: remove uncessary segment size estimation and make it configurable (#46302) 2025-12-13 02:58:46 +08:00
field_schema.go fix: highlight with multi analyzer failed (#46527) 2025-12-30 11:55:21 +08:00
float_util.go
float_util_test.go
gen_empty_field_data.go feat: Geospatial Data Type and GIS Function support for milvus (#44547) 2025-09-28 19:43:05 +08:00
get_dim.go
hash.go
hash_test.go
heap.go
heap_test.go
id_allocator.go
ids_checker.go
ids_checker_test.go
index.go
index_test.go
kv_pair_helper.go
kv_pair_helper_test.go
lifetime.go
lifetime_test.go
map.go
map_test.go
multipart_queue.go
multipart_queue_test.go
ordered_map.go
ordered_map_test.go
pair.go
schema.go fix: prevent node panic when unsupported types used as ClusteringKey (#48184) 2026-03-15 21:21:25 +08:00
schema_test.go fix: prevent node panic when unsupported types used as ClusteringKey (#48184) 2026-03-15 21:21:25 +08:00
schema_typed.go
schema_typed_test.go
set.go
set_test.go
shared_reference.go
shared_reference_test.go
skip_list.go
skip_list_test.go
string_util.go
string_util_test.go
time.go
time_test.go
type.go feat: Add CDC support (#44124) 2025-09-16 16:32:01 +08:00
version.go enhance: support async write syncer for milvus logging (#45805) 2025-11-28 17:43:11 +08:00
version_test.go