Skip to content

Orderby expression#94

Open
den-crane wants to merge 2 commits into
iamtelescope:mainfrom
den-crane:orderby_expression
Open

Orderby expression#94
den-crane wants to merge 2 commits into
iamtelescope:mainfrom
den-crane:orderby_expression

Conversation

@den-crane
Copy link
Copy Markdown
Contributor

@den-crane den-crane commented Feb 19, 2026

closes: #97

Why

My Clickhouse's log tables require very specific ORDER BY expression (toStartOfHour(timestamp) desc,timestamp desc) .

What

This PR adds ORDER_BY_expression entity to Clickhouse Sources (UI/tables/migration).
This ORDER_BY_expression is used by default in Logs also it displayed in the new InputBox at the right from Columns selector. This input allows to define ad-hoc orderby. Also this input box state will be stored in View along with ColumnsSelector, etc.
Plus tests.

Screenshot 2026-02-18 at 9 11 33 PM Screenshot 2026-02-19 at 3 44 34 PM

References


100% vibe-coded by CC.
Later I am going to add a feature for changing this Logs viewer's ad-hoc ORDER_BY_expression by clicking to table's headers.

@HumanUser
Copy link
Copy Markdown
Contributor

Thanks for the contribution - I agree that order_by_expression makes sense at the source level, especially for ClickHouse where time-based ordering may require optimization like:

toStartOfHour(timestamp) DESC, timestamp DESC

That’s a valid source-level optimization.

However, I’m less convinced about arbitrary user-level ORDER BY overrides in a log viewer. Telescope is primarily designed for time-ordered log exploration. Allowing custom expressions moves it closer to a generic data explorer, which may not be the intended direction.

There are also some concerns:

  • Security - raw SQL concatenation increases injection surface.
  • Performance - users can introduce expensive or non-indexed sorts.
  • If we keep user-level overrides, this should probably be permission-gated and/or validated. - while i still not use I want to do itg.

Architecturally, I’d also avoid hardcoding something like:

source.type == 'clickhouse'

Instead, a capability-based approach (e.g. supportsOrderByExpression) would be cleaner and more extensible, especially since this does not apply to Docker/K8s sources.

Let’s align on product direction before finalizing.

p.s.
All these question ask "why" there is opening-an-issue-first note in contribution guide: https://github.com/iamtelescope/telescope?tab=contributing-ov-file#opening-an-issue-first

@HumanUser HumanUser added the enhancement New feature or request label Mar 1, 2026
@HumanUser HumanUser self-assigned this Mar 1, 2026
@den-crane
Copy link
Copy Markdown
Contributor Author

However, I’m less convinced about arbitrary user-level ORDER BY overrides in a log viewer.

Right, I don't need it that much myself.
Generally, I was inspired by the Hyperdx UI, it allows to define a query ORDERBY in ad-hoc manner.

How about I move input box and everything under RAW QUERY?
Input box will be invisible till the raw query enabled and it will be secured by the raw query privilege.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FR: Ability to define ORDERBY

2 participants