Skip to content

Commit

Permalink
fix: docs fmt, add clippy atr, sql error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
gstvg committed Aug 22, 2024
1 parent 1740dfe commit 4f34083
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
24 changes: 21 additions & 3 deletions datafusion/functions/benches/union_extract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#[macro_use]
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

extern crate criterion;

use crate::criterion::Criterion;
use arrow::{
array::{
Array, BooleanArray, Int32Array, Int8Array, NullArray, StringArray, UnionArray,
Expand All @@ -12,7 +27,7 @@ use arrow::{
},
};
use arrow_buffer::ScalarBuffer;
use criterion::black_box;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use datafusion_common::ScalarValue;
use datafusion_expr::{ColumnarValue, ScalarUDFImpl};
use datafusion_functions::core::union_extract::{
Expand Down Expand Up @@ -965,6 +980,7 @@ fn criterion_benchmark(c: &mut Criterion) {
is_sequential_group.bench_function("offsets sequential windows fold &&", |b| {
b.iter(|| {
black_box(
#[allow(clippy::unnecessary_fold)]
offsets
.windows(2)
.fold(true, |b, w| b && (w[0] + 1 == w[1])),
Expand Down Expand Up @@ -993,6 +1009,7 @@ fn criterion_benchmark(c: &mut Criterion) {
is_sequential_group.bench_function("offsets sequential fold &&", |b| {
b.iter(|| {
black_box(
#[allow(clippy::unnecessary_fold)]
offsets
.iter()
.copied()
Expand Down Expand Up @@ -1055,6 +1072,7 @@ fn criterion_benchmark(c: &mut Criterion) {
});

type_ids_eq.bench_function("type_ids equal fold &&", |b| {
#[allow(clippy::unnecessary_fold)]
b.iter(|| type_ids.iter().fold(true, |b, v| b && (*v == type_id)))
});

Expand Down
17 changes: 1 addition & 16 deletions datafusion/sqllogictest/test_files/union_datatype.slt
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,15 @@ select union_extract(my_union, 'int'), expected, my_union from empty_dense_union

query error
select union_extract() from empty_dense_union;
----
DataFusion error: Error during planning: Error during planning: union_extract does not support zero arguments. No function matches the given name and argument types 'union_extract()'. You might need to add explicit type casts.
Candidate functions:
union_extract(Any, Any)


query error
select union_extract(my_union) from empty_dense_union;
----
DataFusion error: Error during planning: Error during planning: The function expected 2 arguments but received 1 No function matches the given name and argument types 'union_extract(Union([], Dense))'. You might need to add explicit type casts.
Candidate functions:
union_extract(Any, Any)


query error
select union_extract('a') from empty_dense_union;
----
DataFusion error: Error during planning: Error during planning: The function expected 2 arguments but received 1 No function matches the given name and argument types 'union_extract(Utf8)'. You might need to add explicit type casts.
Candidate functions:
union_extract(Any, Any)



query error DataFusion error: Execution error: union_extract first argument must be a union, got Utf8 instead
Expand All @@ -264,7 +253,3 @@ select union_extract(my_union, 1) from empty_dense_union;

query error
select union_extract(my_union, 'a', 'b') from empty_dense_union;
----
DataFusion error: Error during planning: Error during planning: The function expected 2 arguments but received 3 No function matches the given name and argument types 'union_extract(Union([], Dense), Utf8, Utf8)'. You might need to add explicit type casts.
Candidate functions:
union_extract(Any, Any)
1 change: 0 additions & 1 deletion docs/source/user-guide/sql/scalar_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3881,7 +3881,6 @@ union_extract(union, field_name)
```


## Other Functions

- [arrow_cast](#arrow_cast)
Expand Down

0 comments on commit 4f34083

Please sign in to comment.