Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]

resolver = "2"
members = [
"derive",
"rs",
Expand Down
2 changes: 1 addition & 1 deletion rs/src/input/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Module for representing Substrait protobuf input.
//!
//! The structures here are generated using [`prost`], but have a bunch of
//! extra traits from [`traits`](crate::input::traits) associated with them,
//! extra traits from [`traits`] associated with them,
//! for which the implementations are generated using
//! [`substrait_validator_derive`]. The purpose of these traits is to add basic
//! introspection capabilities to the prost structures. One of the use cases
Expand Down
8 changes: 2 additions & 6 deletions rs/src/output/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ impl From<jsonschema::error::ValidationError<'_>> for Message {
strum_macros::EnumIter,
strum_macros::EnumProperty,
num_derive::FromPrimitive,
Default,
)]
pub enum Classification {
// Unclassified diagnostics (group 0).
#[strum(props(HiddenDescription = "unclassified diagnostic"))]
#[default]
Unclassified = 0,

#[strum(props(Description = "not yet implemented"))]
Expand Down Expand Up @@ -368,12 +370,6 @@ pub enum Classification {
RedundantEnumVariant = 7008,
}

impl Default for Classification {
fn default() -> Self {
Classification::Unclassified
}
}

impl Classification {
/// Returns the complete code for this classification.
pub fn code(&self) -> u32 {
Expand Down
9 changes: 2 additions & 7 deletions rs/src/output/type_system/data/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ pub trait ParameterInfo {
}

/// Type class.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash, Default)]
pub enum Class {
/// Unresolved type. Used for error recovery.
#[default]
Unresolved,

/// Well-known simple type.
Expand All @@ -53,12 +54,6 @@ pub enum Class {
UserDefined(extension::simple::type_class::Reference),
}

impl Default for Class {
fn default() -> Self {
Class::Unresolved
}
}

impl std::fmt::Display for Class {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down
9 changes: 2 additions & 7 deletions rs/src/output/type_system/data/variation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@
use crate::output::extension;

/// A type variation.
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum Variation {
/// The special system-preferred variation, also known as \[0\].
#[default]
SystemPreferred,

/// Reference to a user-defined variation.
UserDefined(extension::simple::type_variation::Reference),
}

impl Default for Variation {
fn default() -> Self {
Variation::SystemPreferred
}
}

impl std::fmt::Display for Variation {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Expand Down
8 changes: 2 additions & 6 deletions rs/src/output/type_system/meta/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ use super::Pattern;
/// A function that operates on zero or more values.
#[derive(Clone, Debug, PartialEq, Eq, strum_macros::Display, strum_macros::EnumString)]
#[strum(serialize_all = "snake_case")]
#[derive(Default)]
pub enum Function {
/// Used for unknown functions. Takes any number of arguments, doesn't
/// evaluate them, and yields an unresolved value.
#[strum(serialize = "!")]
#[default]
Unresolved,

/// Boolean not: `not(metabool) -> metabool`
Expand Down Expand Up @@ -76,12 +78,6 @@ pub enum Function {
IfThenElse,
}

impl Default for Function {
fn default() -> Self {
Function::Unresolved
}
}

impl Function {
/// Evaluates this function.
pub fn evaluate(
Expand Down
9 changes: 2 additions & 7 deletions rs/src/output/type_system/meta/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ pub trait Pattern {
/// it acts like an expression and is evaluated; see [Pattern::evaluate()]
/// and [Pattern::evaluate_with_context()]. This either fails or yields a
/// [meta::Value].
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum Value {
/// Used when a pattern is unknown due to validator-specific error
/// recovery. Matches all values, and evaluates to an unresolved value.
/// Syntax (only for printing): `!`.
#[default]
Unresolved,

/// Accepts any meta::Value. Cannot be evaluated. Syntax: `?`.
Expand Down Expand Up @@ -161,12 +162,6 @@ impl std::fmt::Display for Value {
}
}

impl Default for Value {
fn default() -> Self {
Value::Unresolved
}
}

impl Value {
/// Match the given value without being lenient about unresolved values.
/// Whenever this returns false, the public match_pattern_with_context()
Expand Down
9 changes: 2 additions & 7 deletions rs/src/output/type_system/meta/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
///
/// Note that the meta type system is much simpler than the data type system,
/// and cannot be extended.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum Type {
/// Special validator-specific value used when the type is unknown due to
/// recovery from previous errors.
#[default]
Unresolved,

/// Type for booleans and predicates. Syntax: `metabool` (to disambiguate
Expand Down Expand Up @@ -52,9 +53,3 @@ impl std::fmt::Display for Type {
}
}
}

impl Default for Type {
fn default() -> Self {
Type::Unresolved
}
}
9 changes: 2 additions & 7 deletions rs/src/output/type_system/meta/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use crate::util;
use crate::util::string::Describe;

/// The value enumeration for metatypes ([`meta::Type`]).
#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq, Default)]
pub enum Value {
/// Special validator-specific value used when the value is unknown due to
/// recovery from previous errors.
#[default]
Unresolved,

/// Used for boolean values. Syntax: `true` or `false`.
Expand Down Expand Up @@ -56,12 +57,6 @@ impl std::fmt::Display for Value {
}
}

impl Default for Value {
fn default() -> Self {
Value::Unresolved
}
}

impl From<bool> for Value {
fn from(x: bool) -> Self {
Value::Boolean(x)
Expand Down
9 changes: 2 additions & 7 deletions rs/src/parse/expressions/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ pub enum FunctionType {
}

/// A function argument; either a value, a type, or an enum option.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Default)]
pub enum FunctionArgument {
/// Used when a function argument is so malformed that not even the type of
/// argument is known.
#[default]
Unresolved,

/// Used for value arguments or normal expressions.
Expand All @@ -45,12 +46,6 @@ pub enum FunctionArgument {
Enum(String),
}

impl Default for FunctionArgument {
fn default() -> Self {
FunctionArgument::Unresolved
}
}

impl Describe for FunctionArgument {
fn describe(
&self,
Expand Down
9 changes: 2 additions & 7 deletions rs/src/parse/expressions/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ use crate::util::string::Describe;
use std::sync::Arc;

/// The value of a literal, not including type information.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Default)]
enum LiteralValue {
/// May be used for any nullable type.
#[default]
Null,

/// May be used only for booleans.
Expand Down Expand Up @@ -50,12 +51,6 @@ enum LiteralValue {
UserDefined,
}

impl Default for LiteralValue {
fn default() -> Self {
LiteralValue::Null
}
}

/// A complete literal, including type information.
#[derive(Clone, Debug, Default, PartialEq)]
pub struct Literal {
Expand Down
9 changes: 2 additions & 7 deletions rs/src/parse/expressions/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ pub mod mask;
pub mod scalar;

/// Description of the root of a reference.
#[derive(Clone, Debug, PartialEq)]
#[derive(Clone, Debug, PartialEq, Default)]
enum Root {
#[default]
Unresolved,
Expression(expressions::Expression),
Schema(usize),
Expand All @@ -29,12 +30,6 @@ impl From<expressions::Expression> for Root {
}
}

impl Default for Root {
fn default() -> Self {
Root::Unresolved
}
}

/// Description of a reference path.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ReferencePath {
Expand Down
2 changes: 1 addition & 1 deletion rs/src/parse/relations/cross.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn parse_cross_rel(
if let (Some(mut fields), Some(additional_fields)) =
(left.unwrap_struct(), right.unwrap_struct())
{
fields.extend(additional_fields.into_iter());
fields.extend(additional_fields);
let schema = data::new_struct(fields, false);
y.set_schema(schema);
} else {
Expand Down
6 changes: 3 additions & 3 deletions rs/src/parse/relations/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn parse_join_rel(x: &substrait::JoinRel, y: &mut context::Context) -> diagn
if let (Some(mut fields), Some(additional_fields)) =
(left.unwrap_struct(), right.unwrap_struct())
{
fields.extend(additional_fields.into_iter());
fields.extend(additional_fields);
let schema = data::new_struct(fields, false);
y.set_schema(schema);
} else {
Expand Down Expand Up @@ -66,13 +66,13 @@ pub fn parse_join_rel(x: &substrait::JoinRel, y: &mut context::Context) -> diagn
if left_nullable {
fields.extend(left_fields.into_iter().map(|x| x.make_nullable()))
} else {
fields.extend(left_fields.into_iter())
fields.extend(left_fields)
}
if let Some(right_nullable) = right_nullable {
if right_nullable {
fields.extend(right_fields.into_iter().map(|x| x.make_nullable()))
} else {
fields.extend(right_fields.into_iter())
fields.extend(right_fields)
}
}
let schema = data::new_struct(fields, false);
Expand Down
1 change: 0 additions & 1 deletion rs/src/parse/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,6 @@ where
if let serde_json::Value::Array(input) = input {
let size = std::cmp::max(min_size, input.len());
Ok((0..size)
.into_iter()
.map(|index| {
push_yaml_required_element(input, context, index, unknown_subtree, &mut parser)
})
Expand Down
6 changes: 3 additions & 3 deletions rs/src/parse/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ fn describe_type(y: &mut context::Context, data_type: &data::Type) {
data::Class::Compound(data::class::Compound::FixedChar) => {
let length = data_type
.parameters()
.get(0)
.first()
.map(|x| x.to_string())
.unwrap_or_else(|| String::from("?"));
summary!(
Expand All @@ -780,7 +780,7 @@ fn describe_type(y: &mut context::Context, data_type: &data::Type) {
data::Class::Compound(data::class::Compound::VarChar) => {
let length = data_type
.parameters()
.get(0)
.first()
.map(|x| x.to_string())
.unwrap_or_else(|| String::from("?"));
summary!(
Expand All @@ -793,7 +793,7 @@ fn describe_type(y: &mut context::Context, data_type: &data::Type) {
data::Class::Compound(data::class::Compound::FixedBinary) => {
let length = data_type
.parameters()
.get(0)
.first()
.map(|x| x.to_string())
.unwrap_or_else(|| String::from("?"));
summary!(
Expand Down