mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-22 07:50:38 +00:00
* change dep Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * feat: adapt to arrow's interval array * chore: fix compile errors in datatypes crate * chore: fix api crate compiler errors * chore: fix compiler errors in common-grpc * chore: fix common-datasource errors * chore: fix deprecated code in common-datasource * fix promql and physical plan related Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * wip: upgrading network deps Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * block on updating `sqlparser` * upgrade sqlparser Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * adapt new df's trait requirements Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix compiler errors in mito2 * chore: fix common-function crate errors * chore: fix catalog errors * change import path Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix some errors in query crate * chore: fix some errors in query crate * aggr expr and some other tiny fixes Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: fix expr related errors in query crate * chore: fix query serializer and admin command * chore: fix grpc services * feat: axum serve * chore: fix http server * remove handle_error handler * refactor timeout layer * serve axum * chore: fix flow aggr functions * chore: fix flow * feat: fix errors in meta-srv * boxed() * use TokioIo * feat!: Remove script crate and python feature (#5321) * feat: exclude script crate * chore: simplify feature * feat: remove the script crate * chore: remove python feature and some comments * chore: fix warning * chore: fix servers tests compiler errors * feat: fix tests-integration errors * chore: fix unused * test: fix catalog test * chore: fix compiler errors for crates using common-meta testing feature is enabled when check with --workspace * test: use display for logical plan test * test: implement rewrite for ScanHintRule * fix: http server build panic * test: fix mito test * fix: sql parser type alias error * test: fix TestClient not listen * test: some flow tests * test(flow): more fix * fix: test_otlp_logs * test: fix promql test that using deprecated method fun() * fix: sql type replace supports Int8 ~ Int64, UInt8 ~ UInt64 * test: fix infer schema test case * test: fix tests related to plan display * chore: fix last flow test * test: fix function format related assertion * test: use larger port range for tests * fix: test_otlp_traces * fix: test_otlp_metrics * fix range query and dist plan Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix: flow handle distinct use deprecated field * fix: can't pass Join plan expressions to LogicalPlan::with_new_exprs * test: fix deserialize test * test: reduce split key case num * tests: lower case aggr func name * test: fix some sqlness tests * tests: more sqlness fix * tests: fixed sqlness test * commit non-bug changes Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix: make our udf correct * fix: implement empty methods of ContextProvider for DfContextProviderAdapter * test: update sqlness test result * chore: remove unused * fix: provide alias name for AggregateExprBuilder in range plan * test: update range query result * fix: implement missing ContextProvider methods for DfContextProviderAdapter * test: update timestamps, cte result * fix: supports empty projection in mito * test: update comment for cte test * fix: support projection for numbers * test: update test cases after projection fix * fix: fix range select first_value/last_value * fix: handle CAST and time index conflict * fix: handle order by correctly in range first_value/last_value * test: update sqlness result * test: update view test result * test: update decimal test wait for https://github.com/apache/datafusion/pull/14126 to fix this * feat: remove redundant physical optimization todo(ruihang): Check if we can remove this. * test: update sqlness test result * chore: range select default sort use nulls_first = false * test: update filter push down test result * test: comment deciaml test to avoid different panic message * test: update some distributed test result * test: update test for distributed count and filter push down * test: update subqueries test * fix: SessionState may overwrite our UDFs * chore: fix compiler errors after merging main * fix: fix elasticsearch and dashboard router panic * chore: fix common-functions tests * chore: update sqlness result * test: fix id keyword and update sqlness result * test: fix flow_null test * fix: enlarge thread size in debug mode to avoid overflow * chore: fix warnings in common-function * chore: fix warning in flow * chore: fix warnings in query crate * chore: remove unused warnings * chore: fix deprecated warnings for parquet * chore: fix deprecated warning in servers crate * style: fix clippy * test: enlarge mito cache tttl test ttl time * chore: fix typo * style: fmt toml * refactor: reimplement PartialOrd for RangeSelect * chore: remove script crate files introduced by merge * fix: return error if sql option is not kv * chore: do not use ..default::default() * chore: per review * chore: update error message in BuildAdminFunctionArgsSnafu Co-authored-by: jeremyhi <jiachun_feng@proton.me> * refactor: typed precision * update sqlness view case Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * chore: flow per review * chore: add example in comment * chore: warn if parquet stats of timestamp is not INT64 * style: add a newline before derive to make the comment more clear * test: update sqlness result * fix: flow from substrait * chore: change update_range_context log to debug level * chore: move axum-extra axum-macros to workspace --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: Ruihang Xia <waynestxia@gmail.com> Co-authored-by: luofucong <luofc@foxmail.com> Co-authored-by: discord9 <discord9@163.com> Co-authored-by: shuiyisong <xixing.sys@gmail.com> Co-authored-by: jeremyhi <jiachun_feng@proton.me>
288 lines
8.5 KiB
Plaintext
288 lines
8.5 KiB
Plaintext
-- from prometheus/promql/testdata/histograms.test
|
|
-- cases related to metric `testhistogram_bucket`
|
|
create table histogram_bucket (
|
|
ts timestamp time index,
|
|
le string,
|
|
s string,
|
|
val double,
|
|
primary key (s, le),
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into histogram_bucket values
|
|
(3000000, "0.1", "positive", 50),
|
|
(3000000, ".2", "positive", 70),
|
|
(3000000, "1e0", "positive", 110),
|
|
(3000000, "+Inf", "positive", 120),
|
|
(3000000, "-.2", "negative", 10),
|
|
(3000000, "-0.1", "negative", 20),
|
|
(3000000, "0.3", "negative", 20),
|
|
(3000000, "+Inf", "negative", 30);
|
|
|
|
Affected Rows: 8
|
|
|
|
-- Quantile too low.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(-0.1, histogram_bucket);
|
|
|
|
+---------------------+----------+------+
|
|
| ts | s | val |
|
|
+---------------------+----------+------+
|
|
| 1970-01-01T00:50:00 | negative | -inf |
|
|
| 1970-01-01T00:50:00 | positive | -inf |
|
|
+---------------------+----------+------+
|
|
|
|
-- Quantile too high.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(1.01, histogram_bucket);
|
|
|
|
+---------------------+----------+-----+
|
|
| ts | s | val |
|
|
+---------------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | negative | inf |
|
|
| 1970-01-01T00:50:00 | positive | inf |
|
|
+---------------------+----------+-----+
|
|
|
|
-- Quantile invalid.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(NaN, histogram_bucket);
|
|
|
|
+---------------------+----------+-----+
|
|
| ts | s | val |
|
|
+---------------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | negative | NaN |
|
|
| 1970-01-01T00:50:00 | positive | NaN |
|
|
+---------------------+----------+-----+
|
|
|
|
-- Quantile value in lowest bucket, which is positive.
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0, histogram_bucket{s="positive"});
|
|
|
|
+---------------------+----------+-----+
|
|
| ts | s | val |
|
|
+---------------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | positive | 0.0 |
|
|
+---------------------+----------+-----+
|
|
|
|
-- Quantile value in lowest bucket, which is negative.
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0, histogram_bucket{s="negative"});
|
|
|
|
+---------------------+----------+------+
|
|
| ts | s | val |
|
|
+---------------------+----------+------+
|
|
| 1970-01-01T00:50:00 | negative | -0.2 |
|
|
+---------------------+----------+------+
|
|
|
|
-- Quantile value in highest bucket.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(1, histogram_bucket);
|
|
|
|
+---------------------+----------+-----+
|
|
| ts | s | val |
|
|
+---------------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | negative | 0.3 |
|
|
| 1970-01-01T00:50:00 | positive | 1.0 |
|
|
+---------------------+----------+-----+
|
|
|
|
-- Finally some useful quantiles.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0.2, histogram_bucket);
|
|
|
|
+---------------------+----------+-------+
|
|
| ts | s | val |
|
|
+---------------------+----------+-------+
|
|
| 1970-01-01T00:50:00 | negative | -0.2 |
|
|
| 1970-01-01T00:50:00 | positive | 0.048 |
|
|
+---------------------+----------+-------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0.5, histogram_bucket);
|
|
|
|
+---------------------+----------+----------------------+
|
|
| ts | s | val |
|
|
+---------------------+----------+----------------------+
|
|
| 1970-01-01T00:50:00 | negative | -0.15000000000000002 |
|
|
| 1970-01-01T00:50:00 | positive | 0.15000000000000002 |
|
|
+---------------------+----------+----------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0.8, histogram_bucket);
|
|
|
|
+---------------------+----------+------+
|
|
| ts | s | val |
|
|
+---------------------+----------+------+
|
|
| 1970-01-01T00:50:00 | negative | 0.3 |
|
|
| 1970-01-01T00:50:00 | positive | 0.72 |
|
|
+---------------------+----------+------+
|
|
|
|
-- More realistic with rates.
|
|
-- This case doesn't contains value because other point are not inserted.
|
|
-- quantile with rate is covered in other cases
|
|
tql eval (3000, 3000, '1s') histogram_quantile(0.2, rate(histogram_bucket[5m]));
|
|
|
|
++
|
|
++
|
|
|
|
drop table histogram_bucket;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- cases related to `testhistogram2_bucket`
|
|
create table histogram2_bucket (
|
|
ts timestamp time index,
|
|
le string,
|
|
val double,
|
|
primary key (le),
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into histogram2_bucket values
|
|
(0, "0", 0),
|
|
(300000, "0", 0),
|
|
(600000, "0", 0),
|
|
(900000, "0", 0),
|
|
(1200000, "0", 0),
|
|
(1500000, "0", 0),
|
|
(1800000, "0", 0),
|
|
(2100000, "0", 0),
|
|
(2400000, "0", 0),
|
|
(2700000, "0", 0),
|
|
(0, "2", 1),
|
|
(300000, "2", 2),
|
|
(600000, "2", 3),
|
|
(900000, "2", 4),
|
|
(1200000, "2", 5),
|
|
(1500000, "2", 6),
|
|
(1800000, "2", 7),
|
|
(2100000, "2", 8),
|
|
(2400000, "2", 9),
|
|
(2700000, "2", 10),
|
|
(0, "4", 2),
|
|
(300000, "4", 4),
|
|
(600000, "4", 6),
|
|
(900000, "4", 8),
|
|
(1200000, "4", 10),
|
|
(1500000, "4", 12),
|
|
(1800000, "4", 14),
|
|
(2100000, "4", 16),
|
|
(2400000, "4", 18),
|
|
(2700000, "4", 20),
|
|
(0, "6", 3),
|
|
(300000, "6", 6),
|
|
(600000, "6", 9),
|
|
(900000, "6", 12),
|
|
(1200000, "6", 15),
|
|
(1500000, "6", 18),
|
|
(1800000, "6", 21),
|
|
(2100000, "6", 24),
|
|
(2400000, "6", 27),
|
|
(2700000, "6", 30),
|
|
(0, "+Inf", 3),
|
|
(300000, "+Inf", 6),
|
|
(600000, "+Inf", 9),
|
|
(900000, "+Inf", 12),
|
|
(1200000, "+Inf", 15),
|
|
(1500000, "+Inf", 18),
|
|
(1800000, "+Inf", 21),
|
|
(2100000, "+Inf", 24),
|
|
(2400000, "+Inf", 27),
|
|
(2700000, "+Inf", 30);
|
|
|
|
Affected Rows: 50
|
|
|
|
-- Want results exactly in the middle of the bucket.
|
|
tql eval (420, 420, '1s') histogram_quantile(0.166, histogram2_bucket);
|
|
|
|
+---------------------+-------+
|
|
| ts | val |
|
|
+---------------------+-------+
|
|
| 1970-01-01T00:07:00 | 0.996 |
|
|
+---------------------+-------+
|
|
|
|
tql eval (420, 420, '1s') histogram_quantile(0.5, histogram2_bucket);
|
|
|
|
+---------------------+-----+
|
|
| ts | val |
|
|
+---------------------+-----+
|
|
| 1970-01-01T00:07:00 | 3.0 |
|
|
+---------------------+-----+
|
|
|
|
tql eval (420, 420, '1s') histogram_quantile(0.833, histogram2_bucket);
|
|
|
|
+---------------------+-------------------+
|
|
| ts | val |
|
|
+---------------------+-------------------+
|
|
| 1970-01-01T00:07:00 | 4.997999999999999 |
|
|
+---------------------+-------------------+
|
|
|
|
tql eval (2820, 2820, '1s') histogram_quantile(0.166, rate(histogram2_bucket[15m]));
|
|
|
|
+---------------------+----------------------------+
|
|
| ts | prom_rate(ts_range,val,ts) |
|
|
+---------------------+----------------------------+
|
|
| 1970-01-01T00:47:00 | 0.996 |
|
|
+---------------------+----------------------------+
|
|
|
|
tql eval (2820, 2820, '1s') histogram_quantile(0.5, rate(histogram2_bucket[15m]));
|
|
|
|
+---------------------+----------------------------+
|
|
| ts | prom_rate(ts_range,val,ts) |
|
|
+---------------------+----------------------------+
|
|
| 1970-01-01T00:47:00 | 3.0 |
|
|
+---------------------+----------------------------+
|
|
|
|
tql eval (2820, 2820, '1s') histogram_quantile(0.833, rate(histogram2_bucket[15m]));
|
|
|
|
+---------------------+----------------------------+
|
|
| ts | prom_rate(ts_range,val,ts) |
|
|
+---------------------+----------------------------+
|
|
| 1970-01-01T00:47:00 | 4.998 |
|
|
+---------------------+----------------------------+
|
|
|
|
drop table histogram2_bucket;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- not from Prometheus
|
|
-- makesure the sort expr works as expected
|
|
create table histogram3_bucket (
|
|
ts timestamp time index,
|
|
le string,
|
|
s string,
|
|
val double,
|
|
primary key (s, le),
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into histogram3_bucket values
|
|
(2900000, "0.1", "a", 0),
|
|
(2900000, "1", "a", 0),
|
|
(2900000, "5", "a", 0),
|
|
(2900000, "+Inf", "a", 0),
|
|
(3000000, "0.1", "a", 50),
|
|
(3000000, "1", "a", 70),
|
|
(3000000, "5", "a", 110),
|
|
(3000000, "+Inf", "a", 120),
|
|
(3005000, "0.1", "a", 10),
|
|
(3005000, "1", "a", 20),
|
|
(3005000, "5", "a", 20),
|
|
(3005000, "+Inf", "a", 30);
|
|
|
|
Affected Rows: 12
|
|
|
|
tql eval (3000, 3005, '3s') histogram_quantile(0.5, sum by(le, s) (rate(histogram3_bucket[5m])));
|
|
|
|
+---+---------------------+---------------------------------+
|
|
| s | ts | sum(prom_rate(ts_range,val,ts)) |
|
|
+---+---------------------+---------------------------------+
|
|
| a | 1970-01-01T00:50:00 | 0.55 |
|
|
| a | 1970-01-01T00:50:03 | 0.5500000000000002 |
|
|
+---+---------------------+---------------------------------+
|
|
|
|
drop table histogram3_bucket;
|
|
|
|
Affected Rows: 0
|
|
|