From 7d1f09b48128da808b8e766080d8d59f758e336c Mon Sep 17 00:00:00 2001 From: Renjie Liu Date: Sat, 21 Dec 2024 10:11:11 +0800 Subject: [PATCH] Add crate for sqllogictest. (#827) --- Cargo.toml | 1 + crates/sqllogictest/Cargo.toml | 28 +++++++++++++++++++ crates/sqllogictest/README.md | 35 ++++++++++++++++++++++++ crates/sqllogictest/src/error.rs | 46 ++++++++++++++++++++++++++++++++ crates/sqllogictest/src/lib.rs | 22 +++++++++++++++ 5 files changed, 132 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 05f2d9073..c2a667930 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 000000000..7c596159f --- /dev/null +++ b/crates/sqllogictest/Cargo.toml @@ -0,0 +1,28 @@ +# 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 } +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 000000000..ddcfe851c --- /dev/null +++ b/crates/sqllogictest/README.md @@ -0,0 +1,35 @@ + + +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 000000000..01eb364e2 --- /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) + } +} diff --git a/crates/sqllogictest/src/lib.rs b/crates/sqllogictest/src/lib.rs new file mode 100644 index 000000000..196d16c63 --- /dev/null +++ b/crates/sqllogictest/src/lib.rs @@ -0,0 +1,22 @@ +// 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) + +#[allow(dead_code)] +mod error;