shyjsarah commented on code in PR #25824:
URL: https://github.com/apache/datafusion/pull/25824#discussion_r4323981126
##########
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:
Thanks! Updated the test to collect the INSERT DataFrame, then query `test`
with COPY still disabled and assert that it contains exactly one row with `x =
1`.
##########
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:
Added a check that re-enables COPY with `options.with_allow_copy(true)` and
verifies that the same COPY statement is accepted.
--
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]