liurenjie1024 commented on code in PR #1630:
URL: https://github.com/apache/iceberg-rust/pull/1630#discussion_r2306844085


##########
crates/sqllogictest/src/schedule.rs:
##########
@@ -0,0 +1,183 @@
+// 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::collections::HashMap;
+use std::fs::read_to_string;
+use std::path::{Path, PathBuf};
+
+use anyhow::{Context, anyhow};
+use serde::{Deserialize, Serialize};
+use toml::{Table as TomlTable, Value};
+use tracing::info;
+
+use crate::engine::Engine;
+
+pub struct Schedule {
+    /// Engine names to engine instances
+    engines: HashMap<String, Engine>,
+    /// List of test steps to run
+    steps: Vec<Step>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Step {
+    /// Engine name
+    engine: String,
+    /// Stl file path
+    slt: String,
+}
+
+impl Schedule {
+    pub fn new(engines: HashMap<String, Engine>, steps: Vec<Step>) -> Self {
+        Self { engines, steps }
+    }
+
+    pub async fn from_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
+        let content = read_to_string(path)?;
+        let toml_value = content.parse::<Value>()?;
+        let toml_table = toml_value
+            .as_table()
+            .ok_or_else(|| anyhow!("Schedule file must be a TOML table"))?;
+
+        let engines = Schedule::parse_engines(toml_table).await?;
+        let steps = Schedule::parse_steps(toml_table)?;
+
+        Ok(Self::new(engines, steps))
+    }
+
+    pub async fn run(mut self) -> anyhow::Result<()> {

Review Comment:
   Add a log about current schedule file?



##########
crates/sqllogictest/src/schedule.rs:
##########
@@ -0,0 +1,183 @@
+// 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::collections::HashMap;
+use std::fs::read_to_string;
+use std::path::{Path, PathBuf};
+
+use anyhow::{Context, anyhow};
+use serde::{Deserialize, Serialize};
+use toml::{Table as TomlTable, Value};
+use tracing::info;
+
+use crate::engine::Engine;
+
+pub struct Schedule {
+    /// Engine names to engine instances
+    engines: HashMap<String, Engine>,
+    /// List of test steps to run
+    steps: Vec<Step>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Step {
+    /// Engine name
+    engine: String,
+    /// Stl file path
+    slt: String,
+}
+
+impl Schedule {
+    pub fn new(engines: HashMap<String, Engine>, steps: Vec<Step>) -> Self {
+        Self { engines, steps }
+    }
+
+    pub async fn from_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
+        let content = read_to_string(path)?;
+        let toml_value = content.parse::<Value>()?;
+        let toml_table = toml_value
+            .as_table()
+            .ok_or_else(|| anyhow!("Schedule file must be a TOML table"))?;
+
+        let engines = Schedule::parse_engines(toml_table).await?;
+        let steps = Schedule::parse_steps(toml_table)?;
+
+        Ok(Self::new(engines, steps))
+    }
+
+    pub async fn run(mut self) -> anyhow::Result<()> {
+        for (idx, step) in self.steps.iter().enumerate() {
+            info!(
+                "Running step {}/{}, using engine {}, slt file path: {}",
+                idx + 1,
+                self.steps.len(),
+                &step.engine,
+                &step.slt
+            );
+
+            let engine = self
+                .engines
+                .get_mut(&step.engine)
+                .ok_or_else(|| anyhow!("Engine {} not found", step.engine))?;
+
+            engine
+                .run_slt_file(&PathBuf::from(step.slt.clone()))

Review Comment:
   This maybe a potential issue, the file path is relative to testdata dir, but 
we could fix it later.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to