diff --git a/src/expr/core/src/window_function/call.rs b/src/expr/core/src/window_function/call.rs index 6e89eef135c6c..d76aee81196fb 100644 --- a/src/expr/core/src/window_function/call.rs +++ b/src/expr/core/src/window_function/call.rs @@ -92,9 +92,12 @@ impl Frame { let bounds = match frame.get_type()? { PbType::Unspecified => bail!("unspecified type of `WindowFrame`"), PbType::RowsLegacy => { - let start = FrameBound::::from_protobuf_legacy(frame.get_start()?)?; - let end = FrameBound::::from_protobuf_legacy(frame.get_end()?)?; - FrameBounds::Rows(RowsFrameBounds { start, end }) + #[expect(deprecated)] + { + let start = FrameBound::::from_protobuf_legacy(frame.get_start()?)?; + let end = FrameBound::::from_protobuf_legacy(frame.get_end()?)?; + FrameBounds::Rows(RowsFrameBounds { start, end }) + } } PbType::Rows => { let bounds = must_match!(frame.get_bounds()?, PbBounds::Rows(bounds) => bounds); diff --git a/src/prost/helpers/src/generate.rs b/src/prost/helpers/src/generate.rs index eb7a5589dd1b9..52784f7ec489f 100644 --- a/src/prost/helpers/src/generate.rs +++ b/src/prost/helpers/src/generate.rs @@ -17,8 +17,8 @@ use quote::quote; use syn::ext::IdentExt; use syn::spanned::Spanned; use syn::{ - Error, Expr, ExprLit, Field, GenericArgument, Lit, Meta, PathArguments, PathSegment, Result, - Type, + AttrStyle, Attribute, Error, Expr, ExprLit, Field, GenericArgument, Lit, Meta, Path, + PathArguments, PathSegment, Result, Type, }; fn extract_type_from_option(option_segment: &PathSegment) -> Type { @@ -83,6 +83,13 @@ fn extract_enum_type_from_field(field: &Field) -> Option { Some(syn::parse_str::(&enum_type.value()).unwrap()) } +fn is_deprecated(field: &Field) -> bool { + field.attrs.iter().any(|attr| match &attr.meta { + Meta::Path(path) => path.is_ident("deprecated"), + _ => false, + }) +} + pub fn implement(field: &Field) -> Result { let field_name = field .clone() @@ -90,9 +97,22 @@ pub fn implement(field: &Field) -> Result { .ok_or_else(|| Error::new(field.span(), "Expected the field to have a name"))?; let getter_fn_name = Ident::new(&format!("get_{}", field_name.unraw()), Span::call_site()); + let is_deprecated = is_deprecated(field); + + let attr_list: Vec = if is_deprecated { + vec![Attribute { + pound_token: Default::default(), + style: AttrStyle::Outer, + bracket_token: Default::default(), + meta: Meta::from(Path::from(Ident::new("deprecated", Span::call_site()))), + }] + } else { + vec![] + }; if let Some(enum_type) = extract_enum_type_from_field(field) { return Ok(quote! { + #(#attr_list)* #[inline(always)] pub fn #getter_fn_name(&self) -> std::result::Result<#enum_type, crate::PbFieldNotFound> { if self.#field_name.eq(&0) { @@ -110,6 +130,7 @@ pub fn implement(field: &Field) -> Result { // ::core::option::Option let ty = extract_type_from_option(data_type); return Ok(quote! { + #(#attr_list)* #[inline(always)] pub fn #getter_fn_name(&self) -> std::result::Result<&#ty, crate::PbFieldNotFound> { self.#field_name.as_ref().ok_or_else(|| crate::PbFieldNotFound(stringify!(#field_name))) @@ -120,6 +141,7 @@ pub fn implement(field: &Field) -> Result { { // Primitive types. Return value instead of reference. return Ok(quote! { + #(#attr_list)* #[inline(always)] pub fn #getter_fn_name(&self) -> #ty { self.#field_name @@ -129,6 +151,7 @@ pub fn implement(field: &Field) -> Result { } Ok(quote! { + #(#attr_list)* #[inline(always)] pub fn #getter_fn_name(&self) -> &#ty { &self.#field_name