Skip to content

Commit fec33b7

Browse files
committed
Minor
1 parent 43be99b commit fec33b7

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

datafusion/core/src/datasource/listing/table.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,18 @@ mod tests {
15611561
Ok(())
15621562
}
15631563

1564+
#[tokio::test]
1565+
async fn test_insert_into_sql_csv_defaults_header_row() -> Result<()> {
1566+
helper_test_insert_into_sql(
1567+
"csv",
1568+
FileCompressionType::UNCOMPRESSED,
1569+
"",
1570+
Some(HashMap::from([("has_header".into(), "true".into())])),
1571+
)
1572+
.await?;
1573+
Ok(())
1574+
}
1575+
15641576
#[tokio::test]
15651577
async fn test_insert_into_sql_json_defaults() -> Result<()> {
15661578
helper_test_insert_into_sql("json", FileCompressionType::UNCOMPRESSED, "", None)

datafusion/sql/src/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ mod tests {
894894
order_exprs: vec![],
895895
if_not_exists: false,
896896
unbounded: false,
897-
options: Vec::new(),
897+
options: vec![],
898898
constraints: vec![],
899899
});
900900
expect_parse_ok(sql, expected)?;
@@ -910,7 +910,7 @@ mod tests {
910910
order_exprs: vec![],
911911
if_not_exists: false,
912912
unbounded: false,
913-
options: Vec::new(),
913+
options: vec![],
914914
constraints: vec![],
915915
});
916916
expect_parse_ok(sql, expected)?;

datafusion/sql/src/statement.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
use std::collections::hash_map::Entry;
1819
use std::collections::{BTreeMap, HashMap, HashSet};
1920
use std::path::Path;
2021
use std::str::FromStr;
@@ -983,6 +984,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
983984

984985
let mut options_map = HashMap::<String, String>::new();
985986
for (key, value) in options {
987+
if options_map.contains_key(&key) {
988+
return plan_err!("Option {key} is specified multiple times");
989+
}
990+
986991
let value_string = match value {
987992
Value::SingleQuotedString(s) => s.to_string(),
988993
Value::DollarQuotedString(s) => s.to_string(),
@@ -1003,6 +1008,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
10031008
);
10041009
}
10051010
};
1011+
10061012
if !(&key.contains('.')) {
10071013
// If config does not belong to any namespace, assume it is
10081014
// a format option and apply the format prefix for backwards

0 commit comments

Comments
 (0)