mirror of
				https://github.com/apache/datafusion-sqlparser-rs.git
				synced 2025-11-04 08:48:23 +00:00 
			
		
		
		
	feat: support tailing commas on snowflake dialect. (#1205)
This commit is contained in:
		
							parent
							
								
									17ef71e42b
								
							
						
					
					
						commit
						6da8828c1b
					
				
					 2 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -2946,14 +2946,15 @@ impl<'a> Parser<'a> {
 | 
			
		|||
 | 
			
		||||
    /// Parse a comma-separated list of 1+ SelectItem
 | 
			
		||||
    pub fn parse_projection(&mut self) -> Result<Vec<SelectItem>, ParserError> {
 | 
			
		||||
        // BigQuery allows trailing commas, but only in project lists
 | 
			
		||||
        // BigQuery and Snowflake allow trailing commas, but only in project lists
 | 
			
		||||
        // e.g. `SELECT 1, 2, FROM t`
 | 
			
		||||
        // https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#trailing_commas
 | 
			
		||||
        // https://docs.snowflake.com/en/release-notes/2024/8_11#select-supports-trailing-commas
 | 
			
		||||
        //
 | 
			
		||||
        // This pattern could be captured better with RAII type semantics, but it's quite a bit of
 | 
			
		||||
        // code to add for just one case, so we'll just do it manually here.
 | 
			
		||||
        let old_value = self.options.trailing_commas;
 | 
			
		||||
        self.options.trailing_commas |= dialect_of!(self is BigQueryDialect);
 | 
			
		||||
        self.options.trailing_commas |= dialect_of!(self is BigQueryDialect | SnowflakeDialect);
 | 
			
		||||
 | 
			
		||||
        let ret = self.parse_comma_separated(|p| p.parse_select_item());
 | 
			
		||||
        self.options.trailing_commas = old_value;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue