Comments (6)
Hi there!
I'd like to work on this issue. πLet's make this happen! πͺ
Please forgive me for not fully understanding the meaning of this issue. What I can think of is that you hope that lindb can support the following SQL statement query:
select x, y, z from a where x > 10.1 and y < 5.2; // x, y and z are all fields
Can you tell me whether my understanding is correct? If not, please describe this issue in more detail. Thank you.
from lindb.
βοΈ , Welcome to contribute LinDB together.
Yes, you are right.
Some cases like this:
select x, y, z from a>10.1; // fields
select x+y as a, 2*z, z from a>10 and 2*z>10; // expr
select sum(x) as a from a>10; // function
from lindb.
βοΈ , Welcome to contribute LinDB together.
Yes, you are right.
Some cases like this:
select x, y, z from a>10.1; // fields select x+y as a, 2*z, z from a>10 and 2*z>10; // expr select sum(x) as a from a>10; // function
-
In your example, there is no specification of the metric, and there is no 'WHERE' keyword. Is this just a shorthand form, or is it a formal syntax?
-
When you need to simultaneously filter based on both tags and fields, what should the SQL statement look like?
-
In this example, would it be better to use the HAVING clause?
select sum(x) as a from a>10; // function
=>
select sum(x) as a from metric_x having a > 10;
from lindb.
If I make any mistakes, please feel free to interrupt me.
Filtering for fields can only be done at the root node of the broker because it requires aggregating results from all intermediate nodes or storage nodes in the broker. Only when all families from all shards are aggregated by interval can the data that doesn't meet the WHERE conditions be filtered out. Implementing this feature in root_metric_context.go might be the most suitable approach.
For queries involving GROUP BY time in standard SQL, field filtering should occur before grouping. In other words, fields that do not meet the conditions should not be included in the group calculation. However, for Lindb, filtering of fields should occur after grouping. In this case, filtering fields behaves similarly to the HAVING clause. Therefore, if Lindb supports HAVING queries, the following two SQL statements would be equivalent.
select * from a where field_a = 1 group by time(1m); // Assuming this is valid.
select * from a group by time(1m) having field_a = 1;
The field condition may not necessarily appear in the selectExpr, which also determines some modifications in certain operators.
from lindb.
I made a mistake.
There are 2 scenarios here.
- Before grouping aggregate, filtering raw value of field.
select * from a where field_a =1
- After grouping aggregate, filtering the result of grouping. Like you said group by having statement is better.
select * from a group by time(1m) having field_a = 1; // using default aggregate function
Let's implement scenario 2 first, and at the same time, like standard SQL, the field condition must appera in the selectExpr?
from lindb.
If I make any mistakes, please feel free to interrupt me.
Filtering for fields can only be done at the root node of the broker because it requires aggregating results from all intermediate nodes or storage nodes in the broker. Only when all families from all shards are aggregated by interval can the data that doesn't meet the WHERE conditions be filtered out. Implementing this feature in root_metric_context.go might be the most suitable approach.
For queries involving GROUP BY time in standard SQL, field filtering should occur before grouping. In other words, fields that do not meet the conditions should not be included in the group calculation. However, for Lindb, filtering of fields should occur after grouping. In this case, filtering fields behaves similarly to the HAVING clause. Therefore, if Lindb supports HAVING queries, the following two SQL statements would be equivalent.
select * from a where field_a = 1 group by time(1m); // Assuming this is valid. select * from a group by time(1m) having field_a = 1;The field condition may not necessarily appear in the selectExpr, which also determines some modifications in certain operators.
Yes, grouping field filtering only be done in the root node before building result set.
from lindb.
Related Issues (20)
- [feature]: support prometheus query language HOT 3
- [bug]: read index data panic
- [enhance]: reduce goroutine when write too many data families HOT 2
- [feature]: create table HOT 2
- [feature]: support insert data by sql HOT 2
- [bug]:the 'show metrics' statement returns incorrect results when there are a large number of metrics HOT 1
- [enhance]: new sql parser
- [bug]: Unexplained restart in standalone mode HOT 18
- [question]: Proper backup and restore mechanism HOT 2
- [bug]: Node goes dead HOT 9
- [enhance]: monthly partitioning of indices
- [bug]: miss makezero in slice init
- [bug]: lost web console when build package via github action
- [feature]: support select *(query all fields)
- [question]: Is this a product exchange group? HOT 3
- [bug]:When the query result is empty, the client will report a null pointer exception. HOT 3
- [feature]: build index on LinDB common kv store
- [bug]: data not found with not in filter(if tag value not exist) HOT 2
- [enhance]: create database by with statement HOT 3
- [feature]: support opentelemetry exemplar
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lindb.