Skip to content

Commit

Permalink
fix case
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Sep 10, 2024
1 parent 57b2bca commit 480d8f0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
12 changes: 9 additions & 3 deletions be/src/vec/data_types/convert_field_to_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "common/exception.h"
#include "common/status.h"
#include "util/bitmap_value.h"
#include "util/jsonb_document.h"
#include "util/jsonb_writer.h"
#include "vec/common/field_visitors.h"
#include "vec/common/typeid_cast.h"
Expand Down Expand Up @@ -111,6 +112,14 @@ class FieldVisitorToJsonb : public StaticVisitor<void> {
writer->writeString(x);
writer->writeEndString();
}
void operator()(const JsonbField& x, JsonbWriter* writer) const {
const JsonbValue* value = JsonbDocument::createValue(x.get_value(), x.get_size());
if (value == nullptr) {
throw doris::Exception(ErrorCode::INVALID_ARGUMENT, "Failed to create JsonbValue");
}
writer->writeValue(value);
}

void operator()(const Array& x, JsonbWriter* writer) const;

void operator()(const Tuple& x, JsonbWriter* writer) const {
Expand Down Expand Up @@ -146,9 +155,6 @@ class FieldVisitorToJsonb : public StaticVisitor<void> {
void operator()(const Map& x, JsonbWriter* writer) const {
throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR, "Not implemeted");
}
void operator()(const JsonbField& x, JsonbWriter* writer) const {
throw doris::Exception(doris::ErrorCode::NOT_IMPLEMENTED_ERROR, "Not implemeted");
}
};

void FieldVisitorToJsonb::operator()(const Array& x, JsonbWriter* writer) const {
Expand Down
4 changes: 3 additions & 1 deletion be/src/vec/data_types/serde/data_type_object_serde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ Status DataTypeObjectSerDe::write_one_cell_to_json(
var.assume_mutable()->finalize();
}
result.SetObject();
for (const auto& entry : var.get_subcolumns()) {
// sort to make output stable, todo add a config
auto subcolumns = schema_util::get_sorted_subcolumns(var.get_subcolumns());
for (const auto& entry : subcolumns) {
const auto& subcolumn = entry->data.get_finalized_column();
const auto& subtype_serde = entry->data.get_least_common_type_serde();
const auto& subtype = entry->data.get_least_common_type();
Expand Down
20 changes: 10 additions & 10 deletions regression-test/data/variant_p0/nested.out
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ v.xx tinyint Yes false \N NONE
120 {"nested120":{"nested":[{"yyyxxxx":"11111"},{"ax1111":"1111"},{"axxxb":100,"xxxy111":111},{"aaa":"11","ddsss":1024},{"xx":10}]},"not nested":1024,"not nested2":{"llll":123}}

-- !sql --
201 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
202 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
203 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
204 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
205 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
206 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
207 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
208 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
209 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
210 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"c":"1111","b":1.1,"a":10}]}}
201 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
202 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
203 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
204 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
205 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
206 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
207 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
208 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
209 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
210 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}

-- !sql --
201 {"k1":1,"k2":"some","k3":[1234],"k4":1.1,"k5":[[123]],"nested1":{"nested2":[{"a":10,"b":1.1,"c":"1111"}]}}
Expand Down
1 change: 1 addition & 0 deletions regression-test/suites/variant_p0/desc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ suite("regression_test_variant_desc", "nonConcurrent"){
}

try {
sql "set use_variant_as_complex_variant = false"
// sparse columns
def table_name = "sparse_columns"
create_table table_name
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/variant_p0/nested.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ suite("regression_test_variant_nested", "p0"){
getBackendIpHttpPort(backendId_to_backendIP, backendId_to_backendHttpPort);

try {

sql "set use_variant_as_complex_variant = false"
def table_name = "var_nested"
sql "DROP TABLE IF EXISTS ${table_name}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ suite("variant_sub_path_pruning", "variant_type"){
"""

sql "sync"
sql "set use_variant_as_complex_variant = false"

// project

Expand Down

0 comments on commit 480d8f0

Please sign in to comment.