-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: array-empty
#7313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: array-empty
#7313
Changes from all commits
ac6284b
2532775
f20002d
817a506
16e1749
cfbee16
daf5907
2424ca7
89a523c
9bc126e
8e5f079
8df5ba2
c6f5144
f8176f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -986,6 +986,21 @@ macro_rules! general_repeat_list { | |
}}; | ||
} | ||
|
||
/// Array_empty SQL function | ||
pub fn array_empty(args: &[ArrayRef]) -> Result<ArrayRef> { | ||
println!("args[0]: {:?}", &args[0]); | ||
if args[0].as_any().downcast_ref::<NullArray>().is_some() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this doesn't catch all nulls. This only works within the test setup because SELECT array_empty(a)
FROM VALUES(NULL, make_array(), make_array(1)) sub (a); I suggest you remove this check and change the else part within There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but that doesn't mean we have to add more immature code, esp. when the fix is rather simple (I would argue the fixed code is even simpler than the current version). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It cannot handle all NULL array cases in this way, but I think we can wait #7142 to make this pr better. |
||
return Ok(args[0].clone()); | ||
} | ||
|
||
let array = as_list_array(&args[0])?; | ||
let builder = array | ||
.iter() | ||
.map(|arr| arr.map(|arr| arr.len() == arr.null_count())) | ||
.collect::<BooleanArray>(); | ||
Ok(Arc::new(builder)) | ||
} | ||
|
||
/// Array_repeat SQL function | ||
pub fn array_repeat(args: &[ArrayRef]) -> Result<ArrayRef> { | ||
let element = &args[0]; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.