substrait_extensions/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2
3//! Packaged Substrait extension files.
4//!
5//! This crate bundles the Substrait specification's extension YAML files, the
6//! text-based JSON schemas, and the function test cases, alongside Rust types
7//! generated from the schemas with [`typify`](https://docs.rs/typify).
8//!
9//! Versions of this crate correspond to Substrait
10//! [releases](https://github.com/substrait-io/substrait/releases).
11//!
12//! - [`text`] — types generated from the text schemas (e.g.
13//! [`text::simple_extensions::SimpleExtensions`]), plus the raw schema
14//! sources as consts (e.g. `text::SIMPLE_EXTENSIONS_SCHEMA`) for consumers
15//! that validate raw YAML against the JSON schema.
16//! - [`extensions`] — the embedded extension YAML files, the
17//! [`extensions::EXTENSIONS`] map (keyed by file stem to the parsed
18//! extension), and the [`extensions::SIMPLE_EXTENSIONS`] slice (keyed by URN
19//! to the raw YAML source).
20//! - [`testcases`] — the embedded function test case files.
21//! - [`examples`] — the embedded example extension and type YAML files from the
22//! specification's documentation. These are illustrations, not catalog
23//! entries: they are deliberately absent from [`extensions::EXTENSIONS`] and
24//! [`extensions::SIMPLE_EXTENSIONS`], their URNs use the
25//! `extension:org.example:` owner, and they carry no compatibility guarantee.
26//! They are useful as fixtures for testing an extension parser.
27
28/// Types generated from the Substrait text-based JSON schemas, plus the raw
29/// schema sources as `&str` consts (e.g. `SIMPLE_EXTENSIONS_SCHEMA`).
30#[allow(
31 unused_variables,
32 clippy::clone_on_copy,
33 clippy::derivable_impls,
34 clippy::needless_borrow,
35 clippy::explicit_auto_deref,
36 clippy::to_string_trait_impl,
37 clippy::uninlined_format_args
38)]
39pub mod text {
40 include!(concat!(env!("OUT_DIR"), "/substrait_text.rs"));
41}
42
43/// The embedded Substrait core extension YAML files.
44///
45/// The contents of this module are auto-generated by `build.rs` and kept in
46/// sync with the packaged extension files.
47pub mod extensions {
48 include!(concat!(env!("OUT_DIR"), "/extensions.in"));
49}
50
51/// The embedded Substrait function test case files.
52pub mod testcases {
53 use include_dir::{include_dir, Dir};
54
55 /// The directory tree of `.test` function test case files.
56 pub static TESTCASES: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/testcases");
57}
58
59/// The embedded example extension and type YAML files.
60///
61/// These come from the specification's documentation (`site/examples`) and are
62/// illustrations of the simple-extension format, not entries in the Substrait
63/// extension catalog. They are not registered in [`extensions::EXTENSIONS`] or
64/// [`extensions::SIMPLE_EXTENSIONS`], and their contents and URNs may change
65/// without a deprecation cycle.
66pub mod examples {
67 use include_dir::{include_dir, Dir};
68
69 /// The directory tree of example `.yaml` files, under `extensions/` and
70 /// `types/`.
71 pub static EXAMPLES: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/examples");
72}