Skip to content

Commit dcecedf

Browse files
committed
Code review fixes
1 parent 10e8499 commit dcecedf

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/ast/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8868,12 +8868,12 @@ pub enum CopyLegacyOption {
88688868
MaxFileSize(FileSize),
88698869
/// NULL \[ AS \] 'null_string'
88708870
Null(String),
8871-
/// PARALLEL
8871+
/// PARALLEL [ { ON | TRUE } | { OFF | FALSE } ]
88728872
Parallel(Option<bool>),
88738873
/// PARQUET
88748874
Parquet,
88758875
/// PARTITION BY ( column_name [, ... ] ) \[ INCLUDE \]
8876-
PartitionBy(PartitionBy),
8876+
PartitionBy(UnloadPartitionBy),
88778877
/// REGION \[ AS \] 'aws-region' }
88788878
Region(String),
88798879
/// ROWGROUPSIZE \[ AS \] size \[ MB | GB \]
@@ -9010,12 +9010,12 @@ impl fmt::Display for FileSizeUnit {
90109010
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
90119011
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
90129012
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
9013-
pub struct PartitionBy {
9013+
pub struct UnloadPartitionBy {
90149014
pub columns: Vec<Ident>,
90159015
pub include: bool,
90169016
}
90179017

9018-
impl fmt::Display for PartitionBy {
9018+
impl fmt::Display for UnloadPartitionBy {
90199019
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
90209020
write!(
90219021
f,

src/parser/mod.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9746,7 +9746,7 @@ impl<'a> Parser<'a> {
97469746
self.expect_keyword(Keyword::BY)?;
97479747
let columns = self.parse_parenthesized_column_list(IsOptional::Mandatory, false)?;
97489748
let include = self.parse_keyword(Keyword::INCLUDE);
9749-
CopyLegacyOption::PartitionBy(PartitionBy { columns, include })
9749+
CopyLegacyOption::PartitionBy(UnloadPartitionBy { columns, include })
97509750
}
97519751
Some(Keyword::REGION) => {
97529752
let _ = self.parse_keyword(Keyword::AS);
@@ -9755,13 +9755,8 @@ impl<'a> Parser<'a> {
97559755
}
97569756
Some(Keyword::ROWGROUPSIZE) => {
97579757
let _ = self.parse_keyword(Keyword::AS);
9758-
let size = self.parse_number_value()?.value;
9759-
let unit = match self.parse_one_of_keywords(&[Keyword::MB, Keyword::GB]) {
9760-
Some(Keyword::MB) => Some(FileSizeUnit::MB),
9761-
Some(Keyword::GB) => Some(FileSizeUnit::GB),
9762-
_ => None,
9763-
};
9764-
CopyLegacyOption::RowGroupSize(FileSize { size, unit })
9758+
let file_size = self.parse_file_size()?;
9759+
CopyLegacyOption::RowGroupSize(file_size)
97659760
}
97669761
Some(Keyword::TIMEFORMAT) => {
97679762
let _ = self.parse_keyword(Keyword::AS);
@@ -9779,6 +9774,20 @@ impl<'a> Parser<'a> {
97799774
Ok(ret)
97809775
}
97819776

9777+
fn parse_file_size(&mut self) -> Result<FileSize, ParserError> {
9778+
let size = self.parse_number_value()?.value;
9779+
let unit = self.maybe_parse_file_size_unit();
9780+
Ok(FileSize { size, unit })
9781+
}
9782+
9783+
fn maybe_parse_file_size_unit(&mut self) -> Option<FileSizeUnit> {
9784+
match self.parse_one_of_keywords(&[Keyword::MB, Keyword::GB]) {
9785+
Some(Keyword::MB) => Some(FileSizeUnit::MB),
9786+
Some(Keyword::GB) => Some(FileSizeUnit::GB),
9787+
_ => None,
9788+
}
9789+
}
9790+
97829791
fn parse_iam_role_kind(&mut self) -> Result<IamRoleKind, ParserError> {
97839792
if self.parse_keyword(Keyword::DEFAULT) {
97849793
Ok(IamRoleKind::Default)

0 commit comments

Comments
 (0)