Skip to main content

sqlparser/ast/helpers/
stmt_data_loading.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! AST types specific to loading and unloading syntax, like one available in Snowflake which
19//! contains: STAGE ddl operations, PUT upload or COPY INTO
20//! See [this page](https://docs.snowflake.com/en/sql-reference/commands-data-loading) for more details.
21
22#[cfg(not(feature = "std"))]
23use alloc::string::String;
24use core::fmt;
25
26#[cfg(feature = "serde")]
27use serde::{Deserialize, Serialize};
28
29use crate::ast::helpers::key_value_options::KeyValueOptions;
30use crate::ast::{Ident, ObjectName, SelectItem};
31#[cfg(feature = "visitor")]
32use sqlparser_derive::{Visit, VisitMut};
33
34#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StageParamsObject {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f,
            "StageParamsObject", "url", &self.url, "encryption",
            &self.encryption, "endpoint", &self.endpoint,
            "storage_integration", &self.storage_integration, "credentials",
            &&self.credentials)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for StageParamsObject {
    #[inline]
    fn clone(&self) -> StageParamsObject {
        StageParamsObject {
            url: ::core::clone::Clone::clone(&self.url),
            encryption: ::core::clone::Clone::clone(&self.encryption),
            endpoint: ::core::clone::Clone::clone(&self.endpoint),
            storage_integration: ::core::clone::Clone::clone(&self.storage_integration),
            credentials: ::core::clone::Clone::clone(&self.credentials),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for StageParamsObject {
    #[inline]
    fn eq(&self, other: &StageParamsObject) -> bool {
        self.url == other.url && self.encryption == other.encryption &&
                    self.endpoint == other.endpoint &&
                self.storage_integration == other.storage_integration &&
            self.credentials == other.credentials
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for StageParamsObject {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<String>>;
        let _: ::core::cmp::AssertParamIsEq<KeyValueOptions>;
        let _: ::core::cmp::AssertParamIsEq<Option<String>>;
        let _: ::core::cmp::AssertParamIsEq<Option<String>>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for StageParamsObject {
    #[inline]
    fn partial_cmp(&self, other: &StageParamsObject)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.url, &other.url) {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                match ::core::cmp::PartialOrd::partial_cmp(&self.encryption,
                        &other.encryption) {
                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                        =>
                        match ::core::cmp::PartialOrd::partial_cmp(&self.endpoint,
                                &other.endpoint) {
                            ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                                =>
                                match ::core::cmp::PartialOrd::partial_cmp(&self.storage_integration,
                                        &other.storage_integration) {
                                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                                        =>
                                        ::core::cmp::PartialOrd::partial_cmp(&self.credentials,
                                            &other.credentials),
                                    cmp => cmp,
                                },
                            cmp => cmp,
                        },
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for StageParamsObject {
    #[inline]
    fn cmp(&self, other: &StageParamsObject) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.url, &other.url) {
            ::core::cmp::Ordering::Equal =>
                match ::core::cmp::Ord::cmp(&self.encryption,
                        &other.encryption) {
                    ::core::cmp::Ordering::Equal =>
                        match ::core::cmp::Ord::cmp(&self.endpoint, &other.endpoint)
                            {
                            ::core::cmp::Ordering::Equal =>
                                match ::core::cmp::Ord::cmp(&self.storage_integration,
                                        &other.storage_integration) {
                                    ::core::cmp::Ordering::Equal =>
                                        ::core::cmp::Ord::cmp(&self.credentials,
                                            &other.credentials),
                                    cmp => cmp,
                                },
                            cmp => cmp,
                        },
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for StageParamsObject {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.url, state);
        ::core::hash::Hash::hash(&self.encryption, state);
        ::core::hash::Hash::hash(&self.endpoint, state);
        ::core::hash::Hash::hash(&self.storage_integration, state);
        ::core::hash::Hash::hash(&self.credentials, state)
    }
}Hash)]
35#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
36#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for StageParamsObject {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::Visit::visit(&self.url, visitor)?;
                        sqlparser::ast::Visit::visit(&self.encryption, visitor)?;
                        sqlparser::ast::Visit::visit(&self.endpoint, visitor)?;
                        sqlparser::ast::Visit::visit(&self.storage_integration,
                                visitor)?;
                        sqlparser::ast::Visit::visit(&self.credentials, visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for StageParamsObject {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::VisitMut::visit(&mut self.url, visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.encryption,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.endpoint,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.storage_integration,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.credentials,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
37/// Parameters for a named stage object used in data loading/unloading.
38pub struct StageParamsObject {
39    /// Optional URL for the stage.
40    pub url: Option<String>,
41    /// Encryption-related key/value options.
42    pub encryption: KeyValueOptions,
43    /// Optional endpoint string.
44    pub endpoint: Option<String>,
45    /// Optional storage integration identifier.
46    pub storage_integration: Option<String>,
47    /// Credentials for accessing the stage.
48    pub credentials: KeyValueOptions,
49}
50
51/// This enum enables support for both standard SQL select item expressions
52/// and Snowflake-specific ones for data loading.
53#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StageLoadSelectItemKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            StageLoadSelectItemKind::SelectItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "SelectItem", &__self_0),
            StageLoadSelectItemKind::StageLoadSelectItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "StageLoadSelectItem", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for StageLoadSelectItemKind {
    #[inline]
    fn clone(&self) -> StageLoadSelectItemKind {
        match self {
            StageLoadSelectItemKind::SelectItem(__self_0) =>
                StageLoadSelectItemKind::SelectItem(::core::clone::Clone::clone(__self_0)),
            StageLoadSelectItemKind::StageLoadSelectItem(__self_0) =>
                StageLoadSelectItemKind::StageLoadSelectItem(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for StageLoadSelectItemKind {
    #[inline]
    fn eq(&self, other: &StageLoadSelectItemKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (StageLoadSelectItemKind::SelectItem(__self_0),
                    StageLoadSelectItemKind::SelectItem(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (StageLoadSelectItemKind::StageLoadSelectItem(__self_0),
                    StageLoadSelectItemKind::StageLoadSelectItem(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for StageLoadSelectItemKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<SelectItem>;
        let _: ::core::cmp::AssertParamIsEq<StageLoadSelectItem>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for StageLoadSelectItemKind {
    #[inline]
    fn partial_cmp(&self, other: &StageLoadSelectItemKind)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match (self, other) {
            (StageLoadSelectItemKind::SelectItem(__self_0),
                StageLoadSelectItemKind::SelectItem(__arg1_0)) =>
                ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            (StageLoadSelectItemKind::StageLoadSelectItem(__self_0),
                StageLoadSelectItemKind::StageLoadSelectItem(__arg1_0)) =>
                ::core::cmp::PartialOrd::partial_cmp(__self_0, __arg1_0),
            _ =>
                ::core::cmp::PartialOrd::partial_cmp(&__self_discr,
                    &__arg1_discr),
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for StageLoadSelectItemKind {
    #[inline]
    fn cmp(&self, other: &StageLoadSelectItemKind) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        match ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr) {
            ::core::cmp::Ordering::Equal =>
                match (self, other) {
                    (StageLoadSelectItemKind::SelectItem(__self_0),
                        StageLoadSelectItemKind::SelectItem(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    (StageLoadSelectItemKind::StageLoadSelectItem(__self_0),
                        StageLoadSelectItemKind::StageLoadSelectItem(__arg1_0)) =>
                        ::core::cmp::Ord::cmp(__self_0, __arg1_0),
                    _ => unsafe { ::core::intrinsics::unreachable() }
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for StageLoadSelectItemKind {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            StageLoadSelectItemKind::SelectItem(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            StageLoadSelectItemKind::StageLoadSelectItem(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash)]
54#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
55#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for StageLoadSelectItemKind {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::SelectItem(_0) => {
                                sqlparser::ast::Visit::visit(_0, visitor)?;
                            }
                            Self::StageLoadSelectItem(_0) => {
                                sqlparser::ast::Visit::visit(_0, visitor)?;
                            }
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for StageLoadSelectItemKind {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        match self {
                            Self::SelectItem(_0) => {
                                sqlparser::ast::VisitMut::visit(_0, visitor)?;
                            }
                            Self::StageLoadSelectItem(_0) => {
                                sqlparser::ast::VisitMut::visit(_0, visitor)?;
                            }
                        }
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
56pub enum StageLoadSelectItemKind {
57    /// A standard SQL select item expression.
58    SelectItem(SelectItem),
59    /// A Snowflake-specific select item used for stage loading.
60    StageLoadSelectItem(StageLoadSelectItem),
61}
62
63impl fmt::Display for StageLoadSelectItemKind {
64    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
65        match &self {
66            StageLoadSelectItemKind::SelectItem(item) => f.write_fmt(format_args!("{0}", item))write!(f, "{item}"),
67            StageLoadSelectItemKind::StageLoadSelectItem(item) => f.write_fmt(format_args!("{0}", item))write!(f, "{item}"),
68        }
69    }
70}
71
72#[derive(#[automatically_derived]
impl ::core::fmt::Debug for StageLoadSelectItem {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "StageLoadSelectItem", "alias", &self.alias, "file_col_num",
            &self.file_col_num, "element", &self.element, "item_as",
            &&self.item_as)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for StageLoadSelectItem {
    #[inline]
    fn clone(&self) -> StageLoadSelectItem {
        StageLoadSelectItem {
            alias: ::core::clone::Clone::clone(&self.alias),
            file_col_num: ::core::clone::Clone::clone(&self.file_col_num),
            element: ::core::clone::Clone::clone(&self.element),
            item_as: ::core::clone::Clone::clone(&self.item_as),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for StageLoadSelectItem {
    #[inline]
    fn eq(&self, other: &StageLoadSelectItem) -> bool {
        self.file_col_num == other.file_col_num && self.alias == other.alias
                && self.element == other.element &&
            self.item_as == other.item_as
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for StageLoadSelectItem {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<Ident>>;
        let _: ::core::cmp::AssertParamIsEq<i32>;
        let _: ::core::cmp::AssertParamIsEq<Option<Ident>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Ident>>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for StageLoadSelectItem {
    #[inline]
    fn partial_cmp(&self, other: &StageLoadSelectItem)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.alias, &other.alias)
            {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                match ::core::cmp::PartialOrd::partial_cmp(&self.file_col_num,
                        &other.file_col_num) {
                    ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                        =>
                        match ::core::cmp::PartialOrd::partial_cmp(&self.element,
                                &other.element) {
                            ::core::option::Option::Some(::core::cmp::Ordering::Equal)
                                =>
                                ::core::cmp::PartialOrd::partial_cmp(&self.item_as,
                                    &other.item_as),
                            cmp => cmp,
                        },
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for StageLoadSelectItem {
    #[inline]
    fn cmp(&self, other: &StageLoadSelectItem) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.alias, &other.alias) {
            ::core::cmp::Ordering::Equal =>
                match ::core::cmp::Ord::cmp(&self.file_col_num,
                        &other.file_col_num) {
                    ::core::cmp::Ordering::Equal =>
                        match ::core::cmp::Ord::cmp(&self.element, &other.element) {
                            ::core::cmp::Ordering::Equal =>
                                ::core::cmp::Ord::cmp(&self.item_as, &other.item_as),
                            cmp => cmp,
                        },
                    cmp => cmp,
                },
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for StageLoadSelectItem {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.alias, state);
        ::core::hash::Hash::hash(&self.file_col_num, state);
        ::core::hash::Hash::hash(&self.element, state);
        ::core::hash::Hash::hash(&self.item_as, state)
    }
}Hash)]
73#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
74#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for StageLoadSelectItem {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::Visit::visit(&self.alias, visitor)?;
                        sqlparser::ast::Visit::visit(&self.file_col_num, visitor)?;
                        sqlparser::ast::Visit::visit(&self.element, visitor)?;
                        sqlparser::ast::Visit::visit(&self.item_as, visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for StageLoadSelectItem {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        sqlparser::ast::VisitMut::visit(&mut self.alias, visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.file_col_num,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.element,
                                visitor)?;
                        sqlparser::ast::VisitMut::visit(&mut self.item_as,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
75/// A single item in the `SELECT` list for data loading from staged files.
76pub struct StageLoadSelectItem {
77    /// Optional alias for the input source.
78    pub alias: Option<Ident>,
79    /// Column number within the staged file (1-based).
80    pub file_col_num: i32,
81    /// Optional element identifier following the column reference.
82    pub element: Option<Ident>,
83    /// Optional alias for the item (AS clause).
84    pub item_as: Option<Ident>,
85}
86
87impl fmt::Display for StageParamsObject {
88    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
89        let url = &self.url.as_ref();
90        let storage_integration = &self.storage_integration.as_ref();
91        let endpoint = &self.endpoint.as_ref();
92
93        if url.is_some() {
94            f.write_fmt(format_args!(" URL=\'{0}\'", url.unwrap()))write!(f, " URL='{}'", url.unwrap())?;
95        }
96        if storage_integration.is_some() {
97            f.write_fmt(format_args!(" STORAGE_INTEGRATION={0}",
        storage_integration.unwrap()))write!(f, " STORAGE_INTEGRATION={}", storage_integration.unwrap())?;
98        }
99        if endpoint.is_some() {
100            f.write_fmt(format_args!(" ENDPOINT=\'{0}\'", endpoint.unwrap()))write!(f, " ENDPOINT='{}'", endpoint.unwrap())?;
101        }
102        if !self.credentials.options.is_empty() {
103            f.write_fmt(format_args!(" CREDENTIALS=({0})", self.credentials))write!(f, " CREDENTIALS=({})", self.credentials)?;
104        }
105        if !self.encryption.options.is_empty() {
106            f.write_fmt(format_args!(" ENCRYPTION=({0})", self.encryption))write!(f, " ENCRYPTION=({})", self.encryption)?;
107        }
108
109        Ok(())
110    }
111}
112
113impl fmt::Display for StageLoadSelectItem {
114    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
115        if let Some(alias) = &self.alias {
116            f.write_fmt(format_args!("{0}.", alias))write!(f, "{alias}.")?;
117        }
118        f.write_fmt(format_args!("${0}", self.file_col_num))write!(f, "${}", self.file_col_num)?;
119        if let Some(element) = &self.element {
120            f.write_fmt(format_args!(":{0}", element))write!(f, ":{element}")?;
121        }
122        if let Some(item_as) = &self.item_as {
123            f.write_fmt(format_args!(" AS {0}", item_as))write!(f, " AS {item_as}")?;
124        }
125        Ok(())
126    }
127}
128
129#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FileStagingCommand {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "FileStagingCommand", "stage", &self.stage, "pattern",
            &&self.pattern)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for FileStagingCommand {
    #[inline]
    fn clone(&self) -> FileStagingCommand {
        FileStagingCommand {
            stage: ::core::clone::Clone::clone(&self.stage),
            pattern: ::core::clone::Clone::clone(&self.pattern),
        }
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for FileStagingCommand {
    #[inline]
    fn eq(&self, other: &FileStagingCommand) -> bool {
        self.stage == other.stage && self.pattern == other.pattern
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for FileStagingCommand {
    #[inline]
    fn partial_cmp(&self, other: &FileStagingCommand)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.stage, &other.stage)
            {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                ::core::cmp::PartialOrd::partial_cmp(&self.pattern,
                    &other.pattern),
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for FileStagingCommand {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<ObjectName>;
        let _: ::core::cmp::AssertParamIsEq<Option<String>>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::Ord for FileStagingCommand {
    #[inline]
    fn cmp(&self, other: &FileStagingCommand) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.stage, &other.stage) {
            ::core::cmp::Ordering::Equal =>
                ::core::cmp::Ord::cmp(&self.pattern, &other.pattern),
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]
impl ::core::hash::Hash for FileStagingCommand {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.stage, state);
        ::core::hash::Hash::hash(&self.pattern, state)
    }
}Hash)]
130#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
131#[cfg_attr(feature = "visitor", derive(impl sqlparser::ast::Visit for FileStagingCommand {
    fn visit<V: sqlparser::ast::Visitor>(&self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        visitor.pre_visit_relation(&self.stage)?;
                        sqlparser::ast::Visit::visit(&self.stage, visitor)?;
                        visitor.post_visit_relation(&self.stage)?;
                        sqlparser::ast::Visit::visit(&self.pattern, visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}Visit, impl sqlparser::ast::VisitMut for FileStagingCommand {
    fn visit<V: sqlparser::ast::VisitorMut>(&mut self, visitor: &mut V)
        -> ::std::ops::ControlFlow<V::Break> {
        ::recursive::__impl::stacker::maybe_grow(::recursive::get_minimum_stack_size(),
            ::recursive::get_stack_allocation_size(),
            move || -> ::std::ops::ControlFlow<V::Break>
                {
                    {
                        visitor.pre_visit_relation(&mut self.stage)?;
                        sqlparser::ast::VisitMut::visit(&mut self.stage, visitor)?;
                        visitor.post_visit_relation(&mut self.stage)?;
                        sqlparser::ast::VisitMut::visit(&mut self.pattern,
                                visitor)?;
                        ::std::ops::ControlFlow::Continue(())
                    }
                })
    }
}VisitMut))]
132/// A command to stage files to a named stage.
133pub struct FileStagingCommand {
134    /// The stage to which files are being staged.
135    #[cfg_attr(feature = "visitor", visit(with = "visit_relation"))]
136    pub stage: ObjectName,
137    /// Optional file matching `PATTERN` expression.
138    pub pattern: Option<String>,
139}
140
141impl fmt::Display for FileStagingCommand {
142    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
143        f.write_fmt(format_args!("{0}", self.stage))write!(f, "{}", self.stage)?;
144        if let Some(pattern) = self.pattern.as_ref() {
145            f.write_fmt(format_args!(" PATTERN=\'{0}\'", pattern))write!(f, " PATTERN='{pattern}'")?;
146        }
147        Ok(())
148    }
149}