Skip to content

Commit 0088c28

Browse files
Remove FORMAT <..> backwards compatibility options from COPY (#9985)
* Revert "Add test for reading back file created with FORMAT options (#9753)" This reverts commit b50f3aa. * Revert "support format in options of COPY command (#9744)" This reverts commit 40fb1b8. * update docs and example to remove old syntax
1 parent ad0abe9 commit 0088c28

File tree

5 files changed

+7
-83
lines changed

5 files changed

+7
-83
lines changed

datafusion/sql/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ impl fmt::Display for ExplainStatement {
8787
///
8888
/// ```sql
8989
/// COPY lineitem TO 'lineitem'
90-
/// (format parquet,
90+
/// STORED AS PARQUET (
9191
/// partitions 16,
9292
/// row_group_limit_rows 100000,
9393
/// row_group_limit_bytes 200000
94-
/// )
94+
/// )
9595
///
9696
/// COPY (SELECT l_orderkey from lineitem) to 'lineitem.parquet';
9797
/// ```

datafusion/sql/src/statement.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
850850
return plan_err!("Unsupported Value in COPY statement {}", value);
851851
}
852852
};
853-
if !(key.contains('.') || key == "format") {
853+
if !(&key.contains('.')) {
854854
// If config does not belong to any namespace, assume it is
855855
// a format option and apply the format prefix for backwards
856856
// compatibility.
@@ -866,16 +866,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
866866
FileType::from_str(&file_type).map_err(|_| {
867867
DataFusionError::Configuration(format!("Unknown FileType {}", file_type))
868868
})?
869-
} else if let Some(format) = options.remove("format") {
870-
// try to infer file format from the "format" key in options
871-
FileType::from_str(&format)
872-
.map_err(|e| DataFusionError::Configuration(format!("{}", e)))?
873869
} else {
874870
let e = || {
875871
DataFusionError::Configuration(
876-
"Format not explicitly set and unable to get file extension! Use STORED AS to define file format."
877-
.to_string(),
878-
)
872+
"Format not explicitly set and unable to get file extension! Use STORED AS to define file format."
873+
.to_string(),
874+
)
879875
};
880876
// try to infer file format from file extension
881877
let extension: &str = &Path::new(&statement.target)

datafusion/sql/tests/sql_integration.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,6 @@ CopyTo: format=csv output_url=output.csv options: ()
444444
quick_test(sql, plan);
445445
}
446446

447-
#[test]
448-
fn plan_copy_stored_as_priority() {
449-
let sql = "COPY (select * from (values (1))) to 'output/' STORED AS CSV OPTIONS (format json)";
450-
let plan = r#"
451-
CopyTo: format=csv output_url=output/ options: (format json)
452-
Projection: column1
453-
Values: (Int64(1))
454-
"#
455-
.trim();
456-
quick_test(sql, plan);
457-
}
458-
459447
#[test]
460448
fn plan_insert() {
461449
let sql =

datafusion/sqllogictest/test_files/copy.slt

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -514,65 +514,6 @@ OPTIONS (
514514
);
515515

516516

517-
# Format Options Support with format in OPTIONS
518-
#
519-
# i.e. COPY { table_name | query } TO 'file_name' OPTIONS (format <format-name>, ...)
520-
521-
# Ensure that the format is set in the OPTIONS, not extension
522-
query I
523-
COPY (select * from (values (1))) to 'test_files/scratch/copy/foo.dat'
524-
OPTIONS (format parquet);
525-
----
526-
1
527-
528-
statement ok
529-
CREATE EXTERNAL TABLE foo_dat STORED AS PARQUET LOCATION 'test_files/scratch/copy/foo.dat';
530-
531-
query I
532-
select * from foo_dat;
533-
----
534-
1
535-
536-
statement ok
537-
DROP TABLE foo_dat;
538-
539-
540-
query I
541-
COPY (select * from (values (1))) to 'test_files/scratch/copy'
542-
OPTIONS (format parquet);
543-
----
544-
1
545-
546-
query I
547-
COPY (select * from (values (1))) to 'test_files/scratch/copy/'
548-
OPTIONS (format parquet, compression 'zstd(10)');
549-
----
550-
1
551-
552-
query I
553-
COPY (select * from (values (1))) to 'test_files/scratch/copy/'
554-
OPTIONS (format json, compression gzip);
555-
----
556-
1
557-
558-
query I
559-
COPY (select * from (values (1))) to 'test_files/scratch/copy/'
560-
OPTIONS (
561-
format csv,
562-
has_header false,
563-
compression xz,
564-
datetime_format '%FT%H:%M:%S.%9f',
565-
delimiter ';',
566-
null_value 'NULLVAL'
567-
);
568-
----
569-
1
570-
571-
query error DataFusion error: Invalid or Unsupported Configuration: This feature is not implemented: Unknown FileType: NOTVALIDFORMAT
572-
COPY (select * from (values (1))) to 'test_files/scratch/copy/'
573-
OPTIONS (format notvalidformat, compression 'zstd(5)');
574-
575-
576517
# Error cases:
577518

578519
# Copy from table with options

docs/source/user-guide/sql/dml.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ separate hive-style directories.
4444
The output format is determined by the first match of the following rules:
4545

4646
1. Value of `STORED AS`
47-
2. Value of the `OPTION (FORMAT ..)`
48-
3. Filename extension (e.g. `foo.parquet` implies `PARQUET` format)
47+
2. Filename extension (e.g. `foo.parquet` implies `PARQUET` format)
4948

5049
For a detailed list of valid OPTIONS, see [Write Options](write_options).
5150

0 commit comments

Comments
 (0)