GreptimeTeam / greptimedb

An Open-Source, Cloud-Native, Unified Time Series Database for Metrics, Logs and Events with SQL/PromQL supported. Available on GreptimeCloud.
http://greptimedb.rs/
Apache License 2.0
4.05k stars 291 forks source link

Supports JSON format #3686

Open WenyXu opened 3 months ago

WenyXu commented 3 months ago

What problem does the new feature solve?

Supports inserting/querying JSON data.

What does the feature do?

Support for JSON data format will be divided into several stages:

  1. Add necessary data type support, including Lists and Nested data
  2. Supports inserting JSON data
  3. Supports querying JSON data
  4. Supports Schemaless JSON

Implementation challenges

See also:

WenyXu commented 3 months ago

As mentioned in https://github.com/apache/datafusion/issues/7845#issuecomment-2068061465, I was greatly inspired by JSONA and proposed a JSONA variant(Maybe we can call it JSONC, JSON for columnar storage formats😙) that may benefit from the high compression rates of columnar storage formats. BTW, If we decide to implement our own JSON storage implementation, It's definitely an excellent opportunity to evaluate various storage implementations of JSON in the OLAP scenario.

A naive proposal of JSONA variant.

For JSON [false, 10, {"k":"v"}, null] can be stored as the following struct.

Struct {
    Nodes: [StartArray, FALSE, Number, StartObject, Key, String, EndObject, NULL, EndArray]
    Offsets: [NULL, NULL, 0, NULL, 0, 0, NULL,…]
    Keys: ["k"]
    Strings: ["v"]
    Numbers: [10]
}

The Struct data can be efficiently encoded into compact files using the underlying file format. In our scenario, we use the Parquet as the underlying file format. For instance, the Nodes field can be represented as UINT8 and efficiently encoded using default dictionary encoding.