Skip to content

Support for native JSON type in JSONExtract* functions. Fixes #88370.#96711

Merged
Avogar merged 19 commits intoClickHouse:masterfrom
fkastrati:fix-json-extract-with-json-type
Feb 25, 2026
Merged

Support for native JSON type in JSONExtract* functions. Fixes #88370.#96711
Avogar merged 19 commits intoClickHouse:masterfrom
fkastrati:fix-json-extract-with-json-type

Conversation

@fkastrati
Copy link
Copy Markdown
Contributor

@fkastrati fkastrati commented Feb 11, 2026

Changelog category:

  • Improvement

Changelog entry:

You can now use native JSON/Object input for JSONExtract functions. Closes #88370

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@fkastrati fkastrati force-pushed the fix-json-extract-with-json-type branch from 47003dd to ffef00f Compare February 12, 2026 00:30
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Feb 12, 2026
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Feb 12, 2026

Workflow [PR], commit [30e40a7]

Summary:

job_name test_name status info comment
Stateless tests (amd_binary, old analyzer, s3 storage, DatabaseReplicated, parallel) failure
03917_mergeTreeTextIndex_table_function FAIL cidb, issue ISSUE EXISTS
Stress test (amd_tsan) failure
Logical error: 'txn->getState() != MergeTreeTransaction::COMMITTED' (STID: 2508-2b69) FAIL cidb, issue ISSUE EXISTS

@clickhouse-gh clickhouse-gh bot added the pr-improvement Pull request with some product improvements label Feb 12, 2026
@Avogar Avogar self-assigned this Feb 12, 2026
@clickhouse-gh clickhouse-gh bot added the manual approve Manual approve required to run CI label Feb 15, 2026
@fkastrati fkastrati force-pushed the fix-json-extract-with-json-type branch 2 times, most recently from 153d656 to 2db08ae Compare February 16, 2026 16:29
@fkastrati
Copy link
Copy Markdown
Contributor Author

@Avogar CI pipeline doesn't seem to be running. I haven't received any update since two days ago. Can you please have a look at it?

@Avogar
Copy link
Copy Markdown
Member

Avogar commented Feb 18, 2026

Sure, I will look at it later today when I am finished with some important incident.

@Avogar Avogar removed the manual approve Manual approve required to run CI label Feb 18, 2026
Copy link
Copy Markdown
Member

@Avogar Avogar left a comment

Choose a reason for hiding this comment

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

This approach works for some use cases, but it has limitations and problems (see comments). Let me suggest another approach:

  • Support JSONExtract* functions over JSON type only with constant keys arguments with type String. Supporting non-constant keys and indexes is not trivial, will be complex to implement and will work very slow. And in my opinion, the use cases with indexes and non-constant keys are not common and it's totally ok to skip them for now.
  • With constant keys we can form a path that we need to extract, here we can use subcolumns to do it, but as I described in one of the comments, we can't just use simple subcolum with dots, we need a combination of a literal subcolumn and subobject subcolumn to be able to extract both literals and nested objects by specified path. Similar how it's done in tupleElement function (see FunctionTupleElement::getObjectElement).
  • After extracting and combining subcolumns we can use accurateCastOrDefault to convert the values to the destination data type (for JSONExtractRaw we need to do something else, for example, formatting the value as JSON string using ISerialization::serializeTextJSON).

@fkastrati fkastrati force-pushed the fix-json-extract-with-json-type branch from 6b2c51a to 32df0eb Compare February 18, 2026 23:06
@clickhouse-gh clickhouse-gh bot added the manual approve Manual approve required to run CI label Feb 18, 2026
@Avogar Avogar removed the manual approve Manual approve required to run CI label Feb 19, 2026
@fkastrati
Copy link
Copy Markdown
Contributor Author

@Avogar Thanks for the thorough review. I’ve incorporated your suggestions and pushed the updated changes.

@fkastrati fkastrati requested a review from Avogar February 20, 2026 13:07
@fkastrati fkastrati force-pushed the fix-json-extract-with-json-type branch from ef253ce to 8606a03 Compare February 20, 2026 13:28
@fkastrati fkastrati requested a review from Avogar February 20, 2026 23:23
@fkastrati fkastrati force-pushed the fix-json-extract-with-json-type branch from b350e18 to 04b17f7 Compare February 21, 2026 14:12
Copy link
Copy Markdown
Member

@Avogar Avogar left a comment

Choose a reason for hiding this comment

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

Great work! Just 2 final minor comments and we can merge it

@fkastrati fkastrati requested a review from Avogar February 24, 2026 16:31
@Avogar Avogar added this pull request to the merge queue Feb 25, 2026
Merged via the queue into ClickHouse:master with commit 98cf010 Feb 25, 2026
145 of 148 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Feb 25, 2026
@fkastrati fkastrati deleted the fix-json-extract-with-json-type branch February 26, 2026 11:43
@Avogar Avogar mentioned this pull request Mar 6, 2026
56 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL/JSON and JSONExtract functions should work with the JSON data type

5 participants