private object Clone(object value)
        {
            if (value == null || value == NullBucket)
            {
                return(NullBucket);
            }

            return(value switch
            {
                LazyStringValue lsv => lsv.ToString(),
                string s => s,
                DateTime time => time.ToString("O"),
                DateTimeOffset offset => offset.ToString("O"),
                TimeSpan span => span.ToString("c"),
                ValueType _ => value,
                LazyCompressedStringValue lcsv => lcsv.ToString(),
                LazyNumberValue lnv => lnv.ToDouble(CultureInfo.InvariantCulture),
                BlittableJsonReaderObject json => json.CloneOnTheSameContext(),
                BlittableJsonReaderArray arr => arr.Clone(_context),
                Document doc => doc,
                _ => throw new NotSupportedException($"Unable to group by type: {value.GetType()}")
            });