Skip to main content

substrait/
extensions.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Substrait core extensions
4//!
5//! The extension files are provided by the
6//! [`substrait-extensions`](https://docs.rs/substrait-extensions) crate. This
7//! module exposes them keyed by their [`Urn`].
8
9use std::collections::HashMap;
10use std::str::FromStr;
11use std::sync::LazyLock;
12
13use crate::text::simple_extensions::SimpleExtensions;
14use crate::urn::Urn;
15
16/// Map with Substrait core extensions. Maps [`Urn`]s to included extensions.
17pub static EXTENSIONS: LazyLock<HashMap<Urn, SimpleExtensions>> = LazyLock::new(|| {
18    substrait_extensions::extensions::EXTENSIONS
19        .iter()
20        .map(|(name, extension)| {
21            let urn = Urn::from_str(&format!("extension:io.substrait:{name}")).expect("valid urn");
22            (urn, extension.clone())
23        })
24        .collect()
25});
26
27#[cfg(test)]
28mod tests {
29    use super::*;
30
31    #[test]
32    fn core_extensions() {
33        // Force evaluation of core extensions.
34        LazyLock::force(&EXTENSIONS);
35    }
36}