Interface SortPreserving

All Known Implementing Classes:
ChangePoint, Completion, Dissect, Enrich, EsqlProject, Eval, Filter, Grok, InferencePlan, InlineJoin, InlineStats, Keep, Project, RegexExtract, Rerank, ResolvingProject

public interface SortPreserving
This is a marker interface for commands that maintain the sort order of their input. This commands can swap position with an adjacent SORT (OrderBy) or with one that is separated from the command only by other SortPreserving commands.

These are some examples of commands that are not sort preserving:

  • Aggregate: reducing node: maps input to different output. (Preceding SORTs should be dropped by the PruneRedundantOrderBy rule.)
  • Fork: generative node: produces new data which might or might not be aligned with the existing sort.
  • Fuse: reducing node: merges rows.
  • Join: some types are generative; LookupJoin is surrogate'd with a "plain" Join node.
  • MvExpand: generative node, can destabilize the order.
  • OrderBy: introduces a new sort.
  • Limit: truncating node. An outlier: it does maintain the order, but cannot be swapped with a SORT, as that'd change the produced results. Notably, the same applies to Sample, but that is acceptable within Sample's contract.
  • TopN: introduces a new sort.

Most other commands are preserving the order.

Note: some commands, like Drop, Keep, Rename are also sort-preserving, but they get swapped out in the Analyzer, before their sortability being relevant.