Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f278b9d
[CHANGE][ISSUE#7426] Add support to convert variant to JSON
carpecodeum Jun 10, 2025
4f005f3
[FIX] fix doc tests and refactor code in variant_to_json
carpecodeum Jun 12, 2025
5c249f8
[FIX] fix issues with clippy errors and rename files
carpecodeum Jun 15, 2025
97e9309
[FIX/ADD] fix and changes to accomodate new variant types
carpecodeum Jun 15, 2025
c4e4868
[TEST] add tests for new variant types to json functionality
carpecodeum Jun 15, 2025
f930f3b
[FIX] fix merge conflict issues
carpecodeum Jun 19, 2025
345d9c5
[TEST] Add tests for objects and lists to json
carpecodeum Jun 19, 2025
47d809b
[FIX] fix cargo fmt tests
carpecodeum Jun 19, 2025
b8f708a
[FIX] fix clippy warnings
carpecodeum Jun 19, 2025
1ac766d
[RENAME] rename file to to_json
carpecodeum Jun 21, 2025
5f7cca7
[FIX] use impl in convert_variant_to_json function
carpecodeum Jun 21, 2025
e2502a6
[FIX] try removing f64 to convert decimal to string
carpecodeum Jun 21, 2025
d947dce
[FIX] make date time formatting more modular
carpecodeum Jun 21, 2025
c96c2d4
[FIX] fix merge conflicts
carpecodeum Jun 21, 2025
743d0e9
[FIX] make intergration_tests.rs more modular
carpecodeum Jun 24, 2025
b455997
[FIX] modify to_json to hide lines when rendering as documentation & …
carpecodeum Jun 24, 2025
1853fe5
[FIX] modify the examples to a single function
carpecodeum Jun 24, 2025
b78b110
[FIX] add an example for the new variant builder
carpecodeum Jun 24, 2025
e7a103d
[FIX] remove integration_tests and consolidate tests
carpecodeum Jun 24, 2025
a7e19d8
[FIX] remove dependency on f64 variant_to_json_value conversion
carpecodeum Jun 24, 2025
a4314e2
[FIX] use the let-else pattern to reduce indentation
carpecodeum Jun 24, 2025
c8c810a
[FIX] fix the formatting issues
carpecodeum Jun 24, 2025
3ac00ca
[FIX] fix all clippy and doc tests errors
carpecodeum Jun 24, 2025
b49c26f
Fix logical conflict with #7738
alamb Jun 24, 2025
a47ccfc
Less explicit panics
alamb Jun 24, 2025
0e10d82
[FIX] retain the position of from bool
carpecodeum Jun 25, 2025
35a2f50
[FIX] make the returns from writes more modular
carpecodeum Jun 25, 2025
b16d1e5
[FIX] make the write decimal functions modular
carpecodeum Jun 25, 2025
4010b73
[FIX] format code with improved iters and value::null handling
carpecodeum Jun 25, 2025
de7c979
[FIX] fix further precision issues from the decimal
carpecodeum Jun 25, 2025
d8f43f2
[FIX] implement fromiterator
carpecodeum Jun 25, 2025
2f52569
[FIX] fix clippy and fmt errors
carpecodeum Jun 25, 2025
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
2 changes: 2 additions & 0 deletions parquet-variant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ rust-version = "1.83"
[dependencies]
arrow-schema = { workspace = true }
chrono = { workspace = true }
serde_json = "1.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if we could avoid adding these dependencies if possible as serdejson brings non trivial code.

This probably looks like adding a optional feature flag (like serde-json) or something

I think we can do it as a follow on PR though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base64 = "0.21"

[lib]
55 changes: 55 additions & 0 deletions parquet-variant/examples/variant_to_json_examples.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

//! Example showing how to convert Variant values to JSON
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great to include this inline in the docs rather than a standalone example, but I will make a follow on PR to do so

use parquet_variant::{
variant_to_json, variant_to_json_string, variant_to_json_value, VariantBuilder,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = VariantBuilder::new();

{
let mut person = builder.new_object();
person.append_value("name", "Alice");
person.append_value("age", 30i32);
person.append_value("email", "[email protected]");
person.append_value("is_active", true);
person.append_value("score", 95.7f64);
person.append_value("department", "Engineering");
person.finish();
}

let (metadata, value) = builder.finish();
let variant = parquet_variant::Variant::try_new(&metadata, &value)?;

let json_string = variant_to_json_string(&variant)?;
let json_value = variant_to_json_value(&variant)?;
let pretty_json = serde_json::to_string_pretty(&json_value)?;
println!("{}", pretty_json);

let mut buffer = Vec::new();
variant_to_json(&mut buffer, &variant)?;
let buffer_result = String::from_utf8(buffer)?;

// Verify all methods produce the same result
assert_eq!(json_string, buffer_result);
assert_eq!(json_string, serde_json::to_string(&json_value)?);

Ok(())
}
2 changes: 2 additions & 0 deletions parquet-variant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ mod decoder;
mod variant;
// TODO: dead code removal
mod builder;
mod to_json;
#[allow(dead_code)]
mod utils;

pub use builder::*;
pub use to_json::{variant_to_json, variant_to_json_string, variant_to_json_value};
pub use variant::*;
Loading
Loading