Skip to content

Can't select nested JSON from Clickhouse #5702

@jwhitaker-gridcog

Description

@jwhitaker-gridcog

It seems we're missing support for column.^path syntax for Clickhouse's JSON type:

-- in clickhouse
create table src (
  doc JSON
);

insert into src
  doc
values
 '{"nested": {"abc": 123}}';

Try to select with a view:

model (
  name my_model;
  kind view;
)

select
  doc.^nested as nested
from src

This errors:

Error: Failed to load model from file '/home/jarrad/src/.../model.sql':

  Required keyword: 'this' missing for <class 'sqlglot.expressions.Column'>.

Docs on column.^path syntax: https://clickhouse.com/docs/sql-reference/data-types/newjson#reading-json-sub-objects-as-sub-columns

I'm assuming a SQLGlot thing but raising here to track getting the fix into sqlmesh.

Thanks for maintaining these!

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