mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-29 23:16:57 +00:00
* feat!: upgrade DataFusion dependencies to 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * refactor: migrate DataFusion 55 APIs Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve table function planning behavior Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve PostgreSQL query compatibility Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: preserve distributed execution plan behavior Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: cover DataFusion 55 behavior regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: update DataFusion 55 SQLness expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: complete DataFusion 55 test API migration Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: address DataFusion 55 CI regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: address remaining DataFusion 55 regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: adapt latest base code to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: normalize environment-specific DataFusion 55 plans Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: align final DataFusion 55 expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: isolate DataFusion 55 regression cases Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: preserve empty result schema in timestamp widening Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: preserve JSON source column order Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * chore: use released DataFusion 55 integrations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: adapt latest execution plan mock to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: pin DataFusion recursive schema and date repairs Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(promql): align dictionary temporality match keys Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: retain Greptime DataFusion fork behaviors on version 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore ordinary function error expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh distributed count compatibility plan Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): adapt last-row cast hint to DataFusion 55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh instant last-row empty results for Arrow 59 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * style: simplify DataFusion expression visitor imports Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore sorting and PostgreSQL column-order assertions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(function): restore primitive numeric coercion signatures Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * refactor(function): share geo integer signature types Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: cover timestamp widening overflow boundaries Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: fix decimal coercion regression imports Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(function): preserve scalar count_hash NULL state semantics Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: simplify decimal clamp case type inference Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: retain historical count_hash wrapper result Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: restore timestamp widening equality and IN pruning Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: carry upstream aggregate dynamic filter correctness fix Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: carry upstream null and predicate simplification fixes Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore baseline JSON ordering expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: restore histogram JSON ordering expectations Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh empty PromQL range result schemas Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: align native timestamp plan with DF55 decimal display Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: refresh native timestamp SQLness results for DF55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: regenerate NULL sample empty result headers for DF55 Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: use DF55 child replacement API in timestamp regressions Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: expose pushed scan dynamic filters to DF55 producers Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: encode string-backed PostgreSQL OID aliases in binary results Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: verify REGPROC binary and text over PostgreSQL protocol Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: register real PostgreSQL catalogs in server fixtures Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: complete DF55 expression inventories for custom query plans Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: correct RangeSelect expression fixture and column identities Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * ci: wait for Kafka WAL helper deployment rollout Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test: update custom storage empty result headers Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: require exact row counts in scan statistics Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix: suppress deprecated partition_statistics warning in test Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --------- Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> Co-authored-by: Ning Sun <sunng@protonmail.com>
152 lines
5.7 KiB
Rust
152 lines
5.7 KiB
Rust
// Copyright 2023 Greptime Team
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
use client::OutputData;
|
|
use common_recordbatch::util::collect_batches;
|
|
use common_test_util::recordbatch::check_output_stream;
|
|
use common_wal::config::{DatanodeWalConfig, MetasrvWalConfig};
|
|
|
|
use crate::cluster::GreptimeDbClusterBuilder;
|
|
use crate::test_util::execute_sql;
|
|
use crate::tests::test_util::{MockInstanceBuilder, RebuildableMockInstance, TestContext};
|
|
|
|
pub(crate) async fn distributed_with_noop_wal() -> TestContext {
|
|
common_telemetry::init_default_ut_logging();
|
|
let test_name = uuid::Uuid::new_v4().to_string();
|
|
let builder = GreptimeDbClusterBuilder::new(&test_name)
|
|
.await
|
|
.with_datanode_wal_config(DatanodeWalConfig::Noop)
|
|
.with_metasrv_wal_config(MetasrvWalConfig::RaftEngine);
|
|
TestContext::new(MockInstanceBuilder::Distributed(builder)).await
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_mito_engine() {
|
|
let mut test_context = distributed_with_noop_wal().await;
|
|
let frontend = test_context.frontend();
|
|
let sql = r#"create table demo(
|
|
host STRING,
|
|
cpu DOUBLE,
|
|
memory DOUBLE,
|
|
ts timestamp,
|
|
TIME INDEX(ts)
|
|
)"#;
|
|
|
|
let output = execute_sql(&frontend, sql).await.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(0)));
|
|
|
|
let output = execute_sql(
|
|
&frontend,
|
|
"insert into demo(host, cpu, memory, ts) values ('host1', 1.1, 1024, 1655276557000)",
|
|
)
|
|
.await
|
|
.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(1)));
|
|
|
|
let output = execute_sql(&frontend, "select * from demo order by ts")
|
|
.await
|
|
.data;
|
|
let expected = r#"+-------+-----+--------+---------------------+
|
|
| host | cpu | memory | ts |
|
|
+-------+-----+--------+---------------------+
|
|
| host1 | 1.1 | 1024.0 | 2022-06-15T07:02:37 |
|
|
+-------+-----+--------+---------------------+"#;
|
|
check_output_stream(output, expected).await;
|
|
|
|
test_context.rebuild().await;
|
|
let frontend = test_context.frontend();
|
|
let output = execute_sql(&frontend, "select * from demo order by ts")
|
|
.await
|
|
.data;
|
|
// Unflushed data should be lost.
|
|
let expected = r#"+------+-----+--------+----+
|
|
| host | cpu | memory | ts |
|
|
+------+-----+--------+----+
|
|
+------+-----+--------+----+"#;
|
|
check_output_stream(output, expected).await;
|
|
|
|
let output = execute_sql(
|
|
&frontend,
|
|
"insert into demo(host, cpu, memory, ts) values ('host1', 1.1, 1024, 1655276557000)",
|
|
)
|
|
.await
|
|
.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(1)));
|
|
execute_sql(&frontend, "admin flush_table('demo')").await;
|
|
|
|
test_context.rebuild().await;
|
|
let frontend = test_context.frontend();
|
|
let output = execute_sql(&frontend, "select * from demo order by ts")
|
|
.await
|
|
.data;
|
|
let expected = r#"+-------+-----+--------+---------------------+
|
|
| host | cpu | memory | ts |
|
|
+-------+-----+--------+---------------------+
|
|
| host1 | 1.1 | 1024.0 | 2022-06-15T07:02:37 |
|
|
+-------+-----+--------+---------------------+"#;
|
|
check_output_stream(output, expected).await;
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_metric_engine() {
|
|
let mut test_context = distributed_with_noop_wal().await;
|
|
let frontend = test_context.frontend();
|
|
|
|
let sql = r#"CREATE TABLE phy (ts timestamp time index, val double) engine=metric with ("physical_metric_table" = "");"#;
|
|
let output = execute_sql(&frontend, sql).await.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(0)));
|
|
|
|
let sql = r#"CREATE TABLE t1 (ts timestamp time index, val double, host string primary key) engine = metric with ("on_physical_table" = "phy");"#;
|
|
let output = execute_sql(&frontend, sql).await.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(0)));
|
|
|
|
// The logical table should be lost.
|
|
test_context.rebuild().await;
|
|
let frontend = test_context.frontend();
|
|
let output = execute_sql(&frontend, "select * from t1").await;
|
|
let err = unwrap_err(output.data).await;
|
|
// Should returns region not found error.
|
|
assert!(err.contains("not found"));
|
|
|
|
let sql = r#"CREATE TABLE t2 (ts timestamp time index, job string primary key, val double) engine = metric with ("on_physical_table" = "phy");"#;
|
|
let output = execute_sql(&frontend, sql).await.data;
|
|
assert!(matches!(output, OutputData::AffectedRows(0)));
|
|
|
|
execute_sql(
|
|
&frontend,
|
|
"INSERT INTO t2 VALUES ('job1', 0, 0), ('job2', 1, 1);",
|
|
)
|
|
.await;
|
|
execute_sql(&frontend, "admin flush_table('phy')").await;
|
|
|
|
test_context.rebuild().await;
|
|
let frontend = test_context.frontend();
|
|
let output = execute_sql(&frontend, "select * from t2 order by job").await;
|
|
let expected = r#"+------+-------------------------+-----+
|
|
| job | ts | val |
|
|
+------+-------------------------+-----+
|
|
| job1 | 1970-01-01T00:00:00 | 0.0 |
|
|
| job2 | 1970-01-01T00:00:00.001 | 1.0 |
|
|
+------+-------------------------+-----+"#;
|
|
check_output_stream(output.data, expected).await;
|
|
}
|
|
|
|
async fn unwrap_err(output: OutputData) -> String {
|
|
let error = match output {
|
|
OutputData::Stream(stream) => collect_batches(stream).await.unwrap_err(),
|
|
_ => unreachable!(),
|
|
};
|
|
format!("{error:?}")
|
|
}
|