feat: integration test (#770)

* feat: add insert test cases

* fix: update results after rebase develop

* feat: supports unsigned integer types and big_insert test

* test: add insert_invalid test

* feat: supports time index constraint for bigint type

* chore: time index column at last

* test: adds more order, limit test

* fix: style

* feat: adds numbers table in standable memory catalog mode

* feat: enable fail_fast and test_filter in sqlness

* feat: add more tests

* fix: test_filter

* test: add alter tests

* feat: supports if_not_exists when create database

* test: filter_push_down and catalog test

* fix: compile error

* fix: delete output file

* chore: ignore integration test output in git

* test: update all integration test results

* fix: by code review

* chore: revert .gitignore

* feat: sort the show tables/databases results

* chore: remove issue link

* fix: compile error and code format after rebase

* test: update all integration test results
This commit is contained in:
dennis zhuang
2023-01-10 18:15:50 +08:00
committed by GitHub
parent 32d51947a4
commit 9428e70971
63 changed files with 2788 additions and 76 deletions

120
Cargo.lock generated
View File

@@ -142,7 +142,7 @@ dependencies = [
"common-error",
"common-time",
"datatypes",
"prost 0.11.3",
"prost 0.11.5",
"snafu",
"tonic",
"tonic-build",
@@ -306,9 +306,9 @@ dependencies = [
"bytes",
"futures",
"proc-macro2",
"prost 0.11.3",
"prost 0.11.5",
"prost-build 0.11.3",
"prost-derive 0.11.2",
"prost-derive 0.11.5",
"tokio",
"tonic",
"tonic-build",
@@ -690,7 +690,7 @@ name = "benchmarks"
version = "0.1.0"
dependencies = [
"arrow",
"clap 4.0.29",
"clap 4.0.32",
"client",
"indicatif",
"itertools",
@@ -1246,9 +1246,9 @@ dependencies = [
[[package]]
name = "clap"
version = "4.0.29"
version = "4.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d"
checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39"
dependencies = [
"bitflags",
"clap_derive 4.0.21",
@@ -1323,7 +1323,7 @@ dependencies = [
"enum_dispatch",
"futures-util",
"parking_lot",
"prost 0.11.3",
"prost 0.11.5",
"prost 0.9.0",
"rand 0.8.5",
"snafu",
@@ -1491,7 +1491,7 @@ dependencies = [
"datatypes",
"flatbuffers",
"futures",
"prost 0.11.3",
"prost 0.11.5",
"rand 0.8.5",
"snafu",
"tokio",
@@ -1626,8 +1626,8 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e57ff02e8ad8e06ab9731d5dc72dc23bef9200778eae1a89d555d8c42e5d4a86"
dependencies = [
"prost 0.11.3",
"prost-types 0.11.2",
"prost 0.11.5",
"prost-types 0.11.5",
"tonic",
"tracing-core",
]
@@ -1644,7 +1644,7 @@ dependencies = [
"futures",
"hdrhistogram",
"humantime",
"prost-types 0.11.2",
"prost-types 0.11.5",
"serde",
"serde_json",
"thread_local",
@@ -2180,7 +2180,7 @@ dependencies = [
"mito",
"object-store",
"pin-project",
"prost 0.11.3",
"prost 0.11.5",
"query",
"script",
"serde",
@@ -2483,7 +2483,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1259da3b15ec7e54bd7203adb2c4335adb9ca1d47b56220d650e52c247e824a"
dependencies = [
"http",
"prost 0.11.3",
"prost 0.11.5",
"tokio",
"tokio-stream",
"tonic",
@@ -2642,7 +2642,7 @@ dependencies = [
"meta-srv",
"moka",
"openmetrics-parser",
"prost 0.11.3",
"prost 0.11.5",
"query",
"rustls",
"serde",
@@ -3300,9 +3300,9 @@ dependencies = [
[[package]]
name = "is-terminal"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330"
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
dependencies = [
"hermit-abi 0.2.6",
"io-lifetimes",
@@ -3491,9 +3491,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.138"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "libloading"
@@ -3834,7 +3834,7 @@ dependencies = [
"http-body",
"lazy_static",
"parking_lot",
"prost 0.11.3",
"prost 0.11.5",
"regex",
"serde",
"serde_json",
@@ -4306,11 +4306,11 @@ dependencies = [
[[package]]
name = "num_cpus"
version = "1.14.0"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
dependencies = [
"hermit-abi 0.1.19",
"hermit-abi 0.2.6",
"libc",
]
@@ -4700,9 +4700,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pest"
version = "2.5.1"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc8bed3549e0f9b0a2a78bf7c0018237a2cdf085eecbbc048e52612438e4e9d0"
checksum = "0f6e86fb9e7026527a0d46bc308b841d73170ef8f443e1807f6ef88526a816d4"
dependencies = [
"thiserror",
"ucd-trie",
@@ -4710,9 +4710,9 @@ dependencies = [
[[package]]
name = "pest_derive"
version = "2.5.1"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc078600d06ff90d4ed238f0119d84ab5d43dbaad278b0e33a8820293b32344"
checksum = "96504449aa860c8dcde14f9fba5c58dc6658688ca1fe363589d6327b8662c603"
dependencies = [
"pest",
"pest_generator",
@@ -4720,9 +4720,9 @@ dependencies = [
[[package]]
name = "pest_generator"
version = "2.5.1"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28a1af60b1c4148bb269006a750cff8e2ea36aff34d2d96cf7be0b14d1bed23c"
checksum = "798e0220d1111ae63d66cb66a5dcb3fc2d986d520b98e49e1852bfdb11d7c5e7"
dependencies = [
"pest",
"pest_meta",
@@ -4733,9 +4733,9 @@ dependencies = [
[[package]]
name = "pest_meta"
version = "2.5.1"
version = "2.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fec8605d59fc2ae0c6c1aefc0c7c7a9769732017c0ce07f7a9cfffa7b4404f20"
checksum = "984298b75898e30a843e278a9f2452c31e349a073a0ce6fd950a12a74464e065"
dependencies = [
"once_cell",
"pest",
@@ -4960,9 +4960,9 @@ dependencies = [
[[package]]
name = "portable-atomic"
version = "0.3.18"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81bdd679d533107e090c2704a35982fc06302e30898e63ffa26a81155c012e92"
checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b"
[[package]]
name = "postgres-protocol"
@@ -5096,9 +5096,9 @@ dependencies = [
[[package]]
name = "proc-macro-hack"
version = "0.5.19"
version = "0.5.20+deprecated"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
[[package]]
name = "proc-macro2"
@@ -5179,12 +5179,12 @@ dependencies = [
[[package]]
name = "prost"
version = "0.11.3"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b18e655c21ff5ac2084a5ad0611e827b3f92badf79f4910b5a5c58f4d87ff0"
checksum = "c01db6702aa05baa3f57dec92b8eeeeb4cb19e894e73996b32a4093289e54592"
dependencies = [
"bytes",
"prost-derive 0.11.2",
"prost-derive 0.11.5",
]
[[package]]
@@ -5221,8 +5221,8 @@ dependencies = [
"multimap",
"petgraph",
"prettyplease",
"prost 0.11.3",
"prost-types 0.11.2",
"prost 0.11.5",
"prost-types 0.11.5",
"regex",
"syn",
"tempfile",
@@ -5244,9 +5244,9 @@ dependencies = [
[[package]]
name = "prost-derive"
version = "0.11.2"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "164ae68b6587001ca506d3bf7f1000bfa248d0e1217b618108fba4ec1d0cc306"
checksum = "c8842bad1a5419bca14eac663ba798f6bc19c413c2fdceb5f3ba3b0932d96720"
dependencies = [
"anyhow",
"itertools",
@@ -5267,12 +5267,12 @@ dependencies = [
[[package]]
name = "prost-types"
version = "0.11.2"
version = "0.11.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "747761bc3dc48f9a34553bf65605cf6cb6288ba219f3450b4275dbd81539551a"
checksum = "017f79637768cde62820bc2d4fe0e45daaa027755c323ad077767c6c5f173091"
dependencies = [
"bytes",
"prost 0.11.3",
"prost 0.11.5",
]
[[package]]
@@ -5882,9 +5882,9 @@ dependencies = [
[[package]]
name = "rustix"
version = "0.36.5"
version = "0.36.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
checksum = "4feacf7db682c6c329c4ede12649cd36ecab0f3be5b7d74e6a20304725db4549"
dependencies = [
"bitflags",
"errno",
@@ -6497,9 +6497,9 @@ checksum = "1685deded9b272198423bdbdb907d8519def2f26cf3699040e54e8c4fbd5c5ce"
[[package]]
name = "serde"
version = "1.0.151"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0"
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
dependencies = [
"serde_derive",
]
@@ -6516,9 +6516,9 @@ dependencies = [
[[package]]
name = "serde_derive"
version = "1.0.151"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8"
checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
dependencies = [
"proc-macro2",
"quote",
@@ -6619,7 +6619,7 @@ dependencies = [
"opensrv-mysql",
"pgwire",
"pin-project",
"prost 0.11.3",
"prost 0.11.5",
"query",
"rand 0.8.5",
"regex",
@@ -6802,9 +6802,9 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "snafu"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a152ba99b054b22972ee794cf04e5ef572da1229e33b65f3c57abbff0525a454"
checksum = "cb0656e7e3ffb70f6c39b3c2a86332bb74aa3c679da781642590f3c1118c5045"
dependencies = [
"backtrace",
"doc-comment",
@@ -6813,9 +6813,9 @@ dependencies = [
[[package]]
name = "snafu-derive"
version = "0.7.3"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5e79cdebbabaebb06a9bdbaedc7f159b410461f63611d4d0e3fb0fab8fed850"
checksum = "475b3bbe5245c26f2d8a6f62d67c1f30eb9fffeccee721c45d162c3ebbdf81b2"
dependencies = [
"heck 0.4.0",
"proc-macro2",
@@ -6982,7 +6982,7 @@ dependencies = [
"parquet",
"paste",
"planus",
"prost 0.11.3",
"prost 0.11.5",
"rand 0.8.5",
"regex",
"serde",
@@ -7689,8 +7689,8 @@ dependencies = [
"hyper-timeout",
"percent-encoding",
"pin-project",
"prost 0.11.3",
"prost-derive 0.11.2",
"prost 0.11.5",
"prost-derive 0.11.5",
"tokio",
"tokio-stream",
"tokio-util",
@@ -8216,9 +8216,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "vergen"
version = "7.4.3"
version = "7.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447f9238a4553957277b3ee09d80babeae0811f1b3baefb093de1c0448437a37"
checksum = "efadd36bc6fde40c6048443897d69511a19161c0756cb704ed403f8dfd2b7d1c"
dependencies = [
"anyhow",
"cfg-if 1.0.0",

View File

@@ -50,6 +50,7 @@ message DropTableExpr {
message CreateDatabaseExpr {
//TODO(hl): maybe rename to schema_name?
string database_name = 1;
bool create_if_not_exists = 2;
}
message AddColumns {

View File

@@ -199,6 +199,9 @@ pub enum Error {
source: catalog::error::Error,
},
#[snafu(display("Schema already exists, name: {}", name))]
SchemaExists { name: String, backtrace: Backtrace },
#[snafu(display("Failed to convert alter expr to request: {}", source))]
AlterExprToRequest {
#[snafu(backtrace)]
@@ -324,6 +327,7 @@ impl ErrorExt for Error {
| Error::CatalogNotFound { .. }
| Error::SchemaNotFound { .. }
| Error::ConstraintNotSupported { .. }
| Error::SchemaExists { .. }
| Error::ParseTimestamp { .. } => StatusCode::InvalidArguments,
// TODO(yingwen): Further categorize http error.

View File

@@ -18,7 +18,8 @@ use std::{fs, path};
use backon::ExponentialBackoff;
use catalog::remote::MetaKvBackend;
use catalog::CatalogManagerRef;
use catalog::{CatalogManager, CatalogManagerRef, RegisterTableRequest};
use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, MIN_USER_TABLE_ID};
use common_grpc::channel_manager::{ChannelConfig, ChannelManager};
use common_telemetry::logging::info;
use log_store::raft_engine::log_store::RaftEngineLogStore;
@@ -36,7 +37,9 @@ use servers::Mode;
use snafu::prelude::*;
use storage::config::EngineConfig as StorageEngineConfig;
use storage::EngineImpl;
use table::table::numbers::NumbersTable;
use table::table::TableIdProviderRef;
use table::Table;
use crate::datanode::{DatanodeOptions, ObjectStoreConfig, WalConfig};
use crate::error::{
@@ -99,6 +102,19 @@ impl Instance {
Mode::Standalone => {
if opts.enable_memory_catalog {
let catalog = Arc::new(catalog::local::MemoryCatalogManager::default());
let table = NumbersTable::new(MIN_USER_TABLE_ID);
catalog
.register_table(RegisterTableRequest {
table_id: MIN_USER_TABLE_ID,
table_name: table.table_info().name.to_string(),
table: Arc::new(table),
catalog: DEFAULT_CATALOG_NAME.to_string(),
schema: DEFAULT_SCHEMA_NAME.to_string(),
})
.await
.expect("Failed to register numbers");
let factory = QueryEngineFactory::new(catalog.clone());
(

View File

@@ -35,6 +35,7 @@ impl Instance {
pub(crate) async fn handle_create_database(&self, expr: CreateDatabaseExpr) -> Result<Output> {
let req = CreateDatabaseRequest {
db_name: expr.database_name,
create_if_not_exists: expr.create_if_not_exists,
};
self.sql_handler().create_database(req).await
}
@@ -143,6 +144,7 @@ mod test {
request: Some(GrpcRequest::Ddl(DdlRequest {
expr: Some(DdlExpr::CreateDatabase(CreateDatabaseExpr {
database_name: "my_database".to_string(),
create_if_not_exists: true,
})),
})),
};

View File

@@ -66,6 +66,7 @@ impl Instance {
QueryStatement::Sql(Statement::CreateDatabase(c)) => {
let request = CreateDatabaseRequest {
db_name: c.name.to_string(),
create_if_not_exists: c.if_not_exists,
};
info!("Creating a new database: {}", request.db_name);

View File

@@ -33,22 +33,30 @@ use table::requests::*;
use crate::error::{
self, CatalogNotFoundSnafu, CatalogSnafu, ConstraintNotSupportedSnafu, CreateSchemaSnafu,
CreateTableSnafu, InsertSystemCatalogSnafu, InvalidPrimaryKeySnafu, KeyColumnNotFoundSnafu,
RegisterSchemaSnafu, Result, SchemaNotFoundSnafu,
RegisterSchemaSnafu, Result, SchemaExistsSnafu, SchemaNotFoundSnafu,
};
use crate::sql::SqlHandler;
impl SqlHandler {
pub(crate) async fn create_database(&self, req: CreateDatabaseRequest) -> Result<Output> {
let schema = req.db_name;
let req = RegisterSchemaRequest {
let reg_req = RegisterSchemaRequest {
catalog: DEFAULT_CATALOG_NAME.to_string(),
schema: schema.clone(),
};
self.catalog_manager
.register_schema(req)
let success = self
.catalog_manager
.register_schema(reg_req)
.await
.context(RegisterSchemaSnafu)?;
// FIXME(dennis): looks like register_schema always returns true even
// even when the schema already exists.
ensure!(
success || req.create_if_not_exists,
SchemaExistsSnafu { name: schema }
);
info!("Successfully created database: {:?}", schema);
Ok(Output::AffectedRows(1))
}

View File

@@ -158,6 +158,7 @@ impl DistInstance {
Statement::CreateDatabase(stmt) => {
let expr = CreateDatabaseExpr {
database_name: stmt.name.to_string(),
create_if_not_exists: stmt.if_not_exists,
};
Ok(self.handle_create_database(expr).await?)
}

View File

@@ -112,6 +112,7 @@ mod test {
request: Some(Request::Ddl(DdlRequest {
expr: Some(DdlExpr::CreateDatabase(CreateDatabaseExpr {
database_name: "database_created_through_grpc".to_string(),
create_if_not_exists: true,
})),
})),
};
@@ -219,8 +220,8 @@ mod test {
let sql = format!(
r"
CREATE TABLE {table_name} (
a INT,
ts TIMESTAMP,
a INT,
ts TIMESTAMP,
TIME INDEX (ts)
) PARTITION BY RANGE COLUMNS(a) (
PARTITION r0 VALUES LESS THAN (10),

View File

@@ -184,7 +184,7 @@ mod tests {
assert!(SqlQueryHandler::do_query(
instance.as_ref(),
"CREATE DATABASE prometheus",
"CREATE DATABASE IF NOT EXISTS prometheus",
QueryContext::arc()
)
.await

View File

@@ -93,7 +93,9 @@ pub fn show_databases(stmt: ShowDatabases, catalog_manager: CatalogManagerRef) -
.context(error::CatalogNotFoundSnafu {
catalog: DEFAULT_CATALOG_NAME,
})?;
let databases = catalog.schema_names().context(error::CatalogSnafu)?;
let mut databases = catalog.schema_names().context(error::CatalogSnafu)?;
// TODO(dennis): Specify the order of the results in catalog manager API
databases.sort();
let databases = if let ShowKind::Like(ident) = stmt.kind {
Helper::like_utf8(databases, &ident.value).context(error::VectorComputationSnafu)?
@@ -138,7 +140,9 @@ pub fn show_tables(
.schema(catalog, &schema)
.context(error::CatalogSnafu)?
.context(error::SchemaNotFoundSnafu { schema })?;
let tables = schema.table_names().context(error::CatalogSnafu)?;
let mut tables = schema.table_names().context(error::CatalogSnafu)?;
// TODO(dennis): Specify the order of the results in schema provider API
tables.sort();
let tables = if let ShowKind::Like(ident) = stmt.kind {
Helper::like_utf8(tables, &ident.value).context(error::VectorComputationSnafu)?

View File

@@ -46,7 +46,7 @@ impl<'a> ParserContext<'a> {
Token::Word(w) => match w.keyword {
Keyword::TABLE => self.parse_create_table(),
Keyword::DATABASE => self.parse_create_database(),
Keyword::SCHEMA | Keyword::DATABASE => self.parse_create_database(),
_ => self.unsupported(w.to_string()),
},
@@ -57,6 +57,10 @@ impl<'a> ParserContext<'a> {
fn parse_create_database(&mut self) -> Result<Statement> {
self.parser.next_token();
let if_not_exists =
self.parser
.parse_keywords(&[Keyword::IF, Keyword::NOT, Keyword::EXISTS]);
let database_name = self
.parser
.parse_object_name()
@@ -68,6 +72,7 @@ impl<'a> ParserContext<'a> {
Ok(Statement::CreateDatabase(CreateDatabase {
name: database_name,
if_not_exists,
}))
}
@@ -253,8 +258,10 @@ impl<'a> ParserContext<'a> {
.parse_column_def()
.context(SyntaxSnafu { sql: self.sql })?;
if !matches!(column.data_type, DataType::Timestamp(_, _))
|| matches!(self.parser.peek_token(), Token::Comma)
if !matches!(
column.data_type,
DataType::Timestamp(_, _) | DataType::BigInt(_)
) || matches!(self.parser.peek_token(), Token::Comma)
{
columns.push(column);
return Ok(());
@@ -290,6 +297,7 @@ impl<'a> ParserContext<'a> {
is_primary: false,
};
// TIME INDEX option means NOT NULL implicitly.
column.options = vec![ColumnOptionDef {
name: None,
option: NotNull,
@@ -297,7 +305,7 @@ impl<'a> ParserContext<'a> {
columns.push(column);
constraints.push(constraint);
if let Token::Comma = self.parser.peek_token() {
if matches!(self.parser.peek_token(), Token::Comma | Token::RParen) {
return Ok(());
}
@@ -580,6 +588,19 @@ mod tests {
match &stmts[0] {
Statement::CreateDatabase(c) => {
assert_eq!(c.name.to_string(), "prometheus");
assert!(!c.if_not_exists);
}
_ => unreachable!(),
}
let sql = "create database if not exists prometheus";
let stmts = ParserContext::create_with_dialect(sql, &GenericDialect {}).unwrap();
assert_eq!(1, stmts.len());
match &stmts[0] {
Statement::CreateDatabase(c) => {
assert_eq!(c.name.to_string(), "prometheus");
assert!(c.if_not_exists);
}
_ => unreachable!(),
}
@@ -838,6 +859,39 @@ ENGINE=mito";
let result3 = ParserContext::create_with_dialect(sql3, &GenericDialect {}).unwrap();
assert_ne!(result1, result3);
// BIGINT as time index
let sql1 = r"
CREATE TABLE monitor (
host_id INT,
idc STRING,
b bigint TIME INDEX,
cpu DOUBLE DEFAULT 0,
memory DOUBLE,
PRIMARY KEY (host),
)
ENGINE=mito";
let result1 = ParserContext::create_with_dialect(sql1, &GenericDialect {}).unwrap();
if let Statement::CreateTable(c) = &result1[0] {
assert_eq!(c.constraints.len(), 2);
let tc = c.constraints[0].clone();
match tc {
TableConstraint::Unique {
name,
columns,
is_primary,
} => {
assert_eq!(name.unwrap().to_string(), "__time_index");
assert_eq!(columns.len(), 1);
assert_eq!(&columns[0].value, "b");
assert!(!is_primary);
}
_ => panic!("should be time index constraint"),
};
} else {
panic!("should be create_table statement");
}
}
#[test]

View File

@@ -311,8 +311,15 @@ pub fn sql_column_def_to_grpc_column_def(col: ColumnDef) -> Result<api::v1::Colu
pub fn sql_data_type_to_concrete_data_type(data_type: &SqlDataType) -> Result<ConcreteDataType> {
match data_type {
SqlDataType::BigInt(_) => Ok(ConcreteDataType::int64_datatype()),
SqlDataType::Int(_) => Ok(ConcreteDataType::int32_datatype()),
SqlDataType::UnsignedBigInt(_) => Ok(ConcreteDataType::uint64_datatype()),
SqlDataType::Int(_) | SqlDataType::Integer(_) => Ok(ConcreteDataType::int32_datatype()),
SqlDataType::UnsignedInt(_) | SqlDataType::UnsignedInteger(_) => {
Ok(ConcreteDataType::uint32_datatype())
}
SqlDataType::SmallInt(_) => Ok(ConcreteDataType::int16_datatype()),
SqlDataType::UnsignedSmallInt(_) => Ok(ConcreteDataType::uint16_datatype()),
SqlDataType::TinyInt(_) => Ok(ConcreteDataType::int8_datatype()),
SqlDataType::UnsignedTinyInt(_) => Ok(ConcreteDataType::uint8_datatype()),
SqlDataType::Char(_)
| SqlDataType::Varchar(_)
| SqlDataType::Text
@@ -376,6 +383,10 @@ mod tests {
ConcreteDataType::int64_datatype(),
);
check_type(SqlDataType::Int(None), ConcreteDataType::int32_datatype());
check_type(
SqlDataType::Integer(None),
ConcreteDataType::int32_datatype(),
);
check_type(
SqlDataType::SmallInt(None),
ConcreteDataType::int16_datatype(),
@@ -406,6 +417,22 @@ mod tests {
SqlDataType::Varbinary(None),
ConcreteDataType::binary_datatype(),
);
check_type(
SqlDataType::UnsignedBigInt(None),
ConcreteDataType::uint64_datatype(),
);
check_type(
SqlDataType::UnsignedInt(None),
ConcreteDataType::uint32_datatype(),
);
check_type(
SqlDataType::UnsignedSmallInt(None),
ConcreteDataType::uint16_datatype(),
);
check_type(
SqlDataType::UnsignedTinyInt(None),
ConcreteDataType::uint8_datatype(),
);
}
#[test]

View File

@@ -47,4 +47,6 @@ pub struct PartitionEntry {
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct CreateDatabase {
pub name: ObjectName,
/// Create if not exists
pub if_not_exists: bool,
}

View File

@@ -33,6 +33,7 @@ pub struct InsertRequest {
#[derive(Debug, Clone)]
pub struct CreateDatabaseRequest {
pub db_name: String,
pub create_if_not_exists: bool,
}
/// Create table request

View File

@@ -0,0 +1,75 @@
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (11, 22, 1), (13, 22, 2), (11, 21, 3), (11, 22, 4);
Affected Rows: 4
SELECT DISTINCT a, b FROM test ORDER BY a, b;
+----+----+
| a | b |
+----+----+
| 11 | 21 |
| 11 | 22 |
| 13 | 22 |
+----+----+
SELECT DISTINCT test.a, b FROM test ORDER BY a, b;
+----+----+
| a | b |
+----+----+
| 11 | 21 |
| 11 | 22 |
| 13 | 22 |
+----+----+
SELECT DISTINCT a FROM test ORDER BY a;
+----+
| a |
+----+
| 11 |
| 13 |
+----+
SELECT DISTINCT b FROM test ORDER BY b;
+----+
| b |
+----+
| 21 |
| 22 |
+----+
SELECT DISTINCT a, SUM(B) FROM test GROUP BY a ORDER BY a;
+----+-------------+
| a | SUM(test.b) |
+----+-------------+
| 11 | 65 |
| 13 | 22 |
+----+-------------+
SELECT DISTINCT MAX(b) FROM test GROUP BY a;
+-------------+
| MAX(test.b) |
+-------------+
| 22 |
+-------------+
SELECT DISTINCT CASE WHEN a > 11 THEN 11 ELSE a END FROM test;
+-------------------------------------------------------------+
| CASE WHEN test.a > Int64(11) THEN Int64(11) ELSE test.a END |
+-------------------------------------------------------------+
| 11 |
+-------------------------------------------------------------+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,19 @@
CREATE TABLE test (a INTEGER, b INTEGER, t BIGINT TIME INDEX);
INSERT INTO test VALUES (11, 22, 1), (13, 22, 2), (11, 21, 3), (11, 22, 4);
SELECT DISTINCT a, b FROM test ORDER BY a, b;
SELECT DISTINCT test.a, b FROM test ORDER BY a, b;
SELECT DISTINCT a FROM test ORDER BY a;
SELECT DISTINCT b FROM test ORDER BY b;
SELECT DISTINCT a, SUM(B) FROM test GROUP BY a ORDER BY a;
SELECT DISTINCT MAX(b) FROM test GROUP BY a;
SELECT DISTINCT CASE WHEN a > 11 THEN 11 ELSE a END FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,64 @@
CREATE TABLE integers(i BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO integers VALUES (1), (2), (3);
Affected Rows: 3
SELECT DISTINCT i%2 FROM integers ORDER BY 1;
+-----------------------+
| integers.i % Int64(2) |
+-----------------------+
| 0 |
| 1 |
+-----------------------+
SELECT DISTINCT i % 2 FROM integers WHERE i<3 ORDER BY i;
+-----------------------+
| integers.i % Int64(2) |
+-----------------------+
| 1 |
| 0 |
+-----------------------+
SELECT DISTINCT ON (1) i % 2, i FROM integers WHERE i<3 ORDER BY i;
Error: 1001(Unsupported), SQL statement is not supported: SELECT DISTINCT ON (1) i % 2, i FROM integers WHERE i<3 ORDER BY i;, keyword: %
SELECT DISTINCT integers.i FROM integers ORDER BY i DESC;
+---+
| i |
+---+
| 3 |
| 2 |
| 1 |
+---+
SELECT DISTINCT i FROM integers ORDER BY integers.i DESC;
+---+
| i |
+---+
| 3 |
| 2 |
| 1 |
+---+
SELECT DISTINCT integers.i FROM integers ORDER BY integers.i DESC;
+---+
| i |
+---+
| 3 |
| 2 |
| 1 |
+---+
DROP TABLE integers;
Affected Rows: 1

View File

@@ -0,0 +1,17 @@
CREATE TABLE integers(i BIGINT TIME INDEX);
INSERT INTO integers VALUES (1), (2), (3);
SELECT DISTINCT i%2 FROM integers ORDER BY 1;
SELECT DISTINCT i % 2 FROM integers WHERE i<3 ORDER BY i;
SELECT DISTINCT ON (1) i % 2, i FROM integers WHERE i<3 ORDER BY i;
SELECT DISTINCT integers.i FROM integers ORDER BY i DESC;
SELECT DISTINCT i FROM integers ORDER BY integers.i DESC;
SELECT DISTINCT integers.i FROM integers ORDER BY integers.i DESC;
DROP TABLE integers;

View File

@@ -0,0 +1,80 @@
SELECT SUM(number) FROM numbers;
+---------------------+
| SUM(numbers.number) |
+---------------------+
| 4950 |
+---------------------+
SELECT SUM(1) FROM numbers;
+---------------+
| SUM(Int64(1)) |
+---------------+
| 100 |
+---------------+
SELECT SUM(-1) FROM numbers;
+----------------+
| SUM(Int64(-1)) |
+----------------+
| -100 |
+----------------+
SELECT SUM(-1) FROM numbers WHERE number=-1;
+----------------+
| SUM(Int64(-1)) |
+----------------+
| |
+----------------+
SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000;
+----------------+
| SUM(Int64(-1)) |
+----------------+
| |
+----------------+
CREATE TABLE bigints(b BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1);
Affected Rows: 3
SELECT SUM(b) FROM bigints;
+----------------------+
| SUM(bigints.b) |
+----------------------+
| -9223372036854774807 |
+----------------------+
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO doubles (n, ts) VALUES (9007199254740992, 1), (1, 2), (1, 3), (0, 4);
Affected Rows: 4
SELECT sum(n) from doubles;
+------------------+
| SUM(doubles.n) |
+------------------+
| 9007199254740992 |
+------------------+
DROP TABLE bigints;
Affected Rows: 1
DROP TABLE doubles;
Affected Rows: 1

View File

@@ -0,0 +1,25 @@
SELECT SUM(number) FROM numbers;
SELECT SUM(1) FROM numbers;
SELECT SUM(-1) FROM numbers;
SELECT SUM(-1) FROM numbers WHERE number=-1;
SELECT SUM(-1) FROM numbers WHERE number>10000 limit 1000;
CREATE TABLE bigints(b BIGINT TIME INDEX);
INSERT INTO bigints values (4611686018427387904), (4611686018427388904), (1);
SELECT SUM(b) FROM bigints;
CREATE TABLE doubles(n DOUBLE, ts BIGINT TIME INDEX);
INSERT INTO doubles (n, ts) VALUES (9007199254740992, 1), (1, 2), (1, 3), (0, 4);
SELECT sum(n) from doubles;
DROP TABLE bigints;
DROP TABLE doubles;

View File

@@ -0,0 +1,25 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (1, 1), (2, 2);
Affected Rows: 2
ALTER TABLE test ADD COLUMN k INTEGER;
Affected Rows: 0
SELECT * FROM test;
+---+---+---+
| i | j | k |
+---+---+---+
| 1 | 1 | |
| 2 | 2 | |
+---+---+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,9 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
INSERT INTO test VALUES (1, 1), (2, 2);
ALTER TABLE test ADD COLUMN k INTEGER;
SELECT * FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,38 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (1, 1), (2, 2);
Affected Rows: 2
INSERT INTO test VALUES (3, 3);
Affected Rows: 1
ALTER TABLE test ADD COLUMN k INTEGER;
Affected Rows: 0
ALTER TABLE test ADD COLUMN l INTEGER;
Affected Rows: 0
ALTER TABLE test ADD COLUMN m INTEGER DEFAULT 3;
Affected Rows: 0
SELECT * FROM test;
+---+---+---+---+---+
| i | j | k | l | m |
+---+---+---+---+---+
| 1 | 1 | | | 3 |
| 2 | 2 | | | 3 |
| 3 | 3 | | | 3 |
+---+---+---+---+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,15 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
INSERT INTO test VALUES (1, 1), (2, 2);
INSERT INTO test VALUES (3, 3);
ALTER TABLE test ADD COLUMN k INTEGER;
ALTER TABLE test ADD COLUMN l INTEGER;
ALTER TABLE test ADD COLUMN m INTEGER DEFAULT 3;
SELECT * FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,25 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (1, 1), (2, 2);
Affected Rows: 2
ALTER TABLE test ADD COLUMN k INTEGER DEFAULT 3;
Affected Rows: 0
SELECT * FROM test;
+---+---+---+
| i | j | k |
+---+---+---+
| 1 | 1 | 3 |
| 2 | 2 | 3 |
+---+---+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,9 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
INSERT INTO test VALUES (1, 1), (2, 2);
ALTER TABLE test ADD COLUMN k INTEGER DEFAULT 3;
SELECT * FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,29 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (1, 1), (2, 2);
Affected Rows: 2
ALTER TABLE test DROP COLUMN i;
Affected Rows: 0
SELECT * FROM test;
+---+
| j |
+---+
| 1 |
| 2 |
+---+
ALTER TABLE test DROP COLUMN j;
Error: 1004(InvalidArguments), Not allowed to remove index column j from table test
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,11 @@
CREATE TABLE test(i INTEGER, j BIGINT TIME INDEX);
INSERT INTO test VALUES (1, 1), (2, 2);
ALTER TABLE test DROP COLUMN i;
SELECT * FROM test;
ALTER TABLE test DROP COLUMN j;
DROP TABLE test;

View File

@@ -0,0 +1,39 @@
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER NOT NULL);
Affected Rows: 0
INSERT INTO test VALUES (1, 1), (2, 2);
Affected Rows: 2
SELECT * FROM test;
+---+---+
| i | j |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
ALTER TABLE test DROP COLUMN j;
Affected Rows: 0
INSERT INTO test VALUES (3);
Affected Rows: 1
SELECT * FROM test;
+---+
| i |
+---+
| 1 |
| 2 |
| 3 |
+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,13 @@
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER NOT NULL);
INSERT INTO test VALUES (1, 1), (2, 2);
SELECT * FROM test;
ALTER TABLE test DROP COLUMN j;
INSERT INTO test VALUES (3);
SELECT * FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,43 @@
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER, k INTEGER NOT NULL);
Affected Rows: 0
INSERT INTO test VALUES (1, 1, 11), (2, 2, 12);
Affected Rows: 2
SELECT * FROM test;
+---+---+----+
| i | j | k |
+---+---+----+
| 1 | 1 | 11 |
| 2 | 2 | 12 |
+---+---+----+
ALTER TABLE test DROP COLUMN j;
Affected Rows: 0
INSERT INTO test VALUES (3, NULL);
Error: 1004(InvalidArguments), Column k is not null but input has null
INSERT INTO test VALUES (3, 13);
Affected Rows: 1
SELECT * FROM test;
+---+----+
| i | k |
+---+----+
| 1 | 11 |
| 2 | 12 |
| 3 | 13 |
+---+----+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,15 @@
CREATE TABLE test(i BIGINT TIME INDEX, j INTEGER, k INTEGER NOT NULL);
INSERT INTO test VALUES (1, 1, 11), (2, 2, 12);
SELECT * FROM test;
ALTER TABLE test DROP COLUMN j;
INSERT INTO test VALUES (3, NULL);
INSERT INTO test VALUES (3, 13);
SELECT * FROM test;
DROP TABLE test;

View File

@@ -0,0 +1,75 @@
CREATE SCHEMA test;
Affected Rows: 1
SHOW DATABASES;
+---------+
| Schemas |
+---------+
| public |
| test |
+---------+
CREATE TABLE test.hello(i BIGINT TIME INDEX);
Affected Rows: 0
DROP TABLE test.hello;
Affected Rows: 1
DROP SCHEMA test;
Error: 1001(Unsupported), SQL statement is not supported: DROP SCHEMA test;, keyword: SCHEMA
CREATE SCHEMA test;
Affected Rows: 1
CREATE TABLE test.hello(i BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test.hello VALUES (2), (3), (4);
Affected Rows: 3
SELECT * FROM test.hello;
+---+
| i |
+---+
| 2 |
| 3 |
| 4 |
+---+
SHOW TABLES;
+---------+
| Tables |
+---------+
| numbers |
+---------+
SHOW TABLES FROM test;
+--------+
| Tables |
+--------+
| hello |
+--------+
DROP TABLE test.hello;
Affected Rows: 1
DROP SCHEMA test;
Error: 1001(Unsupported), SQL statement is not supported: DROP SCHEMA test;, keyword: SCHEMA
SELECT * FROM test.hello;
Error: 3000(PlanQuery), Error during planning: table 'greptime.test.hello' not found

View File

@@ -0,0 +1,27 @@
CREATE SCHEMA test;
SHOW DATABASES;
CREATE TABLE test.hello(i BIGINT TIME INDEX);
DROP TABLE test.hello;
DROP SCHEMA test;
CREATE SCHEMA test;
CREATE TABLE test.hello(i BIGINT TIME INDEX);
INSERT INTO test.hello VALUES (2), (3), (4);
SELECT * FROM test.hello;
SHOW TABLES;
SHOW TABLES FROM test;
DROP TABLE test.hello;
DROP SCHEMA test;
SELECT * FROM test.hello;

View File

@@ -0,0 +1,66 @@
CREATE TABLE integers (i BIGINT);
Error: 2000(InvalidSyntax), sql parser error: Expected TIME, found: )
CREATE TABLE integers (i BIGINT TIME INDEX);
Affected Rows: 0
CREATE TABLE IF NOT EXISTS integers (i BIGINT TIME INDEX);
Affected Rows: 0
CREATE TABLE test1 (i INTEGER, j INTEGER);
Error: 1004(InvalidArguments), Missing timestamp column in request
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX NOT NULL);
Affected Rows: 0
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX NULL);
Error: 2000(InvalidSyntax), sql parser error: Expected NOT, found: NULL
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
DESC TABLE integers;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DESC TABLE test1;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | VALUE |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DESC TABLE test2;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | VALUE |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
DROP TABLE integers;
Affected Rows: 1
DROP TABLE test1;
Affected Rows: 1
DROP TABLE test2;
Affected Rows: 1

View File

@@ -0,0 +1,25 @@
CREATE TABLE integers (i BIGINT);
CREATE TABLE integers (i BIGINT TIME INDEX);
CREATE TABLE IF NOT EXISTS integers (i BIGINT TIME INDEX);
CREATE TABLE test1 (i INTEGER, j INTEGER);
CREATE TABLE test1 (i INTEGER, j BIGINT TIME INDEX NOT NULL);
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX NULL);
CREATE TABLE test2 (i INTEGER, j BIGINT TIME INDEX);
DESC TABLE integers;
DESC TABLE test1;
DESC TABLE test2;
DROP TABLE integers;
DROP TABLE test1;
DROP TABLE test2;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,43 @@
CREATE TABLE integers (
ts TIMESTAMP,
TIME INDEX(ts)
);
Affected Rows: 0
INSERT INTO integers VALUES (1), (2), (3), (4), (5);
Affected Rows: 5
SELECT * FROM integers;
+-------------------------+
| ts |
+-------------------------+
| 1970-01-01T00:00:00.001 |
| 1970-01-01T00:00:00.002 |
| 1970-01-01T00:00:00.003 |
| 1970-01-01T00:00:00.004 |
| 1970-01-01T00:00:00.005 |
+-------------------------+
CREATE TABLE IF NOT EXISTS presentations (
presentation_date TIMESTAMP,
author VARCHAR NOT NULL,
title STRING NOT NULL,
bio VARCHAR,
abstract VARCHAR,
zoom_link VARCHAR,
TIME INDEX(presentation_date)
);
Affected Rows: 0
insert into presentations values (1, 'Patrick Damme', 'Analytical Query Processing Based on Continuous Compression of Intermediates', NULL, 'Modern in-memory column-stores are widely accepted as the adequate database architecture for the efficient processing of complex analytical queries over large relational data volumes. These systems keep their entire data in main memory and typically employ lightweight compression to address the bottleneck between main memory and CPU. Numerous lightweight compression algorithms have been proposed in the past years, but none of them is suitable in all cases. While lightweight compression is already well established for base data, the efficient representation of intermediate results generated during query processing has attracted insufficient attention so far, although in in-memory systems, accessing intermeFdiates is as expensive as accessing base data. Thus, our vision is a continuous use of lightweight compression for all intermediates in a query execution plan, whereby a suitable compression algorithm should be selected for each intermediate. In this talk, I will provide an overview of our research in the context of this vision, including an experimental survey of lightweight compression algorithms, our compression-enabled processing model, and our compression-aware query optimization strategies.', 'https://zoom.us/j/7845983526');
Affected Rows: 1
DROP TABLE integers;
Affected Rows: 1

View File

@@ -0,0 +1,23 @@
CREATE TABLE integers (
ts TIMESTAMP,
TIME INDEX(ts)
);
INSERT INTO integers VALUES (1), (2), (3), (4), (5);
SELECT * FROM integers;
-- Test insert with long string constant
CREATE TABLE IF NOT EXISTS presentations (
presentation_date TIMESTAMP,
author VARCHAR NOT NULL,
title STRING NOT NULL,
bio VARCHAR,
abstract VARCHAR,
zoom_link VARCHAR,
TIME INDEX(presentation_date)
);
insert into presentations values (1, 'Patrick Damme', 'Analytical Query Processing Based on Continuous Compression of Intermediates', NULL, 'Modern in-memory column-stores are widely accepted as the adequate database architecture for the efficient processing of complex analytical queries over large relational data volumes. These systems keep their entire data in main memory and typically employ lightweight compression to address the bottleneck between main memory and CPU. Numerous lightweight compression algorithms have been proposed in the past years, but none of them is suitable in all cases. While lightweight compression is already well established for base data, the efficient representation of intermediate results generated during query processing has attracted insufficient attention so far, although in in-memory systems, accessing intermeFdiates is as expensive as accessing base data. Thus, our vision is a continuous use of lightweight compression for all intermediates in a query execution plan, whereby a suitable compression algorithm should be selected for each intermediate. In this talk, I will provide an overview of our research in the context of this vision, including an experimental survey of lightweight compression algorithms, our compression-enabled processing model, and our compression-aware query optimization strategies.', 'https://zoom.us/j/7845983526');
DROP TABLE integers;

View File

@@ -0,0 +1,44 @@
CREATE TABLE strings(i STRING, t BIGINT, time index(t));
Affected Rows: 0
INSERT INTO strings VALUES ('â‚(', 1);
Affected Rows: 1
INSERT INTO strings VALUES (3, 4);
Error: 2000(InvalidSyntax), Failed to parse value: Fail to parse number 3, invalid column type: String(StringType)
SELECT * FROM strings WHERE i = 'â‚(';
+-----+---+
| i | t |
+-----+---+
| â‚( | 1 |
+-----+---+
CREATE TABLE a(i integer, j BIGINT, time index(j));
Affected Rows: 0
INSERT INTO a VALUES (1, 2);
Affected Rows: 1
INSERT INTO a VALUES (1);
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 2, values: 1
INSERT INTO a VALUES (1,2,3);
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 2, values: 3
INSERT INTO a VALUES (1,2),(3);
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 2, values: 1
INSERT INTO a VALUES (1,2),(3,4,5);
Error: 1004(InvalidArguments), Columns and values number mismatch, columns: 2, values: 3

View File

@@ -0,0 +1,19 @@
CREATE TABLE strings(i STRING, t BIGINT, time index(t));
INSERT INTO strings VALUES ('â‚(', 1);
INSERT INTO strings VALUES (3, 4);
SELECT * FROM strings WHERE i = 'â‚(';
CREATE TABLE a(i integer, j BIGINT, time index(j));
INSERT INTO a VALUES (1, 2);
INSERT INTO a VALUES (1);
INSERT INTO a VALUES (1,2,3);
INSERT INTO a VALUES (1,2),(3);
INSERT INTO a VALUES (1,2),(3,4,5);

View File

@@ -0,0 +1,25 @@
SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) LIMIT 0;
++
++
EXPLAIN SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) LIMIT 0;
+---------------+----------------------------------+
| plan_type | plan |
+---------------+----------------------------------+
| logical_plan | EmptyRelation |
| physical_plan | EmptyExec: produce_one_row=false |
| | |
+---------------+----------------------------------+
EXPLAIN SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) WHERE 1=0;
+---------------+----------------------------------+
| plan_type | plan |
+---------------+----------------------------------+
| logical_plan | EmptyRelation |
| physical_plan | EmptyExec: produce_one_row=false |
| | |
+---------------+----------------------------------+

View File

@@ -0,0 +1,5 @@
SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) LIMIT 0;
EXPLAIN SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) LIMIT 0;
EXPLAIN SELECT * FROM (SELECT SUM(number) FROM numbers LIMIT 100000000000) WHERE 1=0;

View File

@@ -0,0 +1,183 @@
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4);
Affected Rows: 4
SELECT i1.i, i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i ORDER BY 1;
+---+---+
| i | i |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i AND i1.i>1 ORDER BY 1;
+---+---+
| i | i |
+---+---+
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT i1.i,i2.i,i3.i FROM integers i1, integers i2, integers i3 WHERE i1.i=i2.i AND i1.i=i3.i AND i1.i>1 ORDER BY 1;
+---+---+---+
| i | i | i |
+---+---+---+
| 2 | 2 | 2 |
| 3 | 3 | 3 |
+---+---+---+
SELECT i1.i,i2.i FROM integers i1 JOIN integers i2 ON i1.i=i2.i WHERE i1.i>1 ORDER BY 1;
+---+---+
| i | i |
+---+---+
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i>2 ORDER BY 2;
Error: 1003(Internal), External error: Arrow error: External error: External error: Not expected to run ExecutionPlan more than once
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NOT NULL ORDER BY 2;
++
++
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i>1 ORDER BY 2;
++
++
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE CASE WHEN i2.i IS NULL THEN False ELSE True END ORDER BY 2;
++
++
SELECT DISTINCT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NULL ORDER BY 1;
+---+---+
| i | i |
+---+---+
| 1 | |
| 2 | |
| 3 | |
| | |
+---+---+
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=i2.i ORDER BY 1;
+---+---+
| i | i |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i;
Error: 3001(EngineExecuteQuery), This feature is not implemented: Physical plan does not support logical expression (<subquery>)
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i;
Error: 3001(EngineExecuteQuery), This feature is not implemented: Physical plan does not support logical expression (<subquery>)
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i;
Error: 3001(EngineExecuteQuery), This feature is not implemented: Physical plan does not support logical expression (<subquery>)
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1;
Error: 3001(EngineExecuteQuery), This feature is not implemented: Physical plan does not support logical expression (<subquery>)
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
+---+---+
| i | j |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
+---+---+
| i | j |
+---+---+
| | 4 |
+---+---+
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i;
Error: 3001(EngineExecuteQuery), This feature is not implemented: Physical plan does not support logical expression (<subquery>)
SELECT * FROM (SELECT i1.i AS a, i2.i AS b FROM integers i1, integers i2) a1 WHERE a=b ORDER BY 1;
+---+---+
| a | b |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 3 |
+---+---+
SELECT * FROM (SELECT i1.i=i2.i AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1;
+------+
| cond |
+------+
| true |
| true |
| true |
+------+
SELECT * FROM (SELECT DISTINCT i1.i AS a, i2.i AS b FROM integers i1, integers i2) res WHERE a=1 AND b=3;
+---+---+
| a | b |
+---+---+
| 1 | 3 |
+---+---+
SELECT i FROM (SELECT * FROM integers i1 UNION SELECT * FROM integers i2) a WHERE i=3;
+---+
| i |
+---+
| 3 |
+---+
SELECT * FROM (SELECT i1.i AS a, i2.i AS b, row_number() OVER (ORDER BY i1.i, i2.i) FROM integers i1, integers i2 WHERE i1.i IS NOT NULL AND i2.i IS NOT NULL) a1 WHERE a=b ORDER BY 1;
+---+---+--------------+
| a | b | ROW_NUMBER() |
+---+---+--------------+
| 1 | 1 | 1 |
| 2 | 2 | 5 |
| 3 | 3 | 9 |
+---+---+--------------+
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1;
++
++
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2 GROUP BY 1) a1 WHERE cond ORDER BY 1;
++
++
DROP TABLE integers;
Affected Rows: 1

View File

@@ -0,0 +1,54 @@
CREATE TABLE integers(i INTEGER, j BIGINT TIME INDEX);
INSERT INTO integers VALUES (1, 1), (2, 2), (3, 3), (NULL, 4);
SELECT i1.i, i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i ORDER BY 1;
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=i2.i AND i1.i>1 ORDER BY 1;
SELECT i1.i,i2.i,i3.i FROM integers i1, integers i2, integers i3 WHERE i1.i=i2.i AND i1.i=i3.i AND i1.i>1 ORDER BY 1;
SELECT i1.i,i2.i FROM integers i1 JOIN integers i2 ON i1.i=i2.i WHERE i1.i>1 ORDER BY 1;
-- This sql can't work, refer to https://github.com/GreptimeTeam/greptimedb/issues/790 --
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i>2 ORDER BY 2;
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NOT NULL ORDER BY 2;
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i>1 ORDER BY 2;
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE CASE WHEN i2.i IS NULL THEN False ELSE True END ORDER BY 2;
SELECT DISTINCT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=0 WHERE i2.i IS NULL ORDER BY 1;
SELECT i1.i,i2.i FROM integers i1 LEFT OUTER JOIN integers i2 ON 1=1 WHERE i1.i=i2.i ORDER BY 1;
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) ORDER BY i;
SELECT * FROM integers WHERE i NOT IN ((SELECT i FROM integers WHERE i=1)) ORDER BY i;
SELECT * FROM integers WHERE i IN ((SELECT i FROM integers)) AND i<3 ORDER BY i;
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i IN ((SELECT i FROM integers)) AND i1.i=i2.i ORDER BY 1;
SELECT * FROM integers i1 WHERE EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
SELECT * FROM integers i1 WHERE NOT EXISTS(SELECT i FROM integers WHERE i=i1.i) ORDER BY i1.i;
SELECT i1.i,i2.i FROM integers i1, integers i2 WHERE i1.i=(SELECT i FROM integers WHERE i1.i=i) AND i1.i=i2.i ORDER BY i1.i;
SELECT * FROM (SELECT i1.i AS a, i2.i AS b FROM integers i1, integers i2) a1 WHERE a=b ORDER BY 1;
SELECT * FROM (SELECT i1.i=i2.i AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1;
SELECT * FROM (SELECT DISTINCT i1.i AS a, i2.i AS b FROM integers i1, integers i2) res WHERE a=1 AND b=3;
SELECT i FROM (SELECT * FROM integers i1 UNION SELECT * FROM integers i2) a WHERE i=3;
SELECT * FROM (SELECT i1.i AS a, i2.i AS b, row_number() OVER (ORDER BY i1.i, i2.i) FROM integers i1, integers i2 WHERE i1.i IS NOT NULL AND i2.i IS NOT NULL) a1 WHERE a=b ORDER BY 1;
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2) a1 WHERE cond ORDER BY 1;
SELECT * FROM (SELECT 0=1 AS cond FROM integers i1, integers i2 GROUP BY 1) a1 WHERE cond ORDER BY 1;
DROP TABLE integers;

View File

@@ -0,0 +1,133 @@
CREATE TABLE test (a BIGINT time index, b INTEGER);
Affected Rows: 0
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
Affected Rows: 3
SELECT a FROM test LIMIT 1;
+----+
| a |
+----+
| 11 |
+----+
SELECT a FROM test LIMIT 1.25;
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT a FROM test LIMIT 2-1;
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT a FROM test LIMIT a;
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT a FROM test LIMIT a+1;
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT a FROM test LIMIT SUM(42);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT a FROM test LIMIT row_number() OVER ();
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
CREATE TABLE test2 (a STRING, ts BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test2 VALUES ('Hello World', 1);
Affected Rows: 1
SELECT * FROM test2 LIMIT 3;
+-------------+----+
| a | ts |
+-------------+----+
| Hello World | 1 |
+-------------+----+
select 1 limit date '1992-01-01';
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
CREATE TABLE integers(i BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO integers VALUES (1), (2), (3), (4), (5);
Affected Rows: 5
SELECT * FROM integers LIMIT 3;
+---+
| i |
+---+
| 1 |
| 2 |
| 3 |
+---+
SELECT * FROM integers LIMIT 4;
+---+
| i |
+---+
| 1 |
| 2 |
| 3 |
| 4 |
+---+
SELECT * FROM integers as int LIMIT (SELECT MIN(integers.i) FROM integers);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT * FROM integers as int OFFSET (SELECT MIN(integers.i) FROM integers);
Error: 3000(PlanQuery), Error during planning: Unexpected expression in OFFSET clause
SELECT * FROM integers as int LIMIT (SELECT MAX(integers.i) FROM integers) OFFSET (SELECT MIN(integers.i) FROM integers);
Error: 3000(PlanQuery), Error during planning: Unexpected expression in OFFSET clause
SELECT * FROM integers as int LIMIT (SELECT max(integers.i) FROM integers where i > 5);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT * FROM integers as int LIMIT (SELECT max(integers.i) FROM integers where i > 5);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT * FROM integers as int LIMIT (SELECT NULL);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT * FROM integers as int LIMIT (SELECT -1);
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
SELECT * FROM integers as int LIMIT (SELECT 'ab');
Error: 3000(PlanQuery), Error during planning: Unexpected expression for LIMIT clause
DROP TABLE integers;
Affected Rows: 1
DROP TABLE test;
Affected Rows: 1
DROP TABLE test2;
Affected Rows: 1

View File

@@ -0,0 +1,56 @@
CREATE TABLE test (a BIGINT time index, b INTEGER);
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
SELECT a FROM test LIMIT 1;
SELECT a FROM test LIMIT 1.25;
SELECT a FROM test LIMIT 2-1;
SELECT a FROM test LIMIT a;
SELECT a FROM test LIMIT a+1;
SELECT a FROM test LIMIT SUM(42);
SELECT a FROM test LIMIT row_number() OVER ();
CREATE TABLE test2 (a STRING, ts BIGINT TIME INDEX);
INSERT INTO test2 VALUES ('Hello World', 1);
SELECT * FROM test2 LIMIT 3;
select 1 limit date '1992-01-01';
CREATE TABLE integers(i BIGINT TIME INDEX);
INSERT INTO integers VALUES (1), (2), (3), (4), (5);
SELECT * FROM integers LIMIT 3;
SELECT * FROM integers LIMIT 4;
SELECT * FROM integers as int LIMIT (SELECT MIN(integers.i) FROM integers);
SELECT * FROM integers as int OFFSET (SELECT MIN(integers.i) FROM integers);
SELECT * FROM integers as int LIMIT (SELECT MAX(integers.i) FROM integers) OFFSET (SELECT MIN(integers.i) FROM integers);
SELECT * FROM integers as int LIMIT (SELECT max(integers.i) FROM integers where i > 5);
SELECT * FROM integers as int LIMIT (SELECT max(integers.i) FROM integers where i > 5);
SELECT * FROM integers as int LIMIT (SELECT NULL);
SELECT * FROM integers as int LIMIT (SELECT -1);
SELECT * FROM integers as int LIMIT (SELECT 'ab');
DROP TABLE integers;
DROP TABLE test;
DROP TABLE test2;

View File

@@ -0,0 +1,30 @@
CREATE TABLE integers(i BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO integers VALUES (0), (1), (2), (3), (4);
Affected Rows: 5
SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7;
+---+
| i |
+---+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
| 0 |
| 1 |
+---+
SELECT COUNT(*) FROM (SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7) tbl;
Error: 3001(EngineExecuteQuery), Internal error: create_physical_expr expected same number of fields, got got Arrow schema with 1 and DataFusion schema with 0. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker
DROP TABLE integers;
Affected Rows: 1

View File

@@ -0,0 +1,9 @@
CREATE TABLE integers(i BIGINT TIME INDEX);
INSERT INTO integers VALUES (0), (1), (2), (3), (4);
SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7;
SELECT COUNT(*) FROM (SELECT * FROM integers UNION ALL SELECT * FROM integers LIMIT 7) tbl;
DROP TABLE integers;

View File

@@ -0,0 +1,110 @@
CREATE TABLE test(i INTEGER, j INTEGER, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test VALUES (1, 1, 1), (NULL, 1, 2), (1, NULL, 3);
Affected Rows: 3
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST;
+---+---+---+
| i | j | t |
+---+---+---+
| | 1 | 2 |
| 1 | 1 | 1 |
| 1 | | 3 |
+---+---+---+
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
+---+---+---+
| i | j | t |
+---+---+---+
| | 1 | 2 |
| 1 | | 3 |
| 1 | 1 | 1 |
+---+---+---+
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS FIRST;
+---+---+---+
| i | j | t |
+---+---+---+
| 1 | | 3 |
| 1 | 1 | 1 |
| | 1 | 2 |
+---+---+---+
SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
+---+---+--------------+
| i | j | ROW_NUMBER() |
+---+---+--------------+
| | 1 | 1 |
| 1 | | 1 |
| 1 | 1 | 2 |
+---+---+--------------+
SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
+---+---+--------------+
| i | j | ROW_NUMBER() |
+---+---+--------------+
| | 1 | 1 |
| 1 | | 2 |
| 1 | 1 | 1 |
+---+---+--------------+
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST LIMIT 2;
+---+---+---+
| i | j | t |
+---+---+---+
| | 1 | 2 |
| 1 | 1 | 1 |
+---+---+---+
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS LAST LIMIT 2;
+---+---+---+
| i | j | t |
+---+---+---+
| 1 | 1 | 1 |
| 1 | | 3 |
+---+---+---+
SELECT * FROM test ORDER BY i;
+---+---+---+
| i | j | t |
+---+---+---+
| 1 | 1 | 1 |
| 1 | | 3 |
| | 1 | 2 |
+---+---+---+
SELECT * FROM test ORDER BY i NULLS FIRST;
+---+---+---+
| i | j | t |
+---+---+---+
| | 1 | 2 |
| 1 | 1 | 1 |
| 1 | | 3 |
+---+---+---+
SELECT * FROM test ORDER BY i NULLS LAST;
+---+---+---+
| i | j | t |
+---+---+---+
| 1 | 1 | 1 |
| 1 | | 3 |
| | 1 | 2 |
+---+---+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,25 @@
CREATE TABLE test(i INTEGER, j INTEGER, t BIGINT TIME INDEX);
INSERT INTO test VALUES (1, 1, 1), (NULL, 1, 2), (1, NULL, 3);
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST;
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS FIRST;
SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS FIRST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
SELECT i, j, row_number() OVER (PARTITION BY i ORDER BY j NULLS LAST) FROM test ORDER BY i NULLS FIRST, j NULLS FIRST;
SELECT * FROM test ORDER BY i NULLS FIRST, j NULLS LAST LIMIT 2;
SELECT * FROM test ORDER BY i NULLS LAST, j NULLS LAST LIMIT 2;
SELECT * FROM test ORDER BY i;
SELECT * FROM test ORDER BY i NULLS FIRST;
SELECT * FROM test ORDER BY i NULLS LAST;
DROP TABLE test;

View File

@@ -0,0 +1,220 @@
CREATE TABLE test (a BIGINT, b INTEGER, time index(a));
Affected Rows: 0
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
Affected Rows: 3
select b from test where a = 12;
+----+
| b |
+----+
| 21 |
+----+
SELECT b FROM test ORDER BY a DESC;
+----+
| b |
+----+
| 22 |
| 21 |
| 22 |
+----+
SELECT a, b FROM test ORDER BY a;
+----+----+
| a | b |
+----+----+
| 11 | 22 |
| 12 | 21 |
| 13 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY a DESC;
+----+----+
| a | b |
+----+----+
| 13 | 22 |
| 12 | 21 |
| 11 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY b, a;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
| 11 | 22 |
| 13 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY 2, 1;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
| 11 | 22 |
| 13 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY b DESC, a;
+----+----+
| a | b |
+----+----+
| 11 | 22 |
| 13 | 22 |
| 12 | 21 |
+----+----+
SELECT a, b FROM test ORDER BY b, a DESC;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
| 13 | 22 |
| 11 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
+----+----+
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1 OFFSET 1;
+----+----+
| a | b |
+----+----+
| 13 | 22 |
+----+----+
SELECT a, b FROM test ORDER BY b, a DESC OFFSET 1;
+----+----+
| a | b |
+----+----+
| 13 | 22 |
| 11 | 22 |
+----+----+
SELECT a, b FROM test WHERE a < 13 ORDER BY b;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
| 11 | 22 |
+----+----+
SELECT a, b FROM test WHERE a < 13 ORDER BY 2;
+----+----+
| a | b |
+----+----+
| 12 | 21 |
| 11 | 22 |
+----+----+
SELECT a, b FROM test WHERE a < 13 ORDER BY b DESC;
+----+----+
| a | b |
+----+----+
| 11 | 22 |
| 12 | 21 |
+----+----+
SELECT b, a FROM test WHERE a < 13 ORDER BY b DESC;
+----+----+
| b | a |
+----+----+
| 22 | 11 |
| 21 | 12 |
+----+----+
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY b % 2;
+---+-------------+
| f | SUM(test.a) |
+---+-------------+
| 0 | 24 |
| 1 | 12 |
+---+-------------+
SELECT b % 2 AS f, a FROM test ORDER BY b % 2, a;
+---+----+
| f | a |
+---+----+
| 0 | 11 |
| 0 | 13 |
| 1 | 12 |
+---+----+
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY f;
+---+-------------+
| f | SUM(test.a) |
+---+-------------+
| 0 | 24 |
| 1 | 12 |
+---+-------------+
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY 1;
+---+-------------+
| f | SUM(test.a) |
+---+-------------+
| 0 | 24 |
| 1 | 12 |
+---+-------------+
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY k;
+---+
| k |
+---+
| 1 |
| 2 |
| 3 |
+---+
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY l;
Error: 3000(PlanQuery), Schema error: No field named 'l'. Valid fields are 'k'.
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY 1-k;
+---+
| k |
+---+
| 3 |
| 2 |
| 1 |
+---+
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY a-10;
Error: 3000(PlanQuery), Schema error: No field named 'a'. Valid fields are 'k'.
SELECT a-10 AS k FROM test UNION SELECT a-11 AS l FROM test ORDER BY a-11;
Error: 3000(PlanQuery), Schema error: No field named 'a'. Valid fields are 'k'.
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,58 @@
CREATE TABLE test (a BIGINT, b INTEGER, time index(a));
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
select b from test where a = 12;
SELECT b FROM test ORDER BY a DESC;
SELECT a, b FROM test ORDER BY a;
SELECT a, b FROM test ORDER BY a DESC;
SELECT a, b FROM test ORDER BY b, a;
SELECT a, b FROM test ORDER BY 2, 1;
SELECT a, b FROM test ORDER BY b DESC, a;
SELECT a, b FROM test ORDER BY b, a DESC;
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1;
SELECT a, b FROM test ORDER BY b, a DESC LIMIT 1 OFFSET 1;
SELECT a, b FROM test ORDER BY b, a DESC OFFSET 1;
SELECT a, b FROM test WHERE a < 13 ORDER BY b;
SELECT a, b FROM test WHERE a < 13 ORDER BY 2;
SELECT a, b FROM test WHERE a < 13 ORDER BY b DESC;
SELECT b, a FROM test WHERE a < 13 ORDER BY b DESC;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY b % 2;
SELECT b % 2 AS f, a FROM test ORDER BY b % 2, a;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY f;
SELECT b % 2 AS f, SUM(a) FROM test GROUP BY f ORDER BY 1;
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY k;
-- ORDER BY on alias in right-most query
-- CONTROVERSIAL: SQLite allows both "k" and "l" to be referenced here, Postgres and MonetDB give an error.
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY l;
-- Not compatible with duckdb, work in gretimedb
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY 1-k;
-- Not compatible with duckdb, give an error in greptimedb
SELECT a-10 AS k FROM test UNION SELECT a-10 AS l FROM test ORDER BY a-10;
-- Not compatible with duckdb, give an error in greptimedb
SELECT a-10 AS k FROM test UNION SELECT a-11 AS l FROM test ORDER BY a-11;
DROP TABLE test;

View File

@@ -0,0 +1,56 @@
CREATE TABLE test (a BIGINT TIME INDEX, b INTEGER);
Affected Rows: 0
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
Affected Rows: 3
SELECT a FROM test ORDER BY 2;
Error: 3000(PlanQuery), Error during planning: Order by column out of bounds, specified: 2, max: 1
SELECT a FROM test ORDER BY 'hello', a;
Error: 1003(Internal), External error: Arrow error: External error: Error during planning: Sort operation is not applicable to scalar value hello
SELECT a AS k, b FROM test UNION SELECT a, b AS k FROM test ORDER BY k;
+----+----+
| k | b |
+----+----+
| 11 | 22 |
| 12 | 21 |
| 13 | 22 |
+----+----+
SELECT a AS k, b FROM test UNION SELECT a AS k, b FROM test ORDER BY k;
+----+----+
| k | b |
+----+----+
| 11 | 22 |
| 12 | 21 |
| 13 | 22 |
+----+----+
SELECT a % 2, b FROM test UNION SELECT b, a % 2 AS k ORDER BY a % 2;
Error: 3000(PlanQuery), Schema error: No field named 'b'. Valid fields are .
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY a % 2;
Error: 3000(PlanQuery), Schema error: No field named 'a'. Valid fields are 'test.a % Int64(2)', 'b'.
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY 3;
Error: 3000(PlanQuery), Error during planning: Order by column out of bounds, specified: 3, max: 2
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY -1;
Error: 1003(Internal), External error: Arrow error: External error: Error during planning: Sort operation is not applicable to scalar value -1
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k FROM test ORDER BY -1;
Error: 3000(PlanQuery), Error during planning: Union queries must have the same number of columns, (left is 2, right is 1)

View File

@@ -0,0 +1,24 @@
CREATE TABLE test (a BIGINT TIME INDEX, b INTEGER);
INSERT INTO test VALUES (11, 22), (12, 21), (13, 22);
SELECT a FROM test ORDER BY 2;
-- Not work in greptimedb
SELECT a FROM test ORDER BY 'hello', a;
-- Ambiguous reference in union alias, give and error in duckdb, but works in greptimedb
SELECT a AS k, b FROM test UNION SELECT a, b AS k FROM test ORDER BY k;
SELECT a AS k, b FROM test UNION SELECT a AS k, b FROM test ORDER BY k;
SELECT a % 2, b FROM test UNION SELECT b, a % 2 AS k ORDER BY a % 2;
-- Works duckdb, but not work in greptimedb
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY a % 2;
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY 3;
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k, b FROM test ORDER BY -1;
SELECT a % 2, b FROM test UNION SELECT a % 2 AS k FROM test ORDER BY -1;

View File

@@ -0,0 +1,427 @@
create table t0 (c0 varchar, t BIGINT TIME INDEX);
Affected Rows: 0
insert into t0 values ('a', 1), (NULL,2), (NULL, 3), (NULL, 4), (NULL, 5), (NULL,6), (NULL,7);
Affected Rows: 7
SELECT * FROM t0 ORDER BY t0.c0 DESC;
+----+---+
| c0 | t |
+----+---+
| | 7 |
| | 6 |
| | 5 |
| | 4 |
| | 3 |
| | 2 |
| a | 1 |
+----+---+
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test0 VALUES ('Shipping and Receiving Supervisor', 'Ackerman', 1), ('Shipping and Receiving Clerk', 'Berndt', 2), ('Shipping and Receiving Clerk', 'Kuppa', 3), ('Production Supervisor - WC60', 'Brown', 4), ('Production Supervisor - WC60', 'Campbell', 5), ('Production Supervisor - WC40', 'Dsa', 6);
Affected Rows: 6
SELECT * FROM test0 ORDER BY job, name;
+-----------------------------------+----------+---+
| job | name | t |
+-----------------------------------+----------+---+
| Production Supervisor - WC40 | Dsa | 6 |
| Production Supervisor - WC60 | Brown | 4 |
| Production Supervisor - WC60 | Campbell | 5 |
| Shipping and Receiving Clerk | Berndt | 2 |
| Shipping and Receiving Clerk | Kuppa | 3 |
| Shipping and Receiving Supervisor | Ackerman | 1 |
+-----------------------------------+----------+---+
SELECT * FROM test0 ORDER BY job DESC, name DESC;
+-----------------------------------+----------+---+
| job | name | t |
+-----------------------------------+----------+---+
| Shipping and Receiving Supervisor | Ackerman | 1 |
| Shipping and Receiving Clerk | Kuppa | 3 |
| Shipping and Receiving Clerk | Berndt | 2 |
| Production Supervisor - WC60 | Campbell | 5 |
| Production Supervisor - WC60 | Brown | 4 |
| Production Supervisor - WC40 | Dsa | 6 |
+-----------------------------------+----------+---+
CREATE TABLE test1 (s VARCHAR, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test1 VALUES ('2', 1), (NULL, 2), ('3555555555552', 3), ('1', 4), ('355555555556', 5), ('10', 6), ('3555555555553', 7), ('3555555555551', 8);
Affected Rows: 8
SELECT * FROM test1 ORDER BY s;
+---------------+---+
| s | t |
+---------------+---+
| 1 | 4 |
| 10 | 6 |
| 2 | 1 |
| 3555555555551 | 8 |
| 3555555555552 | 3 |
| 3555555555553 | 7 |
| 355555555556 | 5 |
| | 2 |
+---------------+---+
CREATE TABLE test4 (i INT, j INT, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test4 VALUES (3, 3, 1), (2, 3, 2), (2, 2, 3), (3, 2, 4);
Affected Rows: 4
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), j;
+---+---+---+
| i | j | t |
+---+---+---+
| 2 | 2 | 3 |
| 2 | 3 | 2 |
| 3 | 2 | 4 |
| 3 | 3 | 1 |
+---+---+---+
SELECT * FROM test4 ORDER BY i, cast(j AS VARCHAR);
+---+---+---+
| i | j | t |
+---+---+---+
| 2 | 2 | 3 |
| 2 | 3 | 2 |
| 3 | 2 | 4 |
| 3 | 3 | 1 |
+---+---+---+
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), cast(j AS VARCHAR);
+---+---+---+
| i | j | t |
+---+---+---+
| 2 | 2 | 3 |
| 2 | 3 | 2 |
| 3 | 2 | 4 |
| 3 | 3 | 1 |
+---+---+---+
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO tpch_q1_agg VALUES ('N', 'O', 7459297, 10512270008.90, 9986238338.3847, 10385578376.585467, 25.545537671232875, 36000.9246880137, 0.05009595890410959, 292000, 1), ('R', 'F', 3785523, 5337950526.47, 5071818532.9420, 5274405503.049367, 25.5259438574251, 35994.029214030925, 0.04998927856184382, 148301, 2), ('A', 'F', 3774200, 5320753880.69, 5054096266.6828, 5256751331.449234, 25.537587116854997, 36002.12382901414, 0.05014459706340077, 147790, 3), ('N', 'F', 95257, 133737795.84, 127132372.6512, 132286291.229445, 25.30066401062417, 35521.32691633466, 0.04939442231075697, 3765, 4);
Affected Rows: 4
SELECT * FROM tpch_q1_agg ORDER BY l_returnflag, l_linestatus;
+--------------+--------------+---------+----------------+-----------------+--------------------+--------------------+--------------------+---------------------+-------------+---+
| l_returnflag | l_linestatus | sum_qty | sum_base_price | sum_disc_price | sum_charge | avg_qty | avg_price | avg_disc | count_order | t |
+--------------+--------------+---------+----------------+-----------------+--------------------+--------------------+--------------------+---------------------+-------------+---+
| A | F | 3774200 | 5320753880.69 | 5054096266.6828 | 5256751331.449234 | 25.537587116854997 | 36002.12382901414 | 0.05014459706340077 | 147790 | 3 |
| N | F | 95257 | 133737795.84 | 127132372.6512 | 132286291.229445 | 25.30066401062417 | 35521.32691633466 | 0.04939442231075697 | 3765 | 4 |
| N | O | 7459297 | 10512270008.9 | 9986238338.3847 | 10385578376.585466 | 25.545537671232875 | 36000.9246880137 | 0.05009595890410959 | 292000 | 1 |
| R | F | 3785523 | 5337950526.47 | 5071818532.942 | 5274405503.049367 | 25.5259438574251 | 35994.029214030925 | 0.04998927856184382 | 148301 | 2 |
+--------------+--------------+---------+----------------+-----------------+--------------------+--------------------+--------------------+---------------------+-------------+---+
create table test5 (i int, s varchar, t BIGINT TIME INDEX);
Affected Rows: 0
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t BIGINT TIME INDEX);
Affected Rows: 0
INSERT INTO test6 VALUES
(6, '0reallylongstring1', 3, '1reallylongstring8', 1),
(6, '0reallylongstring1', 3, '1reallylongstring7', 2),
(6, '0reallylongstring1', 4, '1reallylongstring8', 3),
(6, '0reallylongstring1', 4, '1reallylongstring7', 4),
(6, '0reallylongstring2', 3, '1reallylongstring8', 5),
(6, '0reallylongstring2', 3, '1reallylongstring7', 6),
(6, '0reallylongstring2', 4, '1reallylongstring8', 7),
(6, '0reallylongstring2', 4, '1reallylongstring7', 8),
(5, '0reallylongstring1', 3, '1reallylongstring8', 9),
(5, '0reallylongstring1', 3, '1reallylongstring7', 10),
(5, '0reallylongstring1', 4, '1reallylongstring8', 11),
(5, '0reallylongstring1', 4, '1reallylongstring7', 12),
(5, '0reallylongstring2', 3, '1reallylongstring8', 13),
(5, '0reallylongstring2', 3, '1reallylongstring7', 14),
(5, '0reallylongstring2', 4, '1reallylongstring8', 15),
(5, '0reallylongstring2', 4, '1reallylongstring7', 16);
Affected Rows: 16
SELECT i1, s1, i2, s2 FROM test6 ORDER BY i1, s1, i2, s2;
+----+--------------------+----+--------------------+
| i1 | s1 | i2 | s2 |
+----+--------------------+----+--------------------+
| 5 | 0reallylongstring1 | 3 | 1reallylongstring7 |
| 5 | 0reallylongstring1 | 3 | 1reallylongstring8 |
| 5 | 0reallylongstring1 | 4 | 1reallylongstring7 |
| 5 | 0reallylongstring1 | 4 | 1reallylongstring8 |
| 5 | 0reallylongstring2 | 3 | 1reallylongstring7 |
| 5 | 0reallylongstring2 | 3 | 1reallylongstring8 |
| 5 | 0reallylongstring2 | 4 | 1reallylongstring7 |
| 5 | 0reallylongstring2 | 4 | 1reallylongstring8 |
| 6 | 0reallylongstring1 | 3 | 1reallylongstring7 |
| 6 | 0reallylongstring1 | 3 | 1reallylongstring8 |
| 6 | 0reallylongstring1 | 4 | 1reallylongstring7 |
| 6 | 0reallylongstring1 | 4 | 1reallylongstring8 |
| 6 | 0reallylongstring2 | 3 | 1reallylongstring7 |
| 6 | 0reallylongstring2 | 3 | 1reallylongstring8 |
| 6 | 0reallylongstring2 | 4 | 1reallylongstring7 |
| 6 | 0reallylongstring2 | 4 | 1reallylongstring8 |
+----+--------------------+----+--------------------+
SELECT s1, i1, i2, s2 FROM test6 ORDER BY s1, i1, i2, s2;
+--------------------+----+----+--------------------+
| s1 | i1 | i2 | s2 |
+--------------------+----+----+--------------------+
| 0reallylongstring1 | 5 | 3 | 1reallylongstring7 |
| 0reallylongstring1 | 5 | 3 | 1reallylongstring8 |
| 0reallylongstring1 | 5 | 4 | 1reallylongstring7 |
| 0reallylongstring1 | 5 | 4 | 1reallylongstring8 |
| 0reallylongstring1 | 6 | 3 | 1reallylongstring7 |
| 0reallylongstring1 | 6 | 3 | 1reallylongstring8 |
| 0reallylongstring1 | 6 | 4 | 1reallylongstring7 |
| 0reallylongstring1 | 6 | 4 | 1reallylongstring8 |
| 0reallylongstring2 | 5 | 3 | 1reallylongstring7 |
| 0reallylongstring2 | 5 | 3 | 1reallylongstring8 |
| 0reallylongstring2 | 5 | 4 | 1reallylongstring7 |
| 0reallylongstring2 | 5 | 4 | 1reallylongstring8 |
| 0reallylongstring2 | 6 | 3 | 1reallylongstring7 |
| 0reallylongstring2 | 6 | 3 | 1reallylongstring8 |
| 0reallylongstring2 | 6 | 4 | 1reallylongstring7 |
| 0reallylongstring2 | 6 | 4 | 1reallylongstring8 |
+--------------------+----+----+--------------------+
SELECT s1, i1, s2, i2 FROM test6 ORDER BY s1, i1, s2, i2;
+--------------------+----+--------------------+----+
| s1 | i1 | s2 | i2 |
+--------------------+----+--------------------+----+
| 0reallylongstring1 | 5 | 1reallylongstring7 | 3 |
| 0reallylongstring1 | 5 | 1reallylongstring7 | 4 |
| 0reallylongstring1 | 5 | 1reallylongstring8 | 3 |
| 0reallylongstring1 | 5 | 1reallylongstring8 | 4 |
| 0reallylongstring1 | 6 | 1reallylongstring7 | 3 |
| 0reallylongstring1 | 6 | 1reallylongstring7 | 4 |
| 0reallylongstring1 | 6 | 1reallylongstring8 | 3 |
| 0reallylongstring1 | 6 | 1reallylongstring8 | 4 |
| 0reallylongstring2 | 5 | 1reallylongstring7 | 3 |
| 0reallylongstring2 | 5 | 1reallylongstring7 | 4 |
| 0reallylongstring2 | 5 | 1reallylongstring8 | 3 |
| 0reallylongstring2 | 5 | 1reallylongstring8 | 4 |
| 0reallylongstring2 | 6 | 1reallylongstring7 | 3 |
| 0reallylongstring2 | 6 | 1reallylongstring7 | 4 |
| 0reallylongstring2 | 6 | 1reallylongstring8 | 3 |
| 0reallylongstring2 | 6 | 1reallylongstring8 | 4 |
+--------------------+----+--------------------+----+
SELECT s1, s2, i1, i2 FROM test6 ORDER BY s1, s2, i1, i2;
+--------------------+--------------------+----+----+
| s1 | s2 | i1 | i2 |
+--------------------+--------------------+----+----+
| 0reallylongstring1 | 1reallylongstring7 | 5 | 3 |
| 0reallylongstring1 | 1reallylongstring7 | 5 | 4 |
| 0reallylongstring1 | 1reallylongstring7 | 6 | 3 |
| 0reallylongstring1 | 1reallylongstring7 | 6 | 4 |
| 0reallylongstring1 | 1reallylongstring8 | 5 | 3 |
| 0reallylongstring1 | 1reallylongstring8 | 5 | 4 |
| 0reallylongstring1 | 1reallylongstring8 | 6 | 3 |
| 0reallylongstring1 | 1reallylongstring8 | 6 | 4 |
| 0reallylongstring2 | 1reallylongstring7 | 5 | 3 |
| 0reallylongstring2 | 1reallylongstring7 | 5 | 4 |
| 0reallylongstring2 | 1reallylongstring7 | 6 | 3 |
| 0reallylongstring2 | 1reallylongstring7 | 6 | 4 |
| 0reallylongstring2 | 1reallylongstring8 | 5 | 3 |
| 0reallylongstring2 | 1reallylongstring8 | 5 | 4 |
| 0reallylongstring2 | 1reallylongstring8 | 6 | 3 |
| 0reallylongstring2 | 1reallylongstring8 | 6 | 4 |
+--------------------+--------------------+----+----+
SELECT i1, i2, s1, s2 FROM test6 ORDER BY i1, i2, s1, s2;
+----+----+--------------------+--------------------+
| i1 | i2 | s1 | s2 |
+----+----+--------------------+--------------------+
| 5 | 3 | 0reallylongstring1 | 1reallylongstring7 |
| 5 | 3 | 0reallylongstring1 | 1reallylongstring8 |
| 5 | 3 | 0reallylongstring2 | 1reallylongstring7 |
| 5 | 3 | 0reallylongstring2 | 1reallylongstring8 |
| 5 | 4 | 0reallylongstring1 | 1reallylongstring7 |
| 5 | 4 | 0reallylongstring1 | 1reallylongstring8 |
| 5 | 4 | 0reallylongstring2 | 1reallylongstring7 |
| 5 | 4 | 0reallylongstring2 | 1reallylongstring8 |
| 6 | 3 | 0reallylongstring1 | 1reallylongstring7 |
| 6 | 3 | 0reallylongstring1 | 1reallylongstring8 |
| 6 | 3 | 0reallylongstring2 | 1reallylongstring7 |
| 6 | 3 | 0reallylongstring2 | 1reallylongstring8 |
| 6 | 4 | 0reallylongstring1 | 1reallylongstring7 |
| 6 | 4 | 0reallylongstring1 | 1reallylongstring8 |
| 6 | 4 | 0reallylongstring2 | 1reallylongstring7 |
| 6 | 4 | 0reallylongstring2 | 1reallylongstring8 |
+----+----+--------------------+--------------------+
SELECT s1, s2, i1, i2 FROM test6 ORDER BY i2 DESC, s1, s2, i1;
+--------------------+--------------------+----+----+
| s1 | s2 | i1 | i2 |
+--------------------+--------------------+----+----+
| 0reallylongstring1 | 1reallylongstring7 | 5 | 4 |
| 0reallylongstring1 | 1reallylongstring7 | 6 | 4 |
| 0reallylongstring1 | 1reallylongstring8 | 5 | 4 |
| 0reallylongstring1 | 1reallylongstring8 | 6 | 4 |
| 0reallylongstring2 | 1reallylongstring7 | 5 | 4 |
| 0reallylongstring2 | 1reallylongstring7 | 6 | 4 |
| 0reallylongstring2 | 1reallylongstring8 | 5 | 4 |
| 0reallylongstring2 | 1reallylongstring8 | 6 | 4 |
| 0reallylongstring1 | 1reallylongstring7 | 5 | 3 |
| 0reallylongstring1 | 1reallylongstring7 | 6 | 3 |
| 0reallylongstring1 | 1reallylongstring8 | 5 | 3 |
| 0reallylongstring1 | 1reallylongstring8 | 6 | 3 |
| 0reallylongstring2 | 1reallylongstring7 | 5 | 3 |
| 0reallylongstring2 | 1reallylongstring7 | 6 | 3 |
| 0reallylongstring2 | 1reallylongstring8 | 5 | 3 |
| 0reallylongstring2 | 1reallylongstring8 | 6 | 3 |
+--------------------+--------------------+----+----+
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t BIGINT TIME INDEX);
Affected Rows: 0
insert into test7 values ('Brand#11', 'ECONOMY BRUSHED COPPER', 3, 4, 1), ('Brand#11', 'ECONOMY BRUSHED COPPER', 9, 4, 2), ('Brand#11', 'ECONOMY BRUSHED STEEL', 36, 4, 3), ('Brand#11', 'ECONOMY BRUSHED STEEL', 9, 4, 4), ('Brand#11', 'ECONOMY BURNISHED BRASS', 36, 4, 5), ('Brand#11', 'ECONOMY BURNISHED COPPER', 49, 4, 6), ('Brand#11', 'ECONOMY BURNISHED COPPER', 9, 4, 7), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 14, 4,8), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 49, 4, 9);
Affected Rows: 9
SELECT p_brand, p_type, p_size, supplier_cnt FROM test7 ORDER BY supplier_cnt DESC, p_brand, p_type, p_size;
+----------+--------------------------+--------+--------------+
| p_brand | p_type | p_size | supplier_cnt |
+----------+--------------------------+--------+--------------+
| Brand#11 | ECONOMY BRUSHED COPPER | 3 | 4 |
| Brand#11 | ECONOMY BRUSHED COPPER | 9 | 4 |
| Brand#11 | ECONOMY BRUSHED STEEL | 9 | 4 |
| Brand#11 | ECONOMY BRUSHED STEEL | 36 | 4 |
| Brand#11 | ECONOMY BURNISHED BRASS | 36 | 4 |
| Brand#11 | ECONOMY BURNISHED COPPER | 9 | 4 |
| Brand#11 | ECONOMY BURNISHED COPPER | 49 | 4 |
| Brand#11 | ECONOMY BURNISHED NICKEL | 14 | 4 |
| Brand#11 | ECONOMY BURNISHED NICKEL | 49 | 4 |
+----------+--------------------------+--------+--------------+
create table test8 (i int, s varchar, t BIGINT TIME INDEX);
Affected Rows: 0
insert into test8 values (3, 'aba', 1), (1, 'ccbcc', 2), (NULL, 'dbdbd', 3), (2, NULL, 4);
Affected Rows: 4
select i, split_part(s, 'b', 1) from test8 order by i;
+---+---------------------------------------+
| i | splitpart(test8.s,Utf8("b"),Int64(1)) |
+---+---------------------------------------+
| 1 | cc |
| 2 | |
| 3 | a |
| | d |
+---+---------------------------------------+
CREATE TABLE DirectReports
(
EmployeeID smallint,
Name varchar NOT NULL,
Title varchar NOT NULL,
EmployeeLevel int NOT NULL,
Sort varchar NOT NULL,
Timestamp BIGINT TIME INDEX,
);
Affected Rows: 0
INSERT INTO DirectReports VALUES
(1, 'Ken Sánchez', 'Chief Executive Officer', 1, 'Ken Sánchez', 1),
(273, '>Brian Welcker', 'Vice President of Sales', 2, 'Ken Sánchez>Brian Welcker', 2),
(274, '>>Stephen Jiang', 'North American Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Stephen Jiang', 3),
(285, '>>Syed Abbas', 'Pacific Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Syed Abbas', 4),
(16, '>>David Bradley', 'Marketing Manager', 3, 'Ken Sánchez>Brian Welcker>David Bradley', 5),
(275, '>>>Michael Blythe', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Stephen Jiang>Michael Blythe', 6),
(276, '>>>Linda Mitchell', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Stephen Jiang>Linda Mitchell', 7),
(286, '>>>Lynn Tsoflias', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Syed Abbas>Lynn Tsoflias', 8),
(23, '>>>Mary Gibson', 'Marketing Specialist', 4, 'Ken Sánchez>Brian Welcker>David Bradley>Mary Gibson', 9);
Affected Rows: 9
SELECT "EmployeeID", "Name", "Title", "EmployeeLevel"
FROM "DirectReports"
ORDER BY "Sort", "EmployeeID";
+------------+-------------------+------------------------------+---------------+
| EmployeeID | Name | Title | EmployeeLevel |
+------------+-------------------+------------------------------+---------------+
| 1 | Ken Sánchez | Chief Executive Officer | 1 |
| 273 | >Brian Welcker | Vice President of Sales | 2 |
| 16 | >>David Bradley | Marketing Manager | 3 |
| 23 | >>>Mary Gibson | Marketing Specialist | 4 |
| 274 | >>Stephen Jiang | North American Sales Manager | 3 |
| 276 | >>>Linda Mitchell | Sales Representative | 4 |
| 275 | >>>Michael Blythe | Sales Representative | 4 |
| 285 | >>Syed Abbas | Pacific Sales Manager | 3 |
| 286 | >>>Lynn Tsoflias | Sales Representative | 4 |
+------------+-------------------+------------------------------+---------------+
DROP TABLE t0;
Affected Rows: 1
DROP TABLE test0;
Affected Rows: 1
DROP TABLE test1;
Affected Rows: 1
DROP TABLE test4;
Affected Rows: 1
DROP TABLE tpch_q1_agg;
Affected Rows: 1
DROP TABLE test6;
Affected Rows: 1
DROP table test7;
Affected Rows: 1
DROP table test8;
Affected Rows: 1
DROP TABLE DirectReports;
Affected Rows: 1

View File

@@ -0,0 +1,125 @@
create table t0 (c0 varchar, t BIGINT TIME INDEX);
insert into t0 values ('a', 1), (NULL,2), (NULL, 3), (NULL, 4), (NULL, 5), (NULL,6), (NULL,7);
SELECT * FROM t0 ORDER BY t0.c0 DESC;
CREATE TABLE test0 (job VARCHAR, name VARCHAR, t BIGINT TIME INDEX);
INSERT INTO test0 VALUES ('Shipping and Receiving Supervisor', 'Ackerman', 1), ('Shipping and Receiving Clerk', 'Berndt', 2), ('Shipping and Receiving Clerk', 'Kuppa', 3), ('Production Supervisor - WC60', 'Brown', 4), ('Production Supervisor - WC60', 'Campbell', 5), ('Production Supervisor - WC40', 'Dsa', 6);
SELECT * FROM test0 ORDER BY job, name;
SELECT * FROM test0 ORDER BY job DESC, name DESC;
CREATE TABLE test1 (s VARCHAR, t BIGINT TIME INDEX);
INSERT INTO test1 VALUES ('2', 1), (NULL, 2), ('3555555555552', 3), ('1', 4), ('355555555556', 5), ('10', 6), ('3555555555553', 7), ('3555555555551', 8);
SELECT * FROM test1 ORDER BY s;
CREATE TABLE test4 (i INT, j INT, t BIGINT TIME INDEX);
INSERT INTO test4 VALUES (3, 3, 1), (2, 3, 2), (2, 2, 3), (3, 2, 4);
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), j;
SELECT * FROM test4 ORDER BY i, cast(j AS VARCHAR);
SELECT * FROM test4 ORDER BY cast(i AS VARCHAR), cast(j AS VARCHAR);
CREATE TABLE tpch_q1_agg (l_returnflag VARCHAR, l_linestatus VARCHAR, sum_qty INT, sum_base_price DOUBLE, sum_disc_price DOUBLE, sum_charge DOUBLE, avg_qty DOUBLE, avg_price DOUBLE, avg_disc DOUBLE, count_order BIGINT, t BIGINT TIME INDEX);
INSERT INTO tpch_q1_agg VALUES ('N', 'O', 7459297, 10512270008.90, 9986238338.3847, 10385578376.585467, 25.545537671232875, 36000.9246880137, 0.05009595890410959, 292000, 1), ('R', 'F', 3785523, 5337950526.47, 5071818532.9420, 5274405503.049367, 25.5259438574251, 35994.029214030925, 0.04998927856184382, 148301, 2), ('A', 'F', 3774200, 5320753880.69, 5054096266.6828, 5256751331.449234, 25.537587116854997, 36002.12382901414, 0.05014459706340077, 147790, 3), ('N', 'F', 95257, 133737795.84, 127132372.6512, 132286291.229445, 25.30066401062417, 35521.32691633466, 0.04939442231075697, 3765, 4);
SELECT * FROM tpch_q1_agg ORDER BY l_returnflag, l_linestatus;
create table test5 (i int, s varchar, t BIGINT TIME INDEX);
CREATE TABLE test6 (i1 INT, s1 VARCHAR, i2 int, s2 VARCHAR, t BIGINT TIME INDEX);
INSERT INTO test6 VALUES
(6, '0reallylongstring1', 3, '1reallylongstring8', 1),
(6, '0reallylongstring1', 3, '1reallylongstring7', 2),
(6, '0reallylongstring1', 4, '1reallylongstring8', 3),
(6, '0reallylongstring1', 4, '1reallylongstring7', 4),
(6, '0reallylongstring2', 3, '1reallylongstring8', 5),
(6, '0reallylongstring2', 3, '1reallylongstring7', 6),
(6, '0reallylongstring2', 4, '1reallylongstring8', 7),
(6, '0reallylongstring2', 4, '1reallylongstring7', 8),
(5, '0reallylongstring1', 3, '1reallylongstring8', 9),
(5, '0reallylongstring1', 3, '1reallylongstring7', 10),
(5, '0reallylongstring1', 4, '1reallylongstring8', 11),
(5, '0reallylongstring1', 4, '1reallylongstring7', 12),
(5, '0reallylongstring2', 3, '1reallylongstring8', 13),
(5, '0reallylongstring2', 3, '1reallylongstring7', 14),
(5, '0reallylongstring2', 4, '1reallylongstring8', 15),
(5, '0reallylongstring2', 4, '1reallylongstring7', 16);
SELECT i1, s1, i2, s2 FROM test6 ORDER BY i1, s1, i2, s2;
SELECT s1, i1, i2, s2 FROM test6 ORDER BY s1, i1, i2, s2;
SELECT s1, i1, s2, i2 FROM test6 ORDER BY s1, i1, s2, i2;
SELECT s1, s2, i1, i2 FROM test6 ORDER BY s1, s2, i1, i2;
SELECT i1, i2, s1, s2 FROM test6 ORDER BY i1, i2, s1, s2;
SELECT s1, s2, i1, i2 FROM test6 ORDER BY i2 DESC, s1, s2, i1;
create table test7 (p_brand VARCHAR, p_type VARCHAR, p_size INT, supplier_cnt BIGINT, t BIGINT TIME INDEX);
insert into test7 values ('Brand#11', 'ECONOMY BRUSHED COPPER', 3, 4, 1), ('Brand#11', 'ECONOMY BRUSHED COPPER', 9, 4, 2), ('Brand#11', 'ECONOMY BRUSHED STEEL', 36, 4, 3), ('Brand#11', 'ECONOMY BRUSHED STEEL', 9, 4, 4), ('Brand#11', 'ECONOMY BURNISHED BRASS', 36, 4, 5), ('Brand#11', 'ECONOMY BURNISHED COPPER', 49, 4, 6), ('Brand#11', 'ECONOMY BURNISHED COPPER', 9, 4, 7), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 14, 4,8), ('Brand#11', 'ECONOMY BURNISHED NICKEL', 49, 4, 9);
SELECT p_brand, p_type, p_size, supplier_cnt FROM test7 ORDER BY supplier_cnt DESC, p_brand, p_type, p_size;
create table test8 (i int, s varchar, t BIGINT TIME INDEX);
insert into test8 values (3, 'aba', 1), (1, 'ccbcc', 2), (NULL, 'dbdbd', 3), (2, NULL, 4);
select i, split_part(s, 'b', 1) from test8 order by i;
CREATE TABLE DirectReports
(
EmployeeID smallint,
Name varchar NOT NULL,
Title varchar NOT NULL,
EmployeeLevel int NOT NULL,
Sort varchar NOT NULL,
Timestamp BIGINT TIME INDEX,
);
INSERT INTO DirectReports VALUES
(1, 'Ken Sánchez', 'Chief Executive Officer', 1, 'Ken Sánchez', 1),
(273, '>Brian Welcker', 'Vice President of Sales', 2, 'Ken Sánchez>Brian Welcker', 2),
(274, '>>Stephen Jiang', 'North American Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Stephen Jiang', 3),
(285, '>>Syed Abbas', 'Pacific Sales Manager', 3, 'Ken Sánchez>Brian Welcker>Syed Abbas', 4),
(16, '>>David Bradley', 'Marketing Manager', 3, 'Ken Sánchez>Brian Welcker>David Bradley', 5),
(275, '>>>Michael Blythe', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Stephen Jiang>Michael Blythe', 6),
(276, '>>>Linda Mitchell', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Stephen Jiang>Linda Mitchell', 7),
(286, '>>>Lynn Tsoflias', 'Sales Representative', 4, 'Ken Sánchez>Brian Welcker>Syed Abbas>Lynn Tsoflias', 8),
(23, '>>>Mary Gibson', 'Marketing Specialist', 4, 'Ken Sánchez>Brian Welcker>David Bradley>Mary Gibson', 9);
SELECT "EmployeeID", "Name", "Title", "EmployeeLevel"
FROM "DirectReports"
ORDER BY "Sort", "EmployeeID";
DROP TABLE t0;
DROP TABLE test0;
DROP TABLE test1;
DROP TABLE test4;
DROP TABLE tpch_q1_agg;
DROP TABLE test6;
DROP table test7;
DROP table test8;
DROP TABLE DirectReports;

View File

@@ -0,0 +1,88 @@
SELECT 2*3+1;
+--------------------------------+
| Int64(2) * Int64(3) + Int64(1) |
+--------------------------------+
| 7 |
+--------------------------------+
SELECT 1+2*3;
+--------------------------------+
| Int64(1) + Int64(2) * Int64(3) |
+--------------------------------+
| 7 |
+--------------------------------+
SELECT 2^2 + 1;
+--------------------------------+
| Int64(2) # Int64(2) + Int64(1) |
+--------------------------------+
| 1 |
+--------------------------------+
SELECT 1+2^2;
+--------------------------------+
| Int64(1) + Int64(2) # Int64(2) |
+--------------------------------+
| 1 |
+--------------------------------+
SELECT 2*4 / 2;
+--------------------------------+
| Int64(2) * Int64(4) / Int64(2) |
+--------------------------------+
| 4 |
+--------------------------------+
SELECT 2*(4 / 2);
+--------------------------------+
| Int64(2) * Int64(4) / Int64(2) |
+--------------------------------+
| 4 |
+--------------------------------+
SELECT 16/2*4;
+---------------------------------+
| Int64(16) / Int64(2) * Int64(4) |
+---------------------------------+
| 32 |
+---------------------------------+
SELECT (16/2)*4;
+---------------------------------+
| Int64(16) / Int64(2) * Int64(4) |
+---------------------------------+
| 32 |
+---------------------------------+
SELECT 2*3*2;
+--------------------------------+
| Int64(2) * Int64(3) * Int64(2) |
+--------------------------------+
| 12 |
+--------------------------------+
SELECT 2^3*2;
+--------------------------------+
| Int64(2) # Int64(3) * Int64(2) |
+--------------------------------+
| 4 |
+--------------------------------+
SELECT 2*3^2;
+--------------------------------+
| Int64(2) * Int64(3) # Int64(2) |
+--------------------------------+
| 4 |
+--------------------------------+

View File

@@ -0,0 +1,21 @@
SELECT 2*3+1;
SELECT 1+2*3;
SELECT 2^2 + 1;
SELECT 1+2^2;
SELECT 2*4 / 2;
SELECT 2*(4 / 2);
SELECT 16/2*4;
SELECT (16/2)*4;
SELECT 2*3*2;
SELECT 2^3*2;
SELECT 2*3^2;

View File

@@ -46,8 +46,11 @@ impl EnvController for Env {
}
/// Stop one [`Database`].
#[allow(clippy::print_stdout)]
async fn stop(&self, _mode: &str, mut database: Self::DB) {
database.server_process.kill().await.unwrap()
database.server_process.kill().await.unwrap();
let _ = database.server_process.wait().await;
println!("Stopped DB.");
}
}

View File

@@ -20,8 +20,17 @@ mod util;
#[tokio::main]
async fn main() {
let mut args: Vec<String> = std::env::args().collect();
let test_filter = if args.len() > 1 {
args.pop().unwrap()
} else {
"".to_string()
};
let config = ConfigBuilder::default()
.case_dir(util::get_case_dir())
.fail_fast(true)
.test_filter(test_filter)
.build()
.unwrap();
let runner = Runner::new_with_config(config, Env {}).await.unwrap();