LucaCappelletti94 commented on code in PR #2077:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2077#discussion_r2527740925


##########
src/parser/mod.rs:
##########
@@ -9597,6 +9533,178 @@ impl<'a> Parser<'a> {
         }
     }
 
+    pub fn parse_csv_body(
+        &mut self,
+        options: &[CopyOption],
+        legacy_options: &[CopyLegacyOption],
+    ) -> Result<Vec<Vec<Option<String>>>, ParserError> {
+        let Token::CopyFromStdin(body) = self.next_token().token else {
+            return self.expected("COPY ... FROM STDIN with CSV body", 
self.peek_token());
+        };
+
+        let mut delimiter = '\t';
+        let mut quote = '"';
+        let mut escape = '\\';
+        let mut null_symbol = "\\N";
+
+        // Apply options
+        for option in options {
+            match option {
+                CopyOption::Delimiter(c) => {
+                    delimiter = *c;
+                }
+                CopyOption::Quote(c) => {
+                    quote = *c;
+                }
+                CopyOption::Escape(c) => {
+                    escape = *c;
+                }
+                CopyOption::Null(null) => {
+                    null_symbol = null;
+                }
+                _ => {}
+            }
+        }
+
+        // Apply legacy options
+        for option in legacy_options {
+            match option {
+                CopyLegacyOption::Delimiter(c) => {
+                    delimiter = *c;
+                }
+                CopyLegacyOption::Null(null) => {
+                    null_symbol = null;
+                }
+                CopyLegacyOption::Csv(csv_options) => {
+                    for csv_option in csv_options {
+                        match csv_option {
+                            CopyLegacyCsvOption::Quote(c) => {
+                                quote = *c;
+                            }
+                            CopyLegacyCsvOption::Escape(c) => {
+                                escape = *c;
+                            }
+                            _ => {}
+                        }
+                    }
+                }
+                _ => {}
+            }
+        }
+
+        // Simple CSV parser

Review Comment:
   Yes, but as it was handled previously it did not provide an error message 
when the CSV was not a CSV. I am not sure what is preferable.



-- 
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