Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions be/test/core/data_type_serde/data_type_serde_arrow_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,9 +957,8 @@ TEST(DataTypeSerDeArrowTest, PlainArrowConverterDoesNotInferIcebergUuid) {

TEST(DataTypeSerDeArrowTest, IcebergVariantExtensionAndParquetSchema) {
auto make_variant_column = []() {
JsonStringToVariantEncoder encoder({.max_json_key_length = 1024,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 1024, .throw_on_invalid_json = true});
for (std::string_view json :
{std::string_view {R"({"name":"doris","n":1})"}, std::string_view {"null"},
std::string_view {R"([1,true,"x"])"}}) {
Expand Down Expand Up @@ -1054,9 +1053,8 @@ TEST(DataTypeSerDeArrowTest, IcebergVariantExtensionAndParquetSchema) {

TEST(DataTypeSerDeArrowTest, NestedIcebergVariantExtensionsAndParquetSchema) {
auto make_variant_column = [](std::initializer_list<std::string_view> json_values) {
JsonStringToVariantEncoder encoder({.max_json_key_length = 1024,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 1024, .throw_on_invalid_json = true});
for (std::string_view json : json_values) {
encoder.add_json({json.data(), json.size()});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ std::string json_at(const DataTypeVariantV2SerDe& serde, const IColumn& column,
}

ColumnVariantV2::MutablePtr encoded_json(std::initializer_list<std::string_view> rows) {
JsonStringToVariantEncoder encoder({.max_json_key_length = 1024,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 1024, .throw_on_invalid_json = true});
for (std::string_view row : rows) {
encoder.add_json({row.data(), row.size()});
}
Expand Down
5 changes: 2 additions & 3 deletions be/test/exprs/variant_v2_execution_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ TEST(VariantV2ExecutionTest, TypePropertiesDoNotAffectEquality) {

TEST(VariantV2ExecutionTest, CanonicalComparison) {
auto parse = [](std::initializer_list<std::string_view> rows) {
JsonStringToVariantEncoder encoder({.max_json_key_length = 255,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 255, .throw_on_invalid_json = true});
for (auto json : rows) {
encoder.add_json({json.data(), json.size()});
}
Expand Down
10 changes: 4 additions & 6 deletions be/test/format/transformer/vparquet_writer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,8 @@ TEST_F(VParquetWriterTest, WritesIcebergVariantAndCollectsLogicalMetrics) {
options, &schema_json, *schema);
ASSERT_TRUE(transformer.open().ok());

JsonStringToVariantEncoder encoder({.max_json_key_length = 1024,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 1024, .throw_on_invalid_json = true});
for (std::string_view json : {std::string_view {R"({"name":"doris","n":1})"},
std::string_view {"null"}, std::string_view {R"([1,2,3])"}}) {
encoder.add_json({json.data(), json.size()});
Expand Down Expand Up @@ -282,9 +281,8 @@ TEST_F(VParquetWriterTest, WritesNestedIcebergVariant) {
options, &schema_json, *schema);
ASSERT_TRUE(transformer.open().ok());

JsonStringToVariantEncoder encoder({.max_json_key_length = 1024,
.throw_on_invalid_json = true,
.check_duplicate_json_path = false});
JsonStringToVariantEncoder encoder(
{.max_json_key_length = 1024, .throw_on_invalid_json = true});
for (std::string_view json :
{std::string_view {R"({"kind":"nested"})"}, std::string_view {"null"},
std::string_view {"{}"}, std::string_view {"7"}}) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !variant_after_errors --
20 false true {"recovered":true}
21 false \N not-json
21 true \N \N
22 false \N {"typed":"string"}
23 false \N 7
24 false \N values-string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ suite("test_paimon_write_variant_errors", "p0,external,paimon,nonConcurrent") {
row.collect { value -> value == null ? null : value.toString() }
})

// Invalid JSON is preserved as a Variant string unless the global
// throw-on-invalid-JSON option is enabled.
// try_parse_to_variant returns NULL for text that is not a JSON document.
order_qt_variant_after_errors """
SELECT id, payload IS NULL,
CAST(payload['recovered'] AS BOOLEAN),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ suite("test_variant_json_functions", "p0") {
DUPLICATE KEY(k) DISTRIBUTED BY HASH(k) BUCKETS 1
PROPERTIES ("replication_num" = "1")
"""
// parse_to_variant only accepts JSON documents, so the Variant string row is a JSON string.
sql """
INSERT INTO test_variant_json_functions
SELECT k, parse_to_variant(doc) FROM (
SELECT 1 AS k, '{"a":1,"s":"x","b":{"c":[1,2]}}' AS doc
UNION ALL SELECT 2, '{"a":2,"s":"yz","b":{"c":[3]},"n":{"m":true}}'
UNION ALL SELECT 3, '[1,"two",{"three":3}]'
UNION ALL SELECT 4, '42'
UNION ALL SELECT 5, 'abc'
UNION ALL SELECT 5, '"abc"'
UNION ALL SELECT 6, NULL) t
"""

Expand Down
Loading