Skip to content

Commit 107419f

Browse files
authored
Merge branch 'main' into zdenko/syn-3293-lineage-in-redshift-doesnt-support-distribution-styles
2 parents 0429ff2 + ecaed29 commit 107419f

13 files changed

+436
-58
lines changed

src/ast/ddl.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ pub struct ColumnDef {
568568
pub codec: Option<Vec<Expr>>,
569569
pub options: Vec<ColumnOptionDef>,
570570
pub column_options: Vec<SqlOption>,
571+
pub mask: Option<ObjectName>,
571572
}
572573

573574
impl fmt::Display for ColumnDef {
@@ -589,6 +590,9 @@ impl fmt::Display for ColumnDef {
589590
display_comma_separated(&self.column_options)
590591
)?;
591592
}
593+
if let Some(mask) = &self.mask {
594+
write!(f, " MASK {mask}")?;
595+
}
592596
Ok(())
593597
}
594598
}

src/ast/mod.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,20 @@ pub struct StructField {
372372
pub field_name: Option<WithSpan<Ident>>,
373373
pub field_type: DataType,
374374
pub options: Vec<SqlOption>,
375+
pub colon: bool,
375376
}
376377

377378
impl fmt::Display for StructField {
378379
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
379380
if let Some(name) = &self.field_name {
380-
write!(f, "{name} {}", self.field_type)?;
381-
} else {
382-
write!(f, "{}", self.field_type)?;
383-
};
381+
if self.colon {
382+
write!(f, "{name}: ")?;
383+
} else {
384+
write!(f, "{name} ")?;
385+
}
386+
}
387+
write!(f, "{}", self.field_type)?;
388+
384389
if !self.options.is_empty() {
385390
write!(f, " OPTIONS({})", display_comma_separated(&self.options))?;
386391
}
@@ -2040,6 +2045,7 @@ pub enum Statement {
20402045
name: ObjectName,
20412046
args: Option<Vec<OperateFunctionArg>>,
20422047
return_type: Option<DataType>,
2048+
comment: Option<String>,
20432049
/// Optional parameters.
20442050
params: CreateFunctionBody,
20452051
},
@@ -2590,6 +2596,7 @@ impl fmt::Display for Statement {
25902596
name,
25912597
args,
25922598
return_type,
2599+
comment,
25932600
params,
25942601
} => {
25952602
write!(
@@ -2604,6 +2611,9 @@ impl fmt::Display for Statement {
26042611
if let Some(return_type) = return_type {
26052612
write!(f, " RETURNS {return_type}")?;
26062613
}
2614+
if let Some(comment) = comment {
2615+
write!(f, " COMMENT '{comment}'")?;
2616+
}
26072617
write!(f, "{params}")?;
26082618
Ok(())
26092619
}
@@ -5027,6 +5037,8 @@ pub struct CreateFunctionBody {
50275037
pub as_: Option<FunctionDefinition>,
50285038
/// RETURN expression
50295039
pub return_: Option<Expr>,
5040+
/// RETURN SELECT
5041+
pub return_select_: Option<Query>,
50305042
/// USING ... (Hive only)
50315043
pub using: Option<CreateFunctionUsing>,
50325044
}
@@ -5045,6 +5057,9 @@ impl fmt::Display for CreateFunctionBody {
50455057
if let Some(expr) = &self.return_ {
50465058
write!(f, " RETURN {expr}")?;
50475059
}
5060+
if let Some(expr) = &self.return_select_ {
5061+
write!(f, " RETURN {expr}")?;
5062+
}
50485063
if let Some(using) = &self.using {
50495064
write!(f, " {using}")?;
50505065
}

src/ast/query.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ impl fmt::Display for Join {
11501150
self.relation,
11511151
suffix(constraint)
11521152
),
1153-
JoinOperator::CrossJoin => write!(f, " CROSS JOIN {}", self.relation),
1153+
JoinOperator::CrossJoin(constraint) => {
1154+
write!(f, " CROSS JOIN {}{}", self.relation, suffix(constraint))
1155+
}
11541156
JoinOperator::LeftSemi(constraint) => write!(
11551157
f,
11561158
" {}LEFT SEMI JOIN {}{}",
@@ -1194,7 +1196,7 @@ pub enum JoinOperator {
11941196
LeftOuter(JoinConstraint),
11951197
RightOuter(JoinConstraint),
11961198
FullOuter(JoinConstraint),
1197-
CrossJoin,
1199+
CrossJoin(JoinConstraint),
11981200
/// LEFT SEMI (non-standard)
11991201
LeftSemi(JoinConstraint),
12001202
/// RIGHT SEMI (non-standard)

src/dialect/redshift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ impl Dialect for RedshiftSqlDialect {
3535

3636
fn is_identifier_part(&self, ch: char) -> bool {
3737
// Extends Postgres dialect with sharp
38-
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#'
38+
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#' || ch == '€'
3939
}
4040
}

src/keywords.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ define_keywords!(
385385
MACRO,
386386
MANAGEDLOCATION,
387387
MAP,
388+
MASK,
388389
MATCH,
389390
MATCHED,
390391
MATERIALIZED,
@@ -608,6 +609,7 @@ define_keywords!(
608609
STRING,
609610
STRUCT,
610611
SUBMULTISET,
612+
SUBSTR,
611613
SUBSTRING,
612614
SUBSTRING_REGEX,
613615
SUCCEEDS,

0 commit comments

Comments
 (0)