File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -8888,7 +8888,7 @@ impl<'a> Parser<'a> {
88888888 }
88898889 }
88908890
8891- pub fn parse_table_index_hints(&mut self) -> Result<Vec<TableIndexHints>, ParserError> {
8891+ fn parse_table_index_hints(&mut self) -> Result<Vec<TableIndexHints>, ParserError> {
88928892 let mut hints = vec![];
88938893 while let Some(hint_type) =
88948894 self.parse_one_of_keywords(&[Keyword::USE, Keyword::IGNORE, Keyword::FORCE])
@@ -11283,7 +11283,10 @@ impl<'a> Parser<'a> {
1128311283
1128411284 let alias = self.maybe_parse_table_alias()?;
1128511285
11286- let index_hints = self.parse_table_index_hints()?;
11286+ // maybe parse so we will still support queries like 'SELECT * FROM T USE LIMIT 1' in BigQuery, for example
11287+ let index_hints = self
11288+ .maybe_parse(|p| p.parse_table_index_hints())?
11289+ .unwrap_or(vec![]);
1128711290
1128811291 // MSSQL-specific table hints:
1128911292 let mut with_hints = vec![];
Original file line number Diff line number Diff line change @@ -1602,6 +1602,34 @@ fn parse_join_constraint_unnest_alias() {
16021602 ) ;
16031603}
16041604
1605+ #[ test]
1606+ fn parse_select_with_use ( ) {
1607+ let sql = "SELECT * FROM T USE LIMIT 1" ;
1608+ let select =
1609+ bigquery ( ) . verified_only_select_with_canonical ( sql, "SELECT * FROM T AS USE LIMIT 1" ) ;
1610+ assert_eq ! (
1611+ select. from,
1612+ vec![ TableWithJoins {
1613+ relation: TableFactor :: Table {
1614+ name: ObjectName ( vec![ Ident :: new( "T" ) ] ) ,
1615+ alias: Some ( TableAlias {
1616+ name: Ident :: new( "USE" ) ,
1617+ columns: vec![ ] ,
1618+ } ) ,
1619+ args: None ,
1620+ with_hints: vec![ ] ,
1621+ version: None ,
1622+ partitions: vec![ ] ,
1623+ with_ordinality: false ,
1624+ json_path: None ,
1625+ sample: None ,
1626+ index_hints: vec![ ] ,
1627+ } ,
1628+ joins: vec![ ] ,
1629+ } ]
1630+ ) ;
1631+ }
1632+
16051633#[ test]
16061634fn parse_merge ( ) {
16071635 let sql = concat ! (
You can’t perform that action at this time.
0 commit comments