clickhouse-native 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/clickhouse_native/client.cpp +53 -2
- data/lib/clickhouse_native/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f3cc163e6a966e97acca8801841c4512293870eaf1461d04cd3050a4aa4fd73
|
|
4
|
+
data.tar.gz: 0abc84555ec48af61ac6d56e526a22e1bb17ddf87ad417cba63bcfbf844a08ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fbf92ccd73e237a8855f158477c54c6a12b1a630e2cf2a145386b2d624bbc2080747c06e2a247c0e58a159b26c7192981309e1a769c9e6cf66d4badf82a7639c
|
|
7
|
+
data.tar.gz: ce7dc8ae0256db019528ae9d50b43710230a2f70939e82367a34d2c643a04a420199a689eec79dd11f845f6ea1b103ee7a8aba724881fe6432d57aa0aa4803e2
|
|
@@ -296,6 +296,20 @@ static VALUE value_at(const ColumnRef& col, size_t idx, const std::string& decla
|
|
|
296
296
|
|
|
297
297
|
static void append_value(const ColumnRef& col, VALUE value);
|
|
298
298
|
|
|
299
|
+
// rb_hash_foreach callback: appends each key/value pair into the columns
|
|
300
|
+
// passed via the context pointer. Used by the Map encoder.
|
|
301
|
+
struct MapInsertCtx {
|
|
302
|
+
ColumnRef key_col;
|
|
303
|
+
ColumnRef val_col;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
static int append_map_pair(VALUE key, VALUE val, VALUE arg) {
|
|
307
|
+
auto* ctx = reinterpret_cast<MapInsertCtx*>(arg);
|
|
308
|
+
append_value(ctx->key_col, key);
|
|
309
|
+
append_value(ctx->val_col, val);
|
|
310
|
+
return ST_CONTINUE;
|
|
311
|
+
}
|
|
312
|
+
|
|
299
313
|
// Append a zero/default value; used for the nested column of Nullable when
|
|
300
314
|
// the flag is set to null. We never expose these bytes to the caller.
|
|
301
315
|
static void append_default(const ColumnRef& col) {
|
|
@@ -539,8 +553,8 @@ static void append_value(const ColumnRef& col, VALUE value) {
|
|
|
539
553
|
|
|
540
554
|
case Type::LowCardinality: {
|
|
541
555
|
// Only LowCardinality(String) and LowCardinality(Nullable(String))
|
|
542
|
-
// are supported for insert
|
|
543
|
-
//
|
|
556
|
+
// are supported for insert. Numeric LC dictionaries are rare and
|
|
557
|
+
// can wait.
|
|
544
558
|
auto nested_type = type->As<LowCardinalityType>()->GetNestedType();
|
|
545
559
|
bool nullable = nested_type->GetCode() == Type::Nullable;
|
|
546
560
|
auto inner_type = nullable
|
|
@@ -576,6 +590,43 @@ static void append_value(const ColumnRef& col, VALUE value) {
|
|
|
576
590
|
return;
|
|
577
591
|
}
|
|
578
592
|
|
|
593
|
+
case Type::Map: {
|
|
594
|
+
// CH's wire format for Map(K, V) is Array(Tuple(K, V)). We build
|
|
595
|
+
// a one-row Map column holding all of this row's pairs and
|
|
596
|
+
// Append it to the target — ColumnMap exposes only Append(map),
|
|
597
|
+
// its underlying ColumnArray is private. Nil is treated as an
|
|
598
|
+
// empty map.
|
|
599
|
+
if (NIL_P(value)) value = rb_hash_new();
|
|
600
|
+
Check_Type(value, T_HASH);
|
|
601
|
+
auto map_type = type->As<MapType>();
|
|
602
|
+
auto key_type = map_type->GetKeyType();
|
|
603
|
+
auto val_type = map_type->GetValueType();
|
|
604
|
+
|
|
605
|
+
auto key_col = CreateColumnByType(key_type->GetName());
|
|
606
|
+
auto val_col = CreateColumnByType(val_type->GetName());
|
|
607
|
+
if (!key_col || !val_col) {
|
|
608
|
+
throw chn::EncoderFailure(
|
|
609
|
+
"cannot create columns for Map(" + key_type->GetName() +
|
|
610
|
+
", " + val_type->GetName() + ")");
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
MapInsertCtx ctx{key_col, val_col};
|
|
614
|
+
rb_hash_foreach(value, append_map_pair, reinterpret_cast<VALUE>(&ctx));
|
|
615
|
+
|
|
616
|
+
auto src_tuple = std::make_shared<ColumnTuple>(
|
|
617
|
+
std::vector<ColumnRef>{key_col, val_col});
|
|
618
|
+
|
|
619
|
+
auto seed_tuple = std::make_shared<ColumnTuple>(std::vector<ColumnRef>{
|
|
620
|
+
CreateColumnByType(key_type->GetName()),
|
|
621
|
+
CreateColumnByType(val_type->GetName()),
|
|
622
|
+
});
|
|
623
|
+
auto seed_array = std::make_shared<ColumnArray>(seed_tuple);
|
|
624
|
+
seed_array->AppendAsColumn(src_tuple);
|
|
625
|
+
|
|
626
|
+
col->As<ColumnMap>()->Append(std::make_shared<ColumnMap>(seed_array));
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
|
|
579
630
|
default:
|
|
580
631
|
throw chn::EncoderFailure(
|
|
581
632
|
"cannot insert into column of type " + type->GetName());
|