Skip to content

Commit af55e9c

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

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![],
@@ -393,7 +390,6 @@ fn parse_delete_statement() {
393390
name: ObjectName(vec![Ident::with_quote('"', "table")]),
394391
alias: None,
395392
args: None,
396-
columns_definition: None,
397393
with_hints: vec![],
398394
},
399395
table_name
@@ -420,7 +416,6 @@ fn parse_where_delete_statement() {
420416
name: ObjectName(vec![Ident::new("foo")]),
421417
alias: None,
422418
args: None,
423-
columns_definition: None,
424419
with_hints: vec![],
425420
},
426421
table_name,
@@ -461,7 +456,6 @@ fn parse_where_delete_with_alias_statement() {
461456
columns: vec![],
462457
}),
463458
args: None,
464-
columns_definition: None,
465459
with_hints: vec![],
466460
},
467461
table_name,
@@ -475,7 +469,6 @@ fn parse_where_delete_with_alias_statement() {
475469
columns: vec![],
476470
}),
477471
args: None,
478-
columns_definition: None,
479472
with_hints: vec![],
480473
}),
481474
using
@@ -3502,7 +3495,6 @@ fn parse_interval_and_or_xor() {
35023495
}]),
35033496
alias: None,
35043497
args: None,
3505-
columns_definition: None,
35063498
with_hints: vec![],
35073499
},
35083500
joins: vec![],
@@ -4018,7 +4010,6 @@ fn parse_implicit_join() {
40184010
name: ObjectName(vec!["t1".into()]),
40194011
alias: None,
40204012
args: None,
4021-
columns_definition: None,
40224013
with_hints: vec![],
40234014
},
40244015
joins: vec![],
@@ -4028,7 +4019,6 @@ fn parse_implicit_join() {
40284019
name: ObjectName(vec!["t2".into()]),
40294020
alias: None,
40304021
args: None,
4031-
columns_definition: None,
40324022
with_hints: vec![],
40334023
},
40344024
joins: vec![],
@@ -4046,15 +4036,13 @@ fn parse_implicit_join() {
40464036
name: ObjectName(vec!["t1a".into()]),
40474037
alias: None,
40484038
args: None,
4049-
columns_definition: None,
40504039
with_hints: vec![],
40514040
},
40524041
joins: vec![Join {
40534042
relation: TableFactor::Table {
40544043
name: ObjectName(vec!["t1b".into()]),
40554044
alias: None,
40564045
args: None,
4057-
columns_definition: None,
40584046
with_hints: vec![],
40594047
},
40604048
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -4065,15 +4053,13 @@ fn parse_implicit_join() {
40654053
name: ObjectName(vec!["t2a".into()]),
40664054
alias: None,
40674055
args: None,
4068-
columns_definition: None,
40694056
with_hints: vec![],
40704057
},
40714058
joins: vec![Join {
40724059
relation: TableFactor::Table {
40734060
name: ObjectName(vec!["t2b".into()]),
40744061
alias: None,
40754062
args: None,
4076-
columns_definition: None,
40774063
with_hints: vec![],
40784064
},
40794065
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -4094,7 +4080,6 @@ fn parse_cross_join() {
40944080
name: ObjectName(vec![Ident::new("t2")]),
40954081
alias: None,
40964082
args: None,
4097-
columns_definition: None,
40984083
with_hints: vec![],
40994084
},
41004085
join_operator: JoinOperator::CrossJoin,
@@ -4115,7 +4100,6 @@ fn parse_joins_on() {
41154100
name: ObjectName(vec![Ident::new(relation.into())]),
41164101
alias,
41174102
args: None,
4118-
columns_definition: None,
41194103
with_hints: vec![],
41204104
},
41214105
join_operator: f(JoinConstraint::On(Expr::BinaryOp {
@@ -4185,7 +4169,6 @@ fn parse_joins_using() {
41854169
name: ObjectName(vec![Ident::new(relation.into())]),
41864170
alias,
41874171
args: None,
4188-
columns_definition: None,
41894172
with_hints: vec![],
41904173
},
41914174
join_operator: f(JoinConstraint::Using(vec!["c1".into()])),
@@ -4247,7 +4230,6 @@ fn parse_natural_join() {
42474230
name: ObjectName(vec![Ident::new("t2")]),
42484231
alias,
42494232
args: None,
4250-
columns_definition: None,
42514233
with_hints: vec![],
42524234
},
42534235
join_operator: f(JoinConstraint::Natural),
@@ -4512,7 +4494,6 @@ fn parse_derived_tables() {
45124494
name: ObjectName(vec!["t2".into()]),
45134495
alias: None,
45144496
args: None,
4515-
columns_definition: None,
45164497
with_hints: vec![],
45174498
},
45184499
join_operator: JoinOperator::Inner(JoinConstraint::Natural),
@@ -5804,7 +5785,6 @@ fn parse_merge() {
58045785
columns: vec![],
58055786
}),
58065787
args: None,
5807-
columns_definition: None,
58085788
with_hints: vec![],
58095789
}
58105790
);
@@ -5828,7 +5808,6 @@ fn parse_merge() {
58285808
name: ObjectName(vec![Ident::new("s"), Ident::new("foo")]),
58295809
alias: None,
58305810
args: None,
5831-
columns_definition: None,
58325811
with_hints: vec![],
58335812
},
58345813
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)