bazelbuild / bazelbuild/bazel

Allow inspection of intermediate query `let` values

Open
#25,718 0 comments 0 reactions 0 assignees View on GitHub
query bugs team-Core type: feature request untriaged
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

In some cases we want to execute hundreds of `bazel query` (and `cquery`) and get the results of each. This involves a lot of overhead as the bazel client has to connect to the bazel server hundreds of times.

Instead, we want a way to issue all of these queries over a single invocation, and then parse out the results individually.
I believe this could be accomplished elegantly by adding a flag to also output the computed values of `let` expressions in the output.

Super simple example with imaginary `--output=let_json`:
```bash
bazel query --output=let_json 'let group1 = deps(//target1) in let group2 = deps(//target2) in //target3'
```
would output something like:
```json
{
"results": ["//target3:target3"],
"variables": {
"group1": [
"//target1:target1",
"//target2:target2",
"//target3:target3"
],
"group2": [
"//target2:target2",
"//target3:target3"
]
}
}
```
Where `results` would be the actual result of the query, `variables.group1` would be the value of `$group1` and `variables.group2` would be the value of `$group2`.

Contributor guide

Open the contributing guide

Research direction

Start with Bazel's query and cquery output handling and the evaluation of let expressions. Define how a new output mode would expose the final results and each let value, then verify the format across the example queries and confirm that multiple queries can be processed from one invocation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.