Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
berkaysynnada committed May 9, 2024
1 parent 43be99b commit fe505a2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions datafusion/core/src/datasource/listing/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,18 @@ mod tests {
Ok(())
}

#[tokio::test]
async fn test_insert_into_sql_csv_defaults_header_row() -> Result<()> {
helper_test_insert_into_sql(
"csv",
FileCompressionType::UNCOMPRESSED,
"",
Some(HashMap::from([("has_header".into(), "true".into())])),
)
.await?;
Ok(())
}

#[tokio::test]
async fn test_insert_into_sql_json_defaults() -> Result<()> {
helper_test_insert_into_sql("json", FileCompressionType::UNCOMPRESSED, "", None)
Expand Down
4 changes: 2 additions & 2 deletions datafusion/sql/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ mod tests {
order_exprs: vec![],
if_not_exists: false,
unbounded: false,
options: Vec::new(),
options: vec![],
constraints: vec![],
});
expect_parse_ok(sql, expected)?;
Expand All @@ -910,7 +910,7 @@ mod tests {
order_exprs: vec![],
if_not_exists: false,
unbounded: false,
options: Vec::new(),
options: vec![],
constraints: vec![],
});
expect_parse_ok(sql, expected)?;
Expand Down
5 changes: 5 additions & 0 deletions datafusion/sql/src/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,10 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {

let mut options_map = HashMap::<String, String>::new();
for (key, value) in options {
if options_map.contains_key(&key) {
return plan_err!("Option {key} is specified multiple times");
}

let value_string = match value {
Value::SingleQuotedString(s) => s.to_string(),
Value::DollarQuotedString(s) => s.to_string(),
Expand All @@ -1003,6 +1007,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
);
}
};

if !(&key.contains('.')) {
// If config does not belong to any namespace, assume it is
// a format option and apply the format prefix for backwards
Expand Down

0 comments on commit fe505a2

Please sign in to comment.