Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(extensions): include Substrait core extensions #187

Merged
merged 3 commits into from
May 21, 2024

Conversation

shanretoo
Copy link
Contributor

@shanretoo shanretoo commented May 18, 2024

Include core extensions from Subtrait.
The majority of the code originates from the un-merged pr #89.

The generated code:

// SPDX-License-Identifier: Apache-2.0
// Note that this file is auto-generated and auto-synced using `build.rs`. It is
// included in `extensions.rs`.

/// Included source of [`functions_datetime`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_datetime.yaml).
const FUNCTIONS_DATETIME: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_datetime.yaml");

/// Included source of [`functions_comparison`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_comparison.yaml).
const FUNCTIONS_COMPARISON: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_comparison.yaml");

/// Included source of [`functions_geometry`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_geometry.yaml).
const FUNCTIONS_GEOMETRY: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_geometry.yaml");

/// Included source of [`functions_aggregate_approx`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_aggregate_approx.yaml).
const FUNCTIONS_AGGREGATE_APPROX: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_aggregate_approx.yaml");

/// Included source of [`functions_logarithmic`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_logarithmic.yaml).
const FUNCTIONS_LOGARITHMIC: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_logarithmic.yaml");

/// Included source of [`unknown`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/unknown.yaml).
const UNKNOWN: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/unknown.yaml");

/// Included source of [`type_variations`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/type_variations.yaml).
const TYPE_VARIATIONS: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/type_variations.yaml");

/// Included source of [`functions_string`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_string.yaml).
const FUNCTIONS_STRING: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_string.yaml");

/// Included source of [`extension_types`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/extension_types.yaml).
const EXTENSION_TYPES: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/extension_types.yaml");

/// Included source of [`functions_arithmetic`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_arithmetic.yaml).
const FUNCTIONS_ARITHMETIC: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_arithmetic.yaml");

/// Included source of [`functions_rounding`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_rounding.yaml).
const FUNCTIONS_ROUNDING: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_rounding.yaml");

/// Included source of [`functions_aggregate_generic`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_aggregate_generic.yaml).
const FUNCTIONS_AGGREGATE_GENERIC: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_aggregate_generic.yaml");

/// Included source of [`functions_boolean`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_boolean.yaml).
const FUNCTIONS_BOOLEAN: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_boolean.yaml");

/// Included source of [`functions_arithmetic_decimal`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_arithmetic_decimal.yaml).
const FUNCTIONS_ARITHMETIC_DECIMAL: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_arithmetic_decimal.yaml");

/// Included source of [`functions_set`](https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_set.yaml).
const FUNCTIONS_SET: &str = include_str!("/Users/awfover/Projects/substrait-rs/substrait/extensions/functions_set.yaml");

use std::collections::HashMap;
use std::str::FromStr;
use once_cell::sync::Lazy;
use crate::text::simple_extensions::SimpleExtensions;
use url::Url;

/// Map with Substrait core extensions. Maps URIs to included extensions.
pub static EXTENSIONS: Lazy<HashMap<Url, SimpleExtensions>> = Lazy::new(|| {
    let mut map = HashMap::new();
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/extension_types.yaml").expect("a valid url"), serde_yaml::from_str(EXTENSION_TYPES).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_geometry.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_GEOMETRY).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_aggregate_approx.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_AGGREGATE_APPROX).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/unknown.yaml").expect("a valid url"), serde_yaml::from_str(UNKNOWN).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_boolean.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_BOOLEAN).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_logarithmic.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_LOGARITHMIC).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/type_variations.yaml").expect("a valid url"), serde_yaml::from_str(TYPE_VARIATIONS).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_set.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_SET).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_string.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_STRING).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_datetime.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_DATETIME).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_comparison.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_COMPARISON).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_aggregate_generic.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_AGGREGATE_GENERIC).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_arithmetic_decimal.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_ARITHMETIC_DECIMAL).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_rounding.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_ROUNDING).expect("a valid core extension"));
    map.insert(Url::from_str("https://github.com/substrait-io/substrait/raw/v0.48.0/extensions/functions_arithmetic.yaml").expect("a valid url"), serde_yaml::from_str(FUNCTIONS_ARITHMETIC).expect("a valid core extension"));
    map
});

Copy link
Member

@mbrobbel mbrobbel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

I took the liberty of making some small changes to this PR:

Let me know if this makes sense to you.

@shanretoo
Copy link
Contributor Author

shanretoo commented May 21, 2024

Thanks for your changes.
I made a minor change to keep the generated code more human readable and updated the pr description.

@mbrobbel mbrobbel merged commit b9fba0f into substrait-io:main May 21, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants