Skip to content

docs: json2 data type#2615

Open
fengys1996 wants to merge 6 commits into
GreptimeTeam:mainfrom
fengys1996:feat/json2
Open

docs: json2 data type#2615
fengys1996 wants to merge 6 commits into
GreptimeTeam:mainfrom
fengys1996:feat/json2

Conversation

@fengys1996

@fengys1996 fengys1996 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What's Changed in this PR

This PR adds a guide to JSON2, including a quick start, syntax, and future roadmap.

Checklist

  • Please confirm that all corresponding versions of the documents have been revised.
  • Please ensure that the content in sidebars.ts matches the current document structure when you changed the document structure.
  • This change requires follow-up update in localized docs.

@fengys1996 fengys1996 requested a review from Copilot July 10, 2026 08:09
@fengys1996

Copy link
Copy Markdown
Contributor Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds documentation for GreptimeDB’s JSON2 data type (nightly/current docs) and surfaces it in the Logs section of the docs sidebar, including a Chinese localized version.

Changes:

  • Added a new JSON2 documentation page under docs/user-guide/logs/.
  • Added the corresponding Chinese doc under i18n/zh/.../current/.
  • Linked the new page into the Logs sidebar navigation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sidebars.ts Adds the new user-guide/logs/json2 doc entry to the Logs sidebar.
docs/user-guide/logs/json2.md Introduces the English JSON2 type guide with examples and limitations.
i18n/zh/docusaurus-plugin-content-docs/current/user-guide/logs/json2.md Adds the Chinese version of the JSON2 type guide.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/user-guide/logs/json2.md

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb656f1549

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sidebars.ts
@fengys1996 fengys1996 marked this pull request as ready for review July 10, 2026 08:24
When creating a table, you can declare a JSON2 column with the `JSON2` type.
Currently, JSON2 can only be used in append-only tables, so you must set `'append_mode' = 'true'` when creating the table.

JSON2 supports type hints, which let you declare concrete data types for subpaths. Once declared, these subpaths are stored using the specified types, which provides query performance close to regular columns and enforces type validation during writes. In the following example, the `attrs` column defines type hints for common paths such as `http.status`, `latency_ms`, and `error`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

describe this is not required. My suggestion is to make quick start quick enough and cover type hint in later section.

just show how to create table without type hint, ingest json and query.

- Support subscript access to elements inside JSON arrays. For now, you can query `attrs.items`, but not `attrs.items[0]` or `json_get(attrs, 'items[0]')`.
- Support functions such as `json_get_string`, `json_get_int`, `json_get_float`, and `json_get_bool` for JSON2.
- Extend supported type hint data types, such as time-related types like `TIMESTAMP`.
- Support index options such as `INVERTED INDEX` and `SKIPPING INDEX` for type hints.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

how to use json2 with otlp and other ingestion path


Type hints allow `NULL` by default. If you specify `NOT NULL`, that path must exist in the written JSON.

### `json_get`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
### `json_get`
### `json_get` UDF


```sql
json_get(json_column, 'path.to.field')::TYPE
```

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add a description for dot syntax


## Syntax

### Type hints

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
### Type hints
### JSON Field Type hints

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and explain why it's essential, but optional

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