alamb commented on code in PR #14723:
URL: https://github.com/apache/datafusion/pull/14723#discussion_r1958097629


##########
datafusion/substrait/src/serializer.rs:
##########
@@ -27,10 +27,13 @@ use substrait::proto::Plan;
 use std::fs::OpenOptions;
 use std::io::{Read, Write};
 
-#[allow(clippy::suspicious_open_options)]
 pub async fn serialize(sql: &str, ctx: &SessionContext, path: &str) -> 
Result<()> {
     let protobuf_out = serialize_bytes(sql, ctx).await;
-    let mut file = OpenOptions::new().create(true).write(true).open(path)?;
+    let mut file = OpenOptions::new()
+        .create(true)
+        .write(true)
+        .truncate(true)

Review Comment:
   An alternate, potentially less confusing behavior, would be to return an 
error if the file existed, so the user could decide if they meant to overwrite 
the contents or not
   
   In any event, I think it would be very helpful if you could also add 
comments to the function explaining what it does (and including the fact it 
truncates the file).
   
   
   
   
   



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