yoavcloud commented on code in PR #1712:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1712#discussion_r1947548884


##########
src/dialect/snowflake.rs:
##########
@@ -960,6 +980,42 @@ fn parse_stage_params(parser: &mut Parser) -> 
Result<StageParamsObject, ParserEr
     })
 }
 
+
+/// Parses options separated by blank spaces, commas, or new lines like:
+/// ABORT_DETACHED_QUERY = { TRUE | FALSE }
+///      [ ACTIVE_PYTHON_PROFILER = { 'LINE' | 'MEMORY' } ]
+///      [ BINARY_INPUT_FORMAT = <string> ]
+fn parse_session_options(parser: &mut Parser, set: bool) -> 
Result<Vec<DataLoadingOption>, ParserError> {
+    let mut options: Vec<DataLoadingOption> = Vec::new();
+    let empty = String::new;
+    loop {
+        match parser.next_token().token {
+            Token::Comma => continue,
+            Token::Word(key) => {
+                if set {
+                    let option = parse_copy_option(parser, key)?;
+                    options.push(option);
+                } else {
+                    options.push(DataLoadingOption {
+                        option_name: key.value,
+                        option_type: DataLoadingOptionType::STRING,
+                        value: empty(),
+                    });
+                }
+
+            },
+            _ => {
+                if parser.peek_token().token == Token::EOF {
+                    break
+                }
+                return parser.expected("another option", parser.peek_token())
+            },
+        }
+    }
+    Ok(options)

Review Comment:
   Perhaps add a check if for empty options and raise error



##########
src/dialect/snowflake.rs:
##########
@@ -960,6 +980,42 @@ fn parse_stage_params(parser: &mut Parser) -> 
Result<StageParamsObject, ParserEr
     })
 }
 
+
+/// Parses options separated by blank spaces, commas, or new lines like:
+/// ABORT_DETACHED_QUERY = { TRUE | FALSE }
+///      [ ACTIVE_PYTHON_PROFILER = { 'LINE' | 'MEMORY' } ]
+///      [ BINARY_INPUT_FORMAT = <string> ]
+fn parse_session_options(parser: &mut Parser, set: bool) -> 
Result<Vec<DataLoadingOption>, ParserError> {
+    let mut options: Vec<DataLoadingOption> = Vec::new();
+    let empty = String::new;
+    loop {
+        match parser.next_token().token {
+            Token::Comma => continue,
+            Token::Word(key) => {
+                if set {
+                    let option = parse_copy_option(parser, key)?;
+                    options.push(option);
+                } else {
+                    options.push(DataLoadingOption {
+                        option_name: key.value,
+                        option_type: DataLoadingOptionType::STRING,
+                        value: empty(),
+                    });
+                }
+
+            },
+            _ => {
+                if parser.peek_token().token == Token::EOF {
+                    break
+                }
+                return parser.expected("another option", parser.peek_token())
+            },
+        }
+    }
+    Ok(options)

Review Comment:
   Perhaps add a check here for empty options and raise error



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to