diff --git a/Cargo.toml b/Cargo.toml index 02e4365..f77154f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,14 +15,17 @@ # specific language governing permissions and limitations # under the License. -[package] -categories = ["command-line-utilities"] -description = "The rust implementation of paimon" -documentation = "https://docs.rs/paimon" -repository = "https://github.com/apache/paimon-rust" -edition = "2021" -license = "Apache-2.0" -name = "paimon" +[workspace] +resolver = "2" +members = [ + "crates/paimon", +] + +[workspace.package] version = "0.0.0" +edition = "2021" +homepage = "https://paimon.apache.org/" -[dependencies] +repository = "https://github.com/apache/paimon-rust" +license = "Apache-2.0" +rust-version = "1.77.1" diff --git a/crates/paimon/Cargo.toml b/crates/paimon/Cargo.toml new file mode 100644 index 0000000..1754ee6 --- /dev/null +++ b/crates/paimon/Cargo.toml @@ -0,0 +1,31 @@ +# 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] +categories = ["command-line-utilities"] +description = "The rust implementation of paimon" +documentation = "https://docs.rs/paimon" +repository = "https://github.com/apache/paimon-rust" +edition = "2021" +license = "Apache-2.0" +name = "paimon" +version = "0.0.0" + +[dependencies] +serde = { version = "1", features = ["derive"] } +serde_with = "3.8.3" +snafu = "0.8.3" diff --git a/crates/paimon/src/error.rs b/crates/paimon/src/error.rs new file mode 100644 index 0000000..f615649 --- /dev/null +++ b/crates/paimon/src/error.rs @@ -0,0 +1,30 @@ +// 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 snafu::Snafu; + +/// Error type for paimon. +#[allow(dead_code)] +#[derive(Debug, Snafu)] +pub enum Error { + #[snafu(display("paimon data invalid for {}: {:?}", message, source))] + DataInvalid { + message: String, + #[snafu(backtrace)] + source: snafu::Whatever, + }, +} diff --git a/src/lib.rs b/crates/paimon/src/lib.rs similarity index 86% rename from src/lib.rs rename to crates/paimon/src/lib.rs index 7814abf..bf367f0 100644 --- a/src/lib.rs +++ b/crates/paimon/src/lib.rs @@ -15,11 +15,5 @@ // specific language governing permissions and limitations // under the License. -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - let result = 2 + 2; - assert_eq!(result, 4); - } -} \ No newline at end of file +mod error; +pub mod spec; diff --git a/crates/paimon/src/spec/mod.rs b/crates/paimon/src/spec/mod.rs new file mode 100644 index 0000000..d38d407 --- /dev/null +++ b/crates/paimon/src/spec/mod.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. + +//! Spec module for paimon. +//! +//! All paimon specs types are defined here. + +mod schema; diff --git a/crates/paimon/src/spec/schema.rs b/crates/paimon/src/spec/schema.rs new file mode 100644 index 0000000..b6a5498 --- /dev/null +++ b/crates/paimon/src/spec/schema.rs @@ -0,0 +1,84 @@ +// 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 crate::error::Error; +use serde::{Deserialize, Serialize}; +use serde_with::{serde_as, DisplayFromStr}; +use std::collections::HashMap; +use std::fmt::{Display, Formatter}; +use std::str::FromStr; + +/// The table schema for paimon table. +/// +/// Impl References: +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct TableSchema { + /// version of schema for paimon + version: i32, + id: i64, + fields: Vec, + highest_field_id: i32, + partition_keys: Vec, + primary_keys: Vec, + options: HashMap, + comment: Option, + time_millis: i64, +} + +/// Data field for paimon table. +/// +/// Impl Reference: +#[serde_as] +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] +pub struct DataField { + id: i32, + name: String, + #[serde(rename = "type")] + #[serde_as(as = "DisplayFromStr")] + typ: DataType, + description: Option, +} + +/// Data type for paimon table. +/// +/// Impl Reference: +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct DataType { + is_nullable: bool, + type_root: DataTypeRoot, +} + +impl Display for DataType { + fn fmt(&self, _: &mut Formatter<'_>) -> std::fmt::Result { + todo!() + } +} + +impl FromStr for DataType { + type Err = Error; + + fn from_str(_: &str) -> Result { + todo!() + } +} + +/// The root of data type. +/// +/// Impl Reference: +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum DataTypeRoot {}