Skip to content

Commit

Permalink
typo: change delimeter to delimiter (#7521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Sep 11, 2023
1 parent 4abae3b commit 9b5733f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions datafusion/common/src/file_options/csv_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ impl TryFrom<(&ConfigOptions, &StatementOptions)> for CsvWriterOptions {
compression = CompressionTypeVariant::from_str(value.replace('\'', "").as_str())?;
builder
},
"delimeter" => {
"delimiter" => {
// Ignore string literal single quotes passed from sql parsing
let value = value.replace('\'', "");
let chars: Vec<char> = value.chars().collect();
if chars.len()>1{
return Err(DataFusionError::Configuration(format!(
"CSV Delimeter Option must be a single char, got: {}", value
"CSV Delimiter Option must be a single char, got: {}", value
)))
}
builder.with_delimiter(chars[0].try_into().map_err(|_| {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/common/src/file_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ mod tests {
option_map.insert("rfc3339".to_owned(), "true".to_owned());
option_map.insert("null_value".to_owned(), "123".to_owned());
option_map.insert("compression".to_owned(), "gzip".to_owned());
option_map.insert("delimeter".to_owned(), ";".to_owned());
option_map.insert("delimiter".to_owned(), ";".to_owned());

let options = StatementOptions::from(&option_map);
let config = ConfigOptions::new();
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/expr_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ scalar_expr!(
scalar_expr!(
ArrayToString,
array_to_string,
array delimeter,
array delimiter,
"converts each element to its text representation."
);
scalar_expr!(
Expand Down
34 changes: 17 additions & 17 deletions datafusion/physical-expr/src/array_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,18 +1471,18 @@ array_replacement_function!(
);

macro_rules! to_string {
($ARG:expr, $ARRAY:expr, $DELIMETER:expr, $NULL_STRING:expr, $WITH_NULL_STRING:expr, $ARRAY_TYPE:ident) => {{
($ARG:expr, $ARRAY:expr, $DELIMITER:expr, $NULL_STRING:expr, $WITH_NULL_STRING:expr, $ARRAY_TYPE:ident) => {{
let arr = downcast_arg!($ARRAY, $ARRAY_TYPE);
for x in arr {
match x {
Some(x) => {
$ARG.push_str(&x.to_string());
$ARG.push_str($DELIMETER);
$ARG.push_str($DELIMITER);
}
None => {
if $WITH_NULL_STRING {
$ARG.push_str($NULL_STRING);
$ARG.push_str($DELIMETER);
$ARG.push_str($DELIMITER);
}
}
}
Expand All @@ -1495,8 +1495,8 @@ macro_rules! to_string {
pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
let arr = &args[0];

let delimeters = as_generic_string_array::<i32>(&args[1])?;
let delimeters: Vec<Option<&str>> = delimeters.iter().collect();
let delimiters = as_generic_string_array::<i32>(&args[1])?;
let delimiters: Vec<Option<&str>> = delimiters.iter().collect();

let mut null_string = String::from("");
let mut with_null_string = false;
Expand All @@ -1510,7 +1510,7 @@ pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
fn compute_array_to_string(
arg: &mut String,
arr: ArrayRef,
delimeter: String,
delimiter: String,
null_string: String,
with_null_string: bool,
) -> Result<&mut String> {
Expand All @@ -1522,7 +1522,7 @@ pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
compute_array_to_string(
arg,
list_array.value(i),
delimeter.clone(),
delimiter.clone(),
null_string.clone(),
with_null_string,
)?;
Expand All @@ -1537,7 +1537,7 @@ pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
to_string!(
arg,
arr,
&delimeter,
&delimiter,
&null_string,
with_null_string,
$ARRAY_TYPE
Expand All @@ -1555,19 +1555,19 @@ pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
match arr.data_type() {
DataType::List(_) | DataType::LargeList(_) | DataType::FixedSizeList(_, _) => {
let list_array = arr.as_list::<i32>();
for (arr, &delimeter) in list_array.iter().zip(delimeters.iter()) {
if let (Some(arr), Some(delimeter)) = (arr, delimeter) {
for (arr, &delimiter) in list_array.iter().zip(delimiters.iter()) {
if let (Some(arr), Some(delimiter)) = (arr, delimiter) {
arg = String::from("");
let s = compute_array_to_string(
&mut arg,
arr,
delimeter.to_string(),
delimiter.to_string(),
null_string.clone(),
with_null_string,
)?
.clone();

if let Some(s) = s.strip_suffix(delimeter) {
if let Some(s) = s.strip_suffix(delimiter) {
res.push(Some(s.to_string()));
} else {
res.push(Some(s));
Expand All @@ -1578,20 +1578,20 @@ pub fn array_to_string(args: &[ArrayRef]) -> Result<ArrayRef> {
}
}
_ => {
// delimeter length is 1
assert_eq!(delimeters.len(), 1);
let delimeter = delimeters[0].unwrap();
// delimiter length is 1
assert_eq!(delimiters.len(), 1);
let delimiter = delimiters[0].unwrap();
let s = compute_array_to_string(
&mut arg,
arr.clone(),
delimeter.to_string(),
delimiter.to_string(),
null_string,
with_null_string,
)?
.clone();

if !s.is_empty() {
let s = s.strip_suffix(delimeter).unwrap().to_string();
let s = s.strip_suffix(delimiter).unwrap().to_string();
res.push(Some(s));
} else {
res.push(Some(s));
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/copy.slt
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ single_file_output false,
header false,
compression 'uncompressed',
datetime_format '%FT%H:%M:%S.%9f',
delimeter ';',
delimiter ';',
null_value 'NULLVAL');
----
2
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user-guide/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Unlike to some databases the math functions in Datafusion works the same way as
| array_replace_n(array, from, to, max) | Replaces the first `max` occurrences of the specified element with another specified element. `array_replace_n([1, 2, 2, 3, 2, 1, 4], 2, 5, 2) -> [1, 5, 5, 3, 2, 1, 4]` |
| array_replace_all(array, from, to) | Replaces all occurrences of the specified element with another specified element. `array_replace_all([1, 2, 2, 3, 2, 1, 4], 2, 5) -> [1, 5, 5, 3, 5, 1, 4]` |
| array_slice(array, index) | Returns a slice of the array. `array_slice([1, 2, 3, 4, 5, 6, 7, 8], 3, 6) -> [3, 4, 5, 6]` |
| array_to_string(array, delimeter) | Converts each element to its text representation. `array_to_string([1, 2, 3, 4], ',') -> 1,2,3,4` |
| array_to_string(array, delimiter) | Converts each element to its text representation. `array_to_string([1, 2, 3, 4], ',') -> 1,2,3,4` |
| cardinality(array) | Returns the total number of elements in the array. `cardinality([[1, 2, 3], [4, 5, 6]]) -> 6` |
| make_array(value1, [value2 [, ...]]) | Returns an Arrow array using the specified input expressions. `make_array(1, 2, 3) -> [1, 2, 3]` |
| trim_array(array, n) | Deprecated |
Expand Down
4 changes: 2 additions & 2 deletions docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2166,14 +2166,14 @@ array_slice(array, begin, end)
Converts each element to its text representation.

```
array_to_string(array, delimeter)
array_to_string(array, delimiter)
```

#### Arguments

- **array**: Array expression.
Can be a constant, column, or function, and any combination of array operators.
- **delimeter**: Array element separator.
- **delimiter**: Array element separator.

#### Example

Expand Down

0 comments on commit 9b5733f

Please sign in to comment.