Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time index column alias for SQL #4524

Open
sunng87 opened this issue Aug 7, 2024 · 5 comments
Open

Time index column alias for SQL #4524

sunng87 opened this issue Aug 7, 2024 · 5 comments
Labels
C-enhancement Category Enhancements C-user-experience Category User Experience

Comments

@sunng87
Copy link
Member

sunng87 commented Aug 7, 2024

What type of enhancement is this?

User experience

What does the enhancement do?

Since we only one time index column in each table, it is possible to use an alias for this column without requiring its actual name in sql. For example in a table of:

CREATE TABLE monitor (
  host STRING,
  ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP() TIME INDEX,
  cpu FLOAT64 DEFAULT 0,
  memory FLOAT64,
  PRIMARY KEY(host));

Instead of using ts, we can use an alias, say __ts__, in sql query:

SELECT * FROM monitor ORDER BY __ts__ DESC LIMIT 100;

Alias naming candidates

  • $timestamp
  • __timestamp
  • __timestamp__
  • @timestamp

Implementation challenges

No response

@sunng87 sunng87 added the C-enhancement Category Enhancements label Aug 7, 2024
@killme2008 killme2008 added the C-user-experience Category User Experience label Aug 8, 2024
@killme2008
Copy link
Contributor

I personally prefer $time_index as it represents the time index.

@waynexia
Copy link
Member

waynexia commented Aug 8, 2024

This seems not viable in JOIN cases like

SELECT * FROM metrics JOIN logs on metrics.host = logs.host ORDER BY ??? DESC LIMIT 100;

where the TIME INDEX attribute lost after calculation (not only JOIN)

@sunng87
Copy link
Member Author

sunng87 commented Aug 9, 2024

@waynexia Can we use metrics.$time_index here?

@waynexia
Copy link
Member

waynexia commented Aug 9, 2024

What if metrics is from a subquery

@sunng87
Copy link
Member Author

sunng87 commented Aug 13, 2024

It has to be an error for this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements C-user-experience Category User Experience
Projects
None yet
Development

No branches or pull requests

3 participants