Skip to content

Support JSON/JSONB metadata discovery from ingestion data #386

Description

@sanphy-citrus

Problem

Currently, JSON/JSONB metadata discovery requires reading JSON/JSONB values separately from the database after ingestion.

This can result in an additional database query even though the JSON/JSONB data may already be available during the SLayer ingestion process.

Requirement

Support discovering metadata from JSON/JSONB values that are already available during ingestion.

The JSON/JSONB structure is not known in advance and may vary between rows.

For example:

  • A table may contain 2–3 JSONB columns.
  • Each JSONB column may have a different structure.
  • Different rows within the same JSONB column may also contain different structures.
  • JSON objects may be nested to multiple levels.

Expected Behavior

During ingestion, when a JSON/JSONB value is available, the metadata discovery process should be able to:

  1. Traverse the JSON/JSONB structure recursively.
  2. Discover nested field paths.
  3. Infer the appropriate data type for scalar values.
  4. Handle different structures across multiple rows.
  5. Merge discovered fields/types for the corresponding JSONB column.
  6. Generate the appropriate SLayer metadata.
  7. Avoid an additional database query solely for JSON/JSONB metadata discovery.

Example

Given:

{
  "name": "John",
  "address": {
    "city": "Kochi",
    "state": "Kerala"
  },
  "orders": [
    {
      "id": 101,
      "amount": 500
    }
  ]
}

The discovery process should be able to identify paths such as:

name
address
address.city
address.state
orders
orders.id
orders.amount

Current Implementation

There is already a separate JSON processor that performs recursive JSON traversal, type inference, type merging, sensitive-field filtering, and SLayer metadata generation.

The proposed change is to reuse this existing discovery logic and provide it with JSON/JSONB values already obtained during SLayer ingestion instead of querying the database again.

Benefit

This would:

  • Avoid unnecessary database reads.
  • Reduce database load.
  • Reuse JSON/JSONB data already available during ingestion.
  • Support arbitrary and changing JSON structures.
  • Keep JSON/JSONB metadata generation integrated with the ingestion flow.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions