kosiew commented on code in PR #25824:
URL: https://github.com/apache/datafusion/pull/25824#discussion_r4323642454


##########
datafusion/core/tests/sql/sql_api.rs:
##########
@@ -116,6 +116,30 @@ async fn unsupported_copy_returns_error() {
     ctx.sql_with_options(&sql, options).await.unwrap();
 }
 
+#[tokio::test]
+async fn copy_can_be_disabled_independently_from_dml() {
+    let tmpdir = TempDir::new().unwrap();
+    let tmpfile = tmpdir.path().join("foo.parquet");
+
+    let ctx = SessionContext::new();
+    ctx.sql("CREATE TABLE test (x int)").await.unwrap();
+
+    let options = SQLOptions::new().with_allow_copy(false);
+    let sql = format!(
+        "COPY (values(1)) TO '{}' STORED AS parquet",
+        tmpfile.to_string_lossy()
+    );
+    let df = ctx.sql_with_options(&sql, options).await;
+    assert_eq!(
+        df.unwrap_err().strip_backtrace(),
+        "Error during planning: COPY not supported"
+    );
+
+    ctx.sql_with_options("INSERT INTO test VALUES (1)", options)
+        .await
+        .unwrap();

Review Comment:
   Could we also collect the INSERT DataFrame and query `test` to verify the 
row was written? The current test only checks that planning succeeds, so a 
readback would confirm that INSERT actually works with COPY disabled.



##########
datafusion/core/tests/sql/sql_api.rs:
##########
@@ -116,6 +116,30 @@ async fn unsupported_copy_returns_error() {
     ctx.sql_with_options(&sql, options).await.unwrap();
 }
 
+#[tokio::test]
+async fn copy_can_be_disabled_independently_from_dml() {
+    let tmpdir = TempDir::new().unwrap();
+    let tmpfile = tmpdir.path().join("foo.parquet");
+
+    let ctx = SessionContext::new();
+    ctx.sql("CREATE TABLE test (x int)").await.unwrap();
+
+    let options = SQLOptions::new().with_allow_copy(false);

Review Comment:
   Could we also test re-enabling COPY with `options.with_allow_copy(true)` and 
verify that the same COPY statement is accepted? This would add coverage for 
both settings of the new flag.



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