Skip to content

(Calculated fields) Add calculated-field predicates to QueryAst - #6777

Open
fulmicoton wants to merge 3 commits into
mainfrom
paul.masurel/calc-fields-integration
Open

fulmicoton wants to merge 3 commits into
mainfrom
paul.masurel/calc-fields-integration

Conversation

@fulmicoton

@fulmicoton fulmicoton commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Description

This adds the capability in Quickwit's QueryAST to match a jitexpr predicate within the query (so-called calculated fields in pomsky). The PR just plugs in a new feature from tantivy.

  • Add QueryAst::CalcField(CalcFieldQuery) with a jitexpr expression serialized as a string, including visitor/transformer support and user-query parsing passthrough. The list like jitexpr language is part of tantivy.
  • The query ast then converts to Tantivy's JitExprPredicate / DocPredicateQuery
  • Collect referenced fast fields for warmup, including string dictionaries through the existing whole-column warmup path. Preserve exact field paths and skip cache-hit subtrees.

Ast part of that effort, I refactored the different visitor collecting fast fields that needed to be downloaded for query matching into a single visitor.

Example:

{
  "type": "calc_field",
  "expression": "(GT custom.duration 1i64)"
}

@fulmicoton fulmicoton changed the title Add calculated-field predicates to QueryAst (Calculated fields) Add calculated-field predicates to QueryAst Sep 7, 2026
@fulmicoton-dd
fulmicoton-dd force-pushed the paul.masurel/calc-fields-integration branch 2 times, most recently from 5e6e6c7 to 7695065 Compare September 7, 2026 20:40
@fulmicoton
fulmicoton force-pushed the paul.masurel/calc-fields-integration branch from 7695065 to 2187a7a Compare September 8, 2026 08:40
@fulmicoton
fulmicoton requested a review from PSeitz September 8, 2026 09:12
@fulmicoton
fulmicoton marked this pull request as ready for review September 8, 2026 09:12
@fulmicoton
fulmicoton requested a review from a team as a code owner September 8, 2026 09:12
@fulmicoton-dd
fulmicoton-dd force-pushed the paul.masurel/calc-fields-integration branch from 6a00966 to 478a291 Compare September 15, 2026 14:52

@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: 478a291907

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

boost: NotNaNf32,
},
Cache(CacheNode),
CalcField(CalcFieldQuery),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Document the public calculated-field predicate

This adds a new publicly serialized QueryAst variant (type: calc_field), but a repository-wide search of docs/, config/, and the README finds no user-facing description of its expression grammar, supported field types, or missing-value behavior. Downstream callers therefore cannot reliably construct or reason about this new query behavior; add it to the native-query/search API documentation.

AGENTS.md reference: AGENTS.md:L23-L24

Useful? React with 👍 / 👎.

@fulmicoton-dd
fulmicoton-dd force-pushed the paul.masurel/calc-fields-integration branch 4 times, most recently from adb1594 to 4510c0d Compare September 15, 2026 15:53

@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: e42805d961

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

&self,
_context: &BuildTantivyAstContext,
) -> Result<TantivyQueryAst, InvalidQuery> {
let predicate = JitExprPredicate::new(self.expression.clone())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Resolve calculated inputs through the dynamic field

When an expression references an unmapped field in Quickwit's default dynamic mode, such as (GT duration 2i64), the physical fast-field column is _dynamic.duration: normal query paths use find_field_or_hit_dynamic to perform this fallback. This implementation ignores the schema context and passes duration unchanged to Tantivy, while the warmup visitor also requests the unchanged name, so the predicate binds a missing column and returns no matches for valid dynamically mapped data. Rewrite calculated-field variables to their resolved split-schema column names before constructing and warming the predicate.

Useful? React with 👍 / 👎.

Comment on lines +202 to +205
const DEFAULT_EXPR_COMPILATION_CACHE_CAPACITY: usize = 256;
let capacity: usize = quickwit_common::get_from_env(
"QW_EXPR_COMPILATION_CACHE_CAPACITY",
DEFAULT_EXPR_COMPILATION_CACHE_CAPACITY,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document the expression compilation cache setting

This introduces the operator-facing QW_EXPR_COMPILATION_CACHE_CAPACITY setting and its default of 256, but a repository-wide search of docs/ and config/ finds no entry describing it, its units, or when it is read. Operators therefore cannot discover or safely tune the process-wide JIT cache without reading the source; add this environment variable to the searcher/node configuration documentation.

AGENTS.md reference: AGENTS.md:L23-L24

Useful? React with 👍 / 👎.

@fulmicoton-dd
fulmicoton-dd force-pushed the paul.masurel/calc-fields-integration branch from e42805d to 73c08ba Compare September 17, 2026 14:12
This adds the capability in Quickwit's QueryAST to match a jitexpr predicate within the query (so-called calculated fields in pomsky). The PR just plugs in a new feature from tantivy.

Add QueryAst::CalcField(CalcFieldQuery) with a jitexpr expression serialized as a string, including visitor/transformer support and user-query parsing passthrough. The list like jitexpr language is part of tantivy.
The query ast then converts to Tantivy's JitExprPredicate / DocPredicateQuery
Collect referenced fast fields for warmup, including string dictionaries through the existing whole-column warmup path. Preserve exact field paths and skip cache-hit subtrees.
Ast part of that effort, I refactored the different visitor collecting fast fields that needed to be downloaded for query matching into a single visitor.

Example:

{
  "type": "calc_field",
  "expression": "(GT custom.duration 1i64)"
}
@fulmicoton-dd
fulmicoton-dd force-pushed the paul.masurel/calc-fields-integration branch from 73c08ba to 8416e8b Compare September 17, 2026 16:05
@fulmicoton-dd
fulmicoton-dd requested review from nadav-govari and removed request for PSeitz September 17, 2026 16:08
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