From 6bdcb42da23006986ddf8b0dd48342c2f174aeb7 Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 20 Dec 2024 17:24:16 +0800 Subject: [PATCH 1/5] Init crate for sqllogictests --- Cargo.toml | 1 + crates/sqllogictest/Cargo.toml | 11 ++++++++ crates/sqllogictest/README.md | 16 +++++++++++ crates/sqllogictest/src/error.rs | 46 ++++++++++++++++++++++++++++++++ crates/sqllogictest/src/lib.rs | 21 +++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 crates/sqllogictest/Cargo.toml create mode 100644 crates/sqllogictest/README.md create mode 100644 crates/sqllogictest/src/error.rs create mode 100644 crates/sqllogictest/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 05f2d9073e..c2a6679304 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ members = [ "crates/iceberg", "crates/integration_tests", "crates/integrations/*", + "crates/sqllogictest", "crates/test_utils", ] exclude = ["bindings/python"] diff --git a/crates/sqllogictest/Cargo.toml b/crates/sqllogictest/Cargo.toml new file mode 100644 index 0000000000..d6c6982327 --- /dev/null +++ b/crates/sqllogictest/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "sqllogictest" +version.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true +license.workspace = true +rust-version.workspace = true + +[dependencies] +anyhow = { workspace = true } diff --git a/crates/sqllogictest/README.md b/crates/sqllogictest/README.md new file mode 100644 index 0000000000..43a979f96f --- /dev/null +++ b/crates/sqllogictest/README.md @@ -0,0 +1,16 @@ +This crate contains a suite of [sqllogictest](https://crates.io/crates/sqllogictest) tests that are used to validate [iceberg-rust](https://github.com/apache/iceberg-rust). + +## Running the tests + +Just run the following command: + +```bash +cargo test +``` + +## Sql Engines + +The tests are run against the following sql engines: + +* [Apache datafusion](https://crates.io/crates/datafusion) +* [Apache spark](https://github.com/apache/spark) \ No newline at end of file diff --git a/crates/sqllogictest/src/error.rs b/crates/sqllogictest/src/error.rs new file mode 100644 index 0000000000..ed47054fe2 --- /dev/null +++ b/crates/sqllogictest/src/error.rs @@ -0,0 +1,46 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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 std::fmt::{Debug, Display, Formatter}; + +pub struct Error(pub anyhow::Error); + +pub type Result = std::result::Result; + +impl Debug for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self.0) + } +} + +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +impl std::error::Error for Error { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.0.source() + } +} + +impl From for Error { + fn from(value: anyhow::Error) -> Self { + Self(value) + } +} \ No newline at end of file diff --git a/crates/sqllogictest/src/lib.rs b/crates/sqllogictest/src/lib.rs new file mode 100644 index 0000000000..e789d54482 --- /dev/null +++ b/crates/sqllogictest/src/lib.rs @@ -0,0 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. + +// This lib contains codes copied from +// [Apache Datafusion](https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest) + +mod error; \ No newline at end of file From 59e4ad2d075cca208d3d68c740dcab55c9a2693d Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 20 Dec 2024 17:27:17 +0800 Subject: [PATCH 2/5] Fix formatter Signed-off-by: liurenjie1024 --- crates/sqllogictest/src/error.rs | 2 +- crates/sqllogictest/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/sqllogictest/src/error.rs b/crates/sqllogictest/src/error.rs index ed47054fe2..01eb364e2a 100644 --- a/crates/sqllogictest/src/error.rs +++ b/crates/sqllogictest/src/error.rs @@ -43,4 +43,4 @@ impl From for Error { fn from(value: anyhow::Error) -> Self { Self(value) } -} \ No newline at end of file +} diff --git a/crates/sqllogictest/src/lib.rs b/crates/sqllogictest/src/lib.rs index e789d54482..c31bc66e89 100644 --- a/crates/sqllogictest/src/lib.rs +++ b/crates/sqllogictest/src/lib.rs @@ -18,4 +18,4 @@ // This lib contains codes copied from // [Apache Datafusion](https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest) -mod error; \ No newline at end of file +mod error; From 68ae6bf9a26ddcbd073a8d56a0be64f6685f2ffc Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 20 Dec 2024 17:32:49 +0800 Subject: [PATCH 3/5] Make formatter happy --- crates/sqllogictest/Cargo.toml | 12 ++++++------ crates/sqllogictest/src/lib.rs | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/crates/sqllogictest/Cargo.toml b/crates/sqllogictest/Cargo.toml index d6c6982327..9a0c9cd5c8 100644 --- a/crates/sqllogictest/Cargo.toml +++ b/crates/sqllogictest/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "sqllogictest" -version.workspace = true -edition.workspace = true -homepage.workspace = true -repository.workspace = true -license.workspace = true -rust-version.workspace = true +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +repository = { workspace = true } +license = { workspace = true } +rust-version = { workspace = true } [dependencies] anyhow = { workspace = true } diff --git a/crates/sqllogictest/src/lib.rs b/crates/sqllogictest/src/lib.rs index c31bc66e89..196d16c630 100644 --- a/crates/sqllogictest/src/lib.rs +++ b/crates/sqllogictest/src/lib.rs @@ -18,4 +18,5 @@ // This lib contains codes copied from // [Apache Datafusion](https://github.com/apache/datafusion/tree/main/datafusion/sqllogictest) +#[allow(dead_code)] mod error; From 339c264cf55a583e2d06277dd2b330573e94ddda Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 20 Dec 2024 17:44:21 +0800 Subject: [PATCH 4/5] Header --- crates/sqllogictest/Cargo.toml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/sqllogictest/Cargo.toml b/crates/sqllogictest/Cargo.toml index 9a0c9cd5c8..7c596159fe 100644 --- a/crates/sqllogictest/Cargo.toml +++ b/crates/sqllogictest/Cargo.toml @@ -1,3 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + [package] name = "sqllogictest" version = { workspace = true } From 9c5d6521767018c37825bef91557eb51bfe6338b Mon Sep 17 00:00:00 2001 From: liurenjie1024 Date: Fri, 20 Dec 2024 17:53:46 +0800 Subject: [PATCH 5/5] Header for README --- crates/sqllogictest/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/sqllogictest/README.md b/crates/sqllogictest/README.md index 43a979f96f..ddcfe851c5 100644 --- a/crates/sqllogictest/README.md +++ b/crates/sqllogictest/README.md @@ -1,3 +1,22 @@ + + This crate contains a suite of [sqllogictest](https://crates.io/crates/sqllogictest) tests that are used to validate [iceberg-rust](https://github.com/apache/iceberg-rust). ## Running the tests