iffyio commented on code in PR #2480:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2480#discussion_r3966620085


##########
tests/sqlparser_redshift.rs:
##########
@@ -557,3 +557,10 @@ fn parse_unpivot_expression() {
 fn test_interval_as_column_name() {
     redshift().verified_stmt("SELECT * FROM table_name WHERE interval = 78");
 }
+
+#[test]
+fn parse_approximate_percentile_disc() {
+    redshift().verified_stmt(

Review Comment:
   let's use the `all_dialect_where` method. Also  let's add a test case for 
`SELECT APPROXIMATE PERCENTILE_DISC` which should be parsed for all dialects as 
a column alias I imagine?



##########
src/parser/mod.rs:
##########
@@ -1836,6 +1836,20 @@ impl<'a> Parser<'a> {
 
         let dialect = self.dialect;
 
+        if dialect.supports_approximate_percentile_disc()

Review Comment:
   hmm I think a better place to hook into this logic is probably 
[here](https://github.com/BenSatori/datafusion-sqlparser-rs/blob/8c2ef6cd95a1a594f92bf23c5fbdfb8cf2fab25d/src/parser/mod.rs#L1656)?
   
   also maybe the check there can be to `peek (precentile_disc)` given the 
current work is 'approximate' and if so maybe_parse(expr) 



##########
src/parser/mod.rs:
##########
@@ -1836,6 +1836,20 @@ impl<'a> Parser<'a> {
 
         let dialect = self.dialect;
 
+        if dialect.supports_approximate_percentile_disc()
+            && matches!(&self.peek_token_ref().token, Token::Word(word) if 
word.value.eq_ignore_ascii_case("approximate"))
+            && matches!(&self.peek_nth_token_ref(1).token, Token::Word(word) 
if word.value.eq_ignore_ascii_case("percentile_disc"))

Review Comment:
   impl wise these should use keywords.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to