Skip to content

Conversation

@sophiewaldman
Copy link
Contributor

What this PR does / why we need it:
We need to be able to serialize physical plans in order for the scheduler to be able to deliver plans to workers over the network. This PR replaces the existing Node and Expression objects with equivalent protobufs, and updates the code accordingly.

Which issue(s) this PR fixes:
Fixes https://github.com/grafana/loki-private/issues/2002

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@sophiewaldman sophiewaldman changed the title chore<query engine>: use serializable protobuf objects for physical plans chore(query engine): use serializable protobuf objects for physical plans Oct 29, 2025
rfratto added a commit that referenced this pull request Nov 1, 2025
This adds two new packages, expressionpb and physicalpb, which are
serializable representations of physical.Expression and physical.Plan,
respectively.

These packages include utility functions to convert between the protobuf
representations and the planner types.

A translation layer is used due to the complexity of integrating
protobuf throughout the engine, as well as difficulties with finding a
clean pattern to construct node types. #19638 took an
initial attempt at fully integrating the protobuf types, but revealed
that it is very challenging.

While investiating the code, I observed that it's very clunky to work
with the protobuf types, especailly with how often we rely on interface
values. It's clear to me that we will want to eventually remove our
translation layer, but doing it too soon means needing to update the
entire engine code path twice. It is a much safer bet to start with a
translation layer, find the right abstraction for constructing the
protobuf, and then migrate once we have confidence in the pattern.
rfratto added a commit that referenced this pull request Nov 1, 2025
This adds two new packages, expressionpb and physicalpb, which are
serializable representations of physical.Expression and physical.Plan,
respectively.

These packages include utility functions to convert between the protobuf
representations and the planner types.

A translation layer is used due to the complexity of integrating
protobuf throughout the engine, as well as difficulties with finding a
clean pattern to construct node types. #19638 took an
initial attempt at fully integrating the protobuf types, but revealed
that it is very challenging.

While investiating the code, I observed that it's very clunky to work
with the protobuf types, especailly with how often we rely on interface
values. It's clear to me that we will want to eventually remove our
translation layer, but doing it too soon means needing to update the
entire engine code path twice. It is a much safer bet to start with a
translation layer, find the right abstraction for constructing the
protobuf, and then migrate once we have confidence in the pattern.

Co-authored-by: Sophie Waldman <[email protected]>
rfratto added a commit that referenced this pull request Nov 1, 2025
This adds two new packages, expressionpb and physicalpb, which are
serializable representations of physical.Expression and physical.Plan,
respectively.

These packages include utility functions to convert between the protobuf
representations and the planner types.

A translation layer is used due to the complexity of integrating
protobuf throughout the engine, as well as difficulties with finding a
clean pattern to construct node types. #19638 took an
initial attempt at fully integrating the protobuf types, but revealed
that it is very challenging.

While investiating the code, I observed that it's very clunky to work
with the protobuf types, especailly with how often we rely on interface
values. It's clear to me that we will want to eventually remove our
translation layer, but doing it too soon means needing to update the
entire engine code path twice. It is a much safer bet to start with a
translation layer, find the right abstraction for constructing the
protobuf, and then migrate once we have confidence in the pattern.

Co-authored-by: Sophie Waldman <[email protected]>
rfratto added a commit that referenced this pull request Nov 1, 2025
This adds two new packages, expressionpb and physicalpb, which are
serializable representations of physical.Expression and physical.Plan,
respectively.

These packages include utility functions to convert between the protobuf
representations and the planner types.

A translation layer is used due to the complexity of integrating
protobuf throughout the engine, as well as difficulties with finding a
clean pattern to construct node types. #19638 took an
initial attempt at fully integrating the protobuf types, but revealed
that it is very challenging.

While investiating the code, I observed that it's very clunky to work
with the protobuf types, especailly with how often we rely on interface
values. It's clear to me that we will want to eventually remove our
translation layer, but doing it too soon means needing to update the
entire engine code path twice. It is a much safer bet to start with a
translation layer, find the right abstraction for constructing the
protobuf, and then migrate once we have confidence in the pattern.

Co-authored-by: Sophie Waldman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant