cortoproject / corto

A hierarchical object store for connecting realtime machine data with web applications, historians & more
https://www.corto.io
MIT License
86 stars 14 forks source link

Allow specifying custom views in queries #659

Open SanderMertens opened 6 years ago

SanderMertens commented 6 years ago

Currently when an application queries for an object, all members for the object are serialized (when a serialization format is specified). Often an application will not need all members, and can thus performance could be saved by making a subselection of members.

Additionally, views could offer more sophisticated abstractions, like selecting members by tag, requesting data in a specific unit or converting to another type, which decouples the application from the underlying types of the data, and allows for more evolvable systems.

Examples:

Select members:

select * from data view x, y

Select nested members:

select * from data view start.x, start.y, stop.x, stop.y

Alias members:

select * from data view start.x as bx, start.y as by, stop.x as ex, stop.y as ey

Select members by tag:

select * from data view #latitude, #longitude

Select members, change type

select * from data view x as (string), y as (string)

Same, but shorthand:

select * from data view x as :string, y as :string

Alias members, change type

select * from data view x as cx(string), y as cy(string)

Same, but shorthand:

select * from data view x as cx:string, y as cy:string

Change unit

select * from data view temperature as (unit=celcius)

Select tag, alias member, change type and change unit

select * from data view #temperature as temp(float64, unit=celcius)

The syntax after as is consistent with the new proposal for the corto language, which means the regular string deserializer can be used to parse query strings.