Skip to content

Commit 1f7ecc9

Browse files
committed
Revert "Support redshift's columns definition list for system information functions (apache#769)"
This reverts commit c35dcc9.
1 parent ef50c46 commit 1f7ecc9

14 files changed

+0
-194
lines changed

src/ast/mod.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4142,35 +4142,6 @@ impl fmt::Display for SearchModifier {
41424142
}
41434143
}
41444144

4145-
/// A result table definition i.e. `cols(view_schema name, view_name name, col_name name, col_type varchar, col_num int)`
4146-
/// used for redshift functions: pg_get_late_binding_view_cols, pg_get_cols, pg_get_grantee_by_iam_role,pg_get_iam_role_by_user
4147-
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
4148-
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4149-
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
4150-
pub struct TableAliasDefinition {
4151-
pub name: Ident,
4152-
pub args: Vec<IdentPair>,
4153-
}
4154-
4155-
impl fmt::Display for TableAliasDefinition {
4156-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4157-
write!(f, "{}({})", self.name, display_comma_separated(&self.args))?;
4158-
Ok(())
4159-
}
4160-
}
4161-
4162-
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
4163-
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
4164-
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
4165-
pub struct IdentPair(pub Ident, pub Ident);
4166-
4167-
impl fmt::Display for IdentPair {
4168-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
4169-
write!(f, "{} {}", self.0, self.1)?;
4170-
Ok(())
4171-
}
4172-
}
4173-
41744145
#[cfg(test)]
41754146
mod tests {
41764147
use super::*;

src/ast/query.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,6 @@ pub enum TableFactor {
631631
/// vector of arguments, in the case of a table-valued function call,
632632
/// whereas it's `None` in the case of a regular table name.
633633
args: Option<Vec<FunctionArg>>,
634-
/// A table alias definition i.e. `cols(view_schema name, view_name name, col_name name, col_type varchar, col_num int)`
635-
/// used for redshift functions: pg_get_late_binding_view_cols, pg_get_cols, pg_get_grantee_by_iam_role,pg_get_iam_role_by_user)
636-
columns_definition: Option<TableAliasDefinition>,
637634
/// MSSQL-specific `WITH (...)` hints such as NOLOCK.
638635
with_hints: Vec<Expr>,
639636
},
@@ -682,7 +679,6 @@ impl fmt::Display for TableFactor {
682679
name,
683680
alias,
684681
args,
685-
columns_definition,
686682
with_hints,
687683
} => {
688684
write!(f, "{name}")?;
@@ -692,9 +688,6 @@ impl fmt::Display for TableFactor {
692688
if let Some(alias) = alias {
693689
write!(f, " AS {alias}")?;
694690
}
695-
if let Some(columns_definition) = columns_definition {
696-
write!(f, " {columns_definition}")?;
697-
}
698691
if !with_hints.is_empty() {
699692
write!(f, " WITH ({})", display_comma_separated(with_hints))?;
700693
}

src/keywords.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ pub const RESERVED_FOR_TABLE_ALIAS: &[Keyword] = &[
671671
Keyword::OUTER,
672672
Keyword::SET,
673673
Keyword::QUALIFY,
674-
Keyword::AS,
675674
];
676675

677676
/// Can't be used as a column alias, so that `SELECT <expr> alias`
@@ -701,5 +700,4 @@ pub const RESERVED_FOR_COLUMN_ALIAS: &[Keyword] = &[
701700
// Reserved only as a column alias in the `SELECT` clause
702701
Keyword::FROM,
703702
Keyword::INTO,
704-
Keyword::AS,
705703
];

src/parser.rs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5713,7 +5713,6 @@ impl<'a> Parser<'a> {
57135713
} else {
57145714
None
57155715
};
5716-
let columns_definition = self.parse_redshift_columns_definition_list()?;
57175716
let alias = self.parse_optional_table_alias(keywords::RESERVED_FOR_TABLE_ALIAS)?;
57185717
// MSSQL-specific table hints:
57195718
let mut with_hints = vec![];
@@ -5730,56 +5729,11 @@ impl<'a> Parser<'a> {
57305729
name,
57315730
alias,
57325731
args,
5733-
columns_definition,
57345732
with_hints,
57355733
})
57365734
}
57375735
}
57385736

5739-
fn parse_redshift_columns_definition_list(
5740-
&mut self,
5741-
) -> Result<Option<TableAliasDefinition>, ParserError> {
5742-
if !dialect_of!(self is RedshiftSqlDialect | GenericDialect) {
5743-
return Ok(None);
5744-
}
5745-
5746-
if let Some(col_definition_list_name) = self.parse_optional_columns_definition_list_alias()
5747-
{
5748-
if self.consume_token(&Token::LParen) {
5749-
let names = self.parse_comma_separated(Parser::parse_ident_pair)?;
5750-
self.expect_token(&Token::RParen)?;
5751-
Ok(Some(TableAliasDefinition {
5752-
name: col_definition_list_name,
5753-
args: names,
5754-
}))
5755-
} else {
5756-
self.prev_token();
5757-
Ok(None)
5758-
}
5759-
} else {
5760-
Ok(None)
5761-
}
5762-
}
5763-
5764-
fn parse_optional_columns_definition_list_alias(&mut self) -> Option<Ident> {
5765-
match self.next_token().token {
5766-
Token::Word(w) if !keywords::RESERVED_FOR_TABLE_ALIAS.contains(&w.keyword) => {
5767-
Some(w.to_ident())
5768-
}
5769-
_ => {
5770-
self.prev_token();
5771-
None
5772-
}
5773-
}
5774-
}
5775-
5776-
fn parse_ident_pair(&mut self) -> Result<IdentPair, ParserError> {
5777-
Ok(IdentPair(
5778-
self.parse_identifier()?,
5779-
self.parse_identifier()?,
5780-
))
5781-
}
5782-
57835737
pub fn parse_derived_table_factor(
57845738
&mut self,
57855739
lateral: IsLateral,

src/test_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ pub fn table(name: impl Into<String>) -> TableFactor {
185185
name: ObjectName(vec![Ident::new(name.into())]),
186186
alias: None,
187187
args: None,
188-
columns_definition: None,
189188
with_hints: vec![],
190189
}
191190
}

tests/sqlparser_bigquery.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ fn parse_table_identifiers() {
9999
name: ObjectName(expected),
100100
alias: None,
101101
args: None,
102-
columns_definition: None,
103102
with_hints: vec![],
104103
},
105104
joins: vec![]

tests/sqlparser_clickhouse.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ fn parse_map_access_expr() {
6060
name: ObjectName(vec![Ident::new("foos")]),
6161
alias: None,
6262
args: None,
63-
columns_definition: None,
6463
with_hints: vec![],
6564
},
6665
joins: vec![]
@@ -165,13 +164,11 @@ fn parse_delimited_identifiers() {
165164
name,
166165
alias,
167166
args,
168-
columns_definition,
169167
with_hints,
170168
} => {
171169
assert_eq!(vec![Ident::with_quote('"', "a table")], name.0);
172170
assert_eq!(Ident::with_quote('"', "alias"), alias.unwrap().name);
173171
assert!(args.is_none());
174-
assert!(columns_definition.is_none());
175172
assert!(with_hints.is_empty());
176173
}
177174
_ => panic!("Expecting TableFactor::Table"),

tests/sqlparser_common.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ fn parse_update_set_from() {
210210
name: ObjectName(vec![Ident::new("t1")]),
211211
alias: None,
212212
args: None,
213-
columns_definition: None,
214213
with_hints: vec![],
215214
},
216215
joins: vec![],
@@ -237,7 +236,6 @@ fn parse_update_set_from() {
237236
name: ObjectName(vec![Ident::new("t1")]),
238237
alias: None,
239238
args: None,
240-
columns_definition: None,
241239
with_hints: vec![],
242240
},
243241
joins: vec![],
@@ -300,7 +298,6 @@ fn parse_update_with_table_alias() {
300298
columns: vec![],
301299
}),
302300
args: None,
303-
columns_definition: None,
304301
with_hints: vec![],
305302
},
306303
joins: vec![],
@@ -394,7 +391,6 @@ fn parse_delete_statement() {
394391
name: ObjectName(vec![Ident::with_quote('"', "table")]),
395392
alias: None,
396393
args: None,
397-
columns_definition: None,
398394
with_hints: vec![],
399395
},
400396
table_name
@@ -421,7 +417,6 @@ fn parse_where_delete_statement() {
421417
name: ObjectName(vec![Ident::new("foo")]),
422418
alias: None,
423419
args: None,
424-
columns_definition: None,
425420
with_hints: vec![],
426421
},
427422
table_name,
@@ -462,7 +457,6 @@ fn parse_where_delete_with_alias_statement() {
462457
columns: vec![],
463458
}),
464459
args: None,
465-
columns_definition: None,
466460
with_hints: vec![],
467461
},
468462
table_name,
@@ -476,7 +470,6 @@ fn parse_where_delete_with_alias_statement() {
476470
columns: vec![],
477471
}),
478472
args: None,
479-
columns_definition: None,
480473
with_hints: vec![],
481474
}),
482475
using
@@ -3503,7 +3496,6 @@ fn parse_interval_and_or_xor() {
35033496
}]),
35043497
alias: None,
35053498
args: None,
3506-
columns_definition: None,
35073499
with_hints: vec![],
35083500
},
35093501
joins: vec![],
@@ -4019,7 +4011,6 @@ fn parse_implicit_join() {
40194011
name: ObjectName(vec!["t1".into()]),
40204012
alias: None,
40214013
args: None,
4022-
columns_definition: None,
40234014
with_hints: vec![],
40244015
},
40254016
joins: vec![],
@@ -4029,7 +4020,6 @@ fn parse_implicit_join() {
40294020
name: ObjectName(vec!["t2".into()]),
40304021
alias: None,
40314022
args: None,
4032-
columns_definition: None,
40334023
with_hints: vec![],
40344024
},
40354025
joins: vec![],
@@ -4047,15 +4037,13 @@ fn parse_implicit_join() {
40474037
name: ObjectName(vec!["t1a".into()]),
40484038
alias: None,
40494039
args: None,
4050-
columns_definition: None,
40514040
with_hints: vec![],
40524041
},
40534042
joins: vec![Join {
40544043
relation: TableFactor::Table {
40554044
name: ObjectName(vec!["t1b".into()]),
40564045
alias: None,
40574046
args: None,
4058-
columns_definition: None,
40594047
with_hints: vec![],
40604048
},
40614049
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -4066,15 +4054,13 @@ fn parse_implicit_join() {
40664054
name: ObjectName(vec!["t2a".into()]),
40674055
alias: None,
40684056
args: None,
4069-
columns_definition: None,
40704057
with_hints: vec![],
40714058
},
40724059
joins: vec![Join {
40734060
relation: TableFactor::Table {
40744061
name: ObjectName(vec!["t2b".into()]),
40754062
alias: None,
40764063
args: None,
4077-
columns_definition: None,
40784064
with_hints: vec![],
40794065
},
40804066
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -4095,7 +4081,6 @@ fn parse_cross_join() {
40954081
name: ObjectName(vec![Ident::new("t2")]),
40964082
alias: None,
40974083
args: None,
4098-
columns_definition: None,
40994084
with_hints: vec![],
41004085
},
41014086
join_operator: JoinOperator::CrossJoin,
@@ -4116,7 +4101,6 @@ fn parse_joins_on() {
41164101
name: ObjectName(vec![Ident::new(relation.into())]),
41174102
alias,
41184103
args: None,
4119-
columns_definition: None,
41204104
with_hints: vec![],
41214105
},
41224106
join_operator: f(JoinConstraint::On(Expr::BinaryOp {
@@ -4186,7 +4170,6 @@ fn parse_joins_using() {
41864170
name: ObjectName(vec![Ident::new(relation.into())]),
41874171
alias,
41884172
args: None,
4189-
columns_definition: None,
41904173
with_hints: vec![],
41914174
},
41924175
join_operator: f(JoinConstraint::Using(vec!["c1".into()])),
@@ -4248,7 +4231,6 @@ fn parse_natural_join() {
42484231
name: ObjectName(vec![Ident::new("t2")]),
42494232
alias,
42504233
args: None,
4251-
columns_definition: None,
42524234
with_hints: vec![],
42534235
},
42544236
join_operator: f(JoinConstraint::Natural),
@@ -4513,7 +4495,6 @@ fn parse_derived_tables() {
45134495
name: ObjectName(vec!["t2".into()]),
45144496
alias: None,
45154497
args: None,
4516-
columns_definition: None,
45174498
with_hints: vec![],
45184499
},
45194500
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -5805,7 +5786,6 @@ fn parse_merge() {
58055786
columns: vec![],
58065787
}),
58075788
args: None,
5808-
columns_definition: None,
58095789
with_hints: vec![],
58105790
}
58115791
);
@@ -5829,7 +5809,6 @@ fn parse_merge() {
58295809
name: ObjectName(vec![Ident::new("s"), Ident::new("foo")]),
58305810
alias: None,
58315811
args: None,
5832-
columns_definition: None,
58335812
with_hints: vec![],
58345813
},
58355814
joins: vec![],

tests/sqlparser_hive.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,11 @@ fn parse_delimited_identifiers() {
320320
name,
321321
alias,
322322
args,
323-
columns_definition,
324323
with_hints,
325324
} => {
326325
assert_eq!(vec![Ident::with_quote('"', "a table")], name.0);
327326
assert_eq!(Ident::with_quote('"', "alias"), alias.unwrap().name);
328327
assert!(args.is_none());
329-
assert!(columns_definition.is_none());
330328
assert!(with_hints.is_empty());
331329
}
332330
_ => panic!("Expecting TableFactor::Table"),

tests/sqlparser_mssql.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,11 @@ fn parse_delimited_identifiers() {
152152
name,
153153
alias,
154154
args,
155-
columns_definition,
156155
with_hints,
157156
} => {
158157
assert_eq!(vec![Ident::with_quote('"', "a table")], name.0);
159158
assert_eq!(Ident::with_quote('"', "alias"), alias.unwrap().name);
160159
assert!(args.is_none());
161-
assert!(columns_definition.is_none());
162160
assert!(with_hints.is_empty());
163161
}
164162
_ => panic!("Expecting TableFactor::Table"),

0 commit comments

Comments
 (0)