diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf8fe12b..b8a22c95 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,8 +3,8 @@ name: Rust on: pull_request: push: - branches: [ main ] - tags: [ 'v*.*.*' ] + branches: [main] + tags: ["v*.*.*"] jobs: check: @@ -105,7 +105,7 @@ jobs: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [ check, test ] + needs: [check, test] environment: VALIDATOR_RELEASE steps: - uses: actions/checkout@v2 @@ -129,9 +129,6 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} run: cargo publish --allow-dirty - - name: Wait for substrait-validator-derive to appear in the index - continue-on-error: true - run: python3 ci/crates-io-wait.py substrait-validator-derive `cat ci/version` 1800 - name: Publish substrait-validator working-directory: rs env: diff --git a/ci/crates-io-wait.py b/ci/crates-io-wait.py deleted file mode 100644 index a37fd965..00000000 --- a/ci/crates-io-wait.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/python3 -# SPDX-License-Identifier: Apache-2.0 - -""" -Waits for a crate to appear on crates.io, since cargo publish doesn't. -See https://github.com/rust-lang/cargo/issues/9507 -""" - - -import urllib.request -import json -import sys -import time -import argparse - - -def crate_version_exists(crate, version): - """Returns whether the given version of the given crate exists on the - crates.io index.""" - - # Fetch the version info for the crate. - with urllib.request.urlopen( - "https://raw.githubusercontent.com/rust-lang/crates.io-index/" - f"master/{crate[0:2]}/{crate[2:4]}/{crate}" - ) as f: - data = f.read() - - # Parse version info. - versions = list(map(json.loads, data.decode("utf-8").strip().split("\n"))) - - # Check whether the requested version exists. - for version_data in versions: - if version_data.get("vers", None) == version: - return True - return False - - -def check(crate, version): - """Exits with code 0 if the given crate + version is found.""" - - try: - if crate_version_exists(crate, version): - print("Crate found!") - sys.exit(0) - except Exception as e: - print(f"{type(e).__name__}: {e}") - - -if __name__ == "__main__": - - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("crate", type=str, help="the crate to wait for") - parser.add_argument("version", type=str, help="the version to wait for") - parser.add_argument("timeout", type=int, help="number of seconds to wait") - args = parser.parse_args() - - print("Checking...") - check(args.crate, args.version) - - wait_remain = args.timeout - period = 10 - while wait_remain > 0: - print(f"Waiting {period}s...", flush=True) - time.sleep(period) - wait_remain -= period - period = int(period * 1.25) - - print("Checking...", flush=True) - check(args.crate, args.version) - - print("Timeout expired!") - sys.exit(1) diff --git a/rs/build.rs b/rs/build.rs index ba75100c..72647245 100644 --- a/rs/build.rs +++ b/rs/build.rs @@ -137,6 +137,10 @@ fn main() -> Result<()> { // Compile the protobuf files using prost. let mut config = prost_build::Config::new(); config.type_attribute(".", "#[derive(::substrait_validator_derive::ProtoMeta)]"); + config.disable_comments([ + "substrait.AggregateRel.Measure.filter", + "substrait.Type.Parameter.data_type", + ]); config.compile_protos(&proto_files, &[&proto_path.display().to_string()])?; // Inform cargo that changes to the .proto files require a rerun. diff --git a/rs/src/input/config.rs b/rs/src/input/config.rs index c559aba4..610f1c0a 100644 --- a/rs/src/input/config.rs +++ b/rs/src/input/config.rs @@ -72,12 +72,12 @@ pub struct Config { /// pre-downloaded files. pub uri_overrides: Vec<(glob::Pattern, Option)>, - /// Optional callback function for resolving URIs. If specified, all - /// URIs (after processing yaml_uri_overrides) are resolved using this - /// function. The function takes the URI as its argument, and should either - /// return the download contents as a Vec or return a String-based - /// error. If no downloader is specified, only file:// URLs with an - /// absolute path are supported. + /// Optional callback function for resolving URIs. If specified, all URIs + /// (after processing yaml_uri_overrides) are resolved using this function. + /// The function takes the URI as its argument, and should either return the + /// download contents as a `Vec` or return a String-based error. If no + /// downloader is specified, only file:// URLs with an absolute path are + /// supported. pub uri_resolver: Option, /// Optional URI resolution depth. If specified, dependencies are only diff --git a/rs/src/lib.rs b/rs/src/lib.rs index 3987cdb3..6a86e812 100644 --- a/rs/src/lib.rs +++ b/rs/src/lib.rs @@ -9,7 +9,7 @@ //! 1) Build a [`Config`] structure to configure the validator. You can also //! just use [`std::default::Default`] if you don't need to configure //! anything, but you might want to at least call -//! [`Config::add_curl_uri_resolver()`] (if you're using the `curl` +//! `Config::add_curl_uri_resolver()` (if you're using the `curl` //! feature). //! 2) Parse the incoming `substrait.Plan` message using [`parse()`]. This //! creates a [ParseResult], containing a [tree](output::tree) structure diff --git a/rs/src/output/type_system/data/type.rs b/rs/src/output/type_system/data/type.rs index 5726398a..56525287 100644 --- a/rs/src/output/type_system/data/type.rs +++ b/rs/src/output/type_system/data/type.rs @@ -210,7 +210,7 @@ impl Definition { ) } - /// Returns Some(Vec)) when this is a STRUCT or NSTRUCT type, where the + /// Returns `Some(Vec))` when this is a STRUCT or NSTRUCT type, where the /// vector contains the field types. Returns None otherwise. pub fn unwrap_struct(&self) -> Option>> { if self.is_struct() { diff --git a/rs/src/parse/context.rs b/rs/src/parse/context.rs index 15338a3e..ea8501e1 100644 --- a/rs/src/parse/context.rs +++ b/rs/src/parse/context.rs @@ -152,13 +152,7 @@ impl<'a> Context<'a> { .unwrap_or(&(diagnostic::Level::Info, diagnostic::Level::Error)); // Adjust the level. - let adjusted_level = if diag.level < *min { - *min - } else if diag.level > *max { - *max - } else { - diag.level - }; + let adjusted_level = diag.level.clamp(*min, *max); let adjusted = diag.adjust_level(adjusted_level); // Actually push the data item. diff --git a/rs/src/parse/expressions/literals.rs b/rs/src/parse/expressions/literals.rs index f9e4581e..d3bc281b 100644 --- a/rs/src/parse/expressions/literals.rs +++ b/rs/src/parse/expressions/literals.rs @@ -174,7 +174,7 @@ impl Describe for Literal { _ => write!(f, "{i}"), }, LiteralValue::Float(v) => { - let max = std::cmp::min(std::cmp::max(3, limit.chars()), 10); + let max = limit.chars().clamp(3, 10); write!(f, "{:3.1$}", float_pretty_print::PrettyPrintFloat(*v), max) } LiteralValue::Data16(d) => match self.data_type.class() {