Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Introduce Variant data #4729

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

Zouxxyy
Copy link
Contributor

@Zouxxyy Zouxxyy commented Dec 17, 2024

Purpose

Subtask of #4471

Variant was born from Apache Spark, and the encoding rules have been incorporated into Parquet https://github.com/apache/parquet-format/blob/master/VariantEncoding.md

This PR add the basic interface of Variant and ported the latest implementation of Spark.

public interface Variant {

    /** Returns the variant metadata. */
    byte[] metadata();

    /** Returns the variant value. */
    byte[] value();

    /** Parses the variant to json. */
    String toJson();

    /**
     * Extracts a sub-variant value according to a path which start with a `$`. 
     */
    Object variantGet(String path);
}

Usage

  String json = "{\"age\":35,\"city\":\"Hangzhou\"}";
  Variant v = GenericVariant.fromJson(json);
  assertThat(v.variantGet("$.age")).isEqualTo(35L);
  assertThat(v.variantGet("$.city")).isEqualTo("Hangzhou");

Tests

API and Format

Documentation

Copy link
Contributor

@JingsongLi JingsongLi left a comment

Choose a reason for hiding this comment

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

+1

@YannByron YannByron merged commit 3a9e1e8 into apache:master Dec 17, 2024
12 checks passed
jerry-024 pushed a commit to jerry-024/paimon that referenced this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants