fluss/metadata/data_lake_format.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use strum_macros::{Display, EnumString};
19
20/// Identifies the logical format of a data lake table supported by Fluss.
21///
22/// This enum is typically used in metadata and configuration to distinguish
23/// between different table formats so that the appropriate integration and
24/// semantics can be applied.
25#[derive(Debug, EnumString, Display, PartialEq)]
26#[strum(ascii_case_insensitive)]
27pub enum DataLakeFormat {
28 #[strum(serialize = "paimon")]
29 Paimon,
30
31 #[strum(serialize = "lance")]
32 Lance,
33
34 #[strum(serialize = "iceberg")]
35 Iceberg,
36}
37
38#[cfg(test)]
39mod tests {
40 use crate::metadata::DataLakeFormat;
41 use crate::metadata::DataLakeFormat::{Iceberg, Lance, Paimon};
42
43 #[test]
44 fn test_parse() {
45 let cases = vec![
46 ("paimon", Paimon),
47 ("Paimon", Paimon),
48 ("PAIMON", Paimon),
49 ("lance", Lance),
50 ("LANCE", Lance),
51 ("iceberg", Iceberg),
52 ("ICEBERG", Iceberg),
53 ];
54
55 for (raw, expected) in cases {
56 let parsed = raw.parse::<DataLakeFormat>().unwrap();
57 assert_eq!(parsed, expected, "failed to parse: {raw}");
58 }
59
60 // negative cases
61 assert!("unknown".parse::<DataLakeFormat>().is_err());
62 assert!("".parse::<DataLakeFormat>().is_err());
63 }
64}