liurenjie1024 commented on code in PR #1621: URL: https://github.com/apache/iceberg-rust/pull/1621#discussion_r2315641281
########## crates/sqllogictest/src/schedule.rs: ########## @@ -0,0 +1,153 @@ +// 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::anyhow; +use itertools::Itertools; +use toml::{Table, Value}; + +use crate::engine::{EngineRunner, load_engine}; + +/// Schedule of engines to run tests. +/// Controls the engine, storage, and catalog being used for the test steps +pub struct Schedule { + // Map of engine names to engine instances. + engines: HashMap<String, Box<dyn EngineRunner>>, + // List of steps to run, each step is a sql file. + steps: Vec<Step>, + // catalog: Box<dyn Catalog>, +} + +pub struct Step { + /// Name of engine to execute. + engine_name: String, + /// Name of sql file. + sql: String, +} + +impl Schedule { + pub async fn parse<P: AsRef<Path>>(schedule_def_file: P) -> anyhow::Result<Self> { + let content = read_to_string(schedule_def_file)?; + let toml_value = content.parse::<Value>()?; + let toml_table = toml_value + .as_table() + .ok_or_else(|| anyhow::anyhow!("Schedule file must be a TOML table"))?; + + let engines = Schedule::parse_engines(toml_table).await?; + let steps = Schedule::parse_steps(toml_table).await?; + + Ok(Self { engines, steps }) + } + + async fn parse_engines( Review Comment: The parsing logic maintained manually. Would be nice if we could use `ser/de` framework for them. -- 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]
