* feat(promql): answer __field__ selectors and same-metric `or` groups natively
Let the native route plan three shapes it used to hand back:
- `__field__` selection (`m{__field__="f"}`) on mito raw scans, metric
logical scans and file-engine row sources: the scan is narrowed to the
selected fields (`field_first_projection`) so `RawSeriesSource` still
sees exactly the canonical frame, text columns are refused as value
kinds, and a matcher naming a column the selection drops is refused
(`row_matchers_need_a_dropped_column`) instead of degrading to a
literal `"" = …` that silently answers nothing.
- `or` groups within one metric (`m{host="a" or host="b"}`) as one scan
with one `Filter`: `AlternativeFilters` merges the groups' conjuncts,
groups that select different fields or tables are refused, and
`discovers_metric_name` learns the alternative groups so the
authorization layer and the planner agree on what a selector
discovers.
- A scalar operand in a composed binary (`(hist * on(job) floats) * 2`):
`native_scalar_operand` binds a scalar side that the composed path
previously required to be a frame.
`field_columns_selected_by` is extracted in `planner.rs` so the legacy
and native routes select the same columns; as a side effect the legacy
route's value-column order for a multi-field `__field__` selection goes
from HashSet order to table order.
Signed-off-by: discord9 <discord9@163.com>
* refactor(promql): share the scalar-binary binder and refuse a histogram over a dynamic scalar
- Fold the composed path's `bind_evaluated_broadcast` into a single
`bind_scalar_binary` shared with `binary_operation`'s scalar tail;
both carry the same modifier refusal and `broadcast(...)` call.
- In `try_plan_native_composed_binary`, decline a histogram frame met
by a *dynamic* scalar (`(hist * on(job) floats) / time()`) with
`histogram_over_a_dynamic_scalar`: the runtime refuses non-float
samples on that branch instead of dropping them. A constant scalar
(`* 2`) keeps planning natively. The refusal can go once the
histogram-aware dynamic kernel lands separately.
- Adapt the tests to the rebased base (#10701): a decline is now an
error carrying its cause, so the `plan_or_refusal` sites assert
`native_decline_reason(..)` and the integration rows that used to
unwrap a declined output assert the cause.
Signed-off-by: discord9 <discord9@163.com>
* refactor(promql): say a refusal is an error and drop the dead pre-or matcher loop
Review follow-ups:
- `histogram_over_a_dynamic_scalar` refused because the dynamic-scalar
kernel on main errors on a non-float sample (#10812), not because
Prometheus lacks a per-point histogram scale — it has one (`h / time()`).
Comment and the three test docs now say so and reference #10812.
- Since #10701 a decline is a planning error with its cause; nothing
falls back to the existing plan. Reword the doc comments and test
docs that still described a fallback.
- `native_promql_or_matchers_narrow_the_scan` asserted the existing
plan's rows for `{host="a" or host="b"}`, which answers `c`: the
parser moves the pre-`or` matchers into the first group and
`matchers_to_expr` reads `matchers.matchers` only, so the existing
plan applies none of them. That is the existing plan's bug, filed
separately; the test no longer states it as an expectation and keeps
only the route check.
- `AlternativeFilters::of_selector` looped over `selector.matchers.matchers`
before the group loop; with any `or` that list is empty, and if it
were not the loop would silently drop every non-selection matcher.
Removed.
Signed-off-by: discord9 <discord9@163.com>
---------
Signed-off-by: discord9 <discord9@163.com>
Setup tests for multiple storage backend
To run the integration test, please copy .env.example to .env in the project root folder and change the values on need.
Take s3 for example. You need to set your S3 bucket, access key id and secret key:
# Settings for s3 test
GT_S3_BUCKET=S3 bucket
GT_S3_REGION=S3 region
GT_S3_ACCESS_KEY_ID=S3 access key id
GT_S3_ACCESS_KEY=S3 secret access key
Run
Execute the following command in the project root folder:
cargo test integration
Test s3 storage:
cargo test s3
Test oss storage:
cargo test oss
Test azblob storage:
cargo test azblob
Setup tests with Kafka wal
To run the integration test, please copy .env.example to .env in the project root folder and change the values on need.
GT_KAFKA_ENDPOINTS = localhost:9092
Setup kafka standalone
cd tests-integration/fixtures
docker compose -f docker-compose.yml up kafka
Setup tests with etcd TLS
This guide explains how to set up and test TLS-enabled etcd connections in GreptimeDB integration tests.
Quick Start
TLS certificates are already at tests-integration/fixtures/etcd-tls-certs/.
-
Start TLS-enabled etcd:
cd tests-integration/fixtures docker compose up etcd-tls -d -
Start all services (including etcd-tls):
cd tests-integration/fixtures docker compose up -d --wait
Certificate Details
The checked-in certificates include:
ca.crt- Certificate Authority certificateserver.crt/server-key.pem- Server certificate for etcd-tls serviceclient.crt/client-key.pem- Client certificate for connecting to etcd-tls
The server certificate includes SANs for localhost, etcd-tls, 127.0.0.1, and ::1.
Regenerating Certificates (Optional)
If you need to regenerate the etcd certificates:
# Regenerate certificates (overwrites existing ones)
./scripts/generate-etcd-tls-certs.sh
# Or generate in custom location
./scripts/generate-etcd-tls-certs.sh /path/to/cert/directory
If you need to regenerate the mysql and postgres certificates:
# Regenerate certificates (overwrites existing ones)
./scripts/generate_certs.sh
# Or generate in custom location
./scripts/generate_certs.sh /path/to/cert/directory
Note: The checked-in certificates are for testing purposes only and should never be used in production.