Skip to content

Commit 7f99947

Browse files
authored
chore: Cleanup "!is_valid(i)" -> "is_null(i)" (#20453)
## Which issue does this PR close? N/A ## Rationale for this change This makes the code easier to read; per suggestion from @Jefffrey in code review for a different change. ## What changes are included in this PR? ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
1 parent a936d0d commit 7f99947

6 files changed

Lines changed: 9 additions & 9 deletions

File tree

datafusion/common/src/scalar/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3588,7 +3588,7 @@ impl ScalarValue {
35883588
/// Converts a value in `array` at `index` into a ScalarValue
35893589
pub fn try_from_array(array: &dyn Array, index: usize) -> Result<Self> {
35903590
// handle NULL value
3591-
if !array.is_valid(index) {
3591+
if array.is_null(index) {
35923592
return array.data_type().try_into();
35933593
}
35943594

datafusion/physical-expr-common/src/binary_view_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ where
275275
let hash = self.hashes_buffer[i];
276276

277277
// handle null value via validity bitmap check
278-
if !values.is_valid(i) {
278+
if values.is_null(i) {
279279
let payload = if let Some(&(payload, _offset)) = self.null.as_ref() {
280280
payload
281281
} else {

datafusion/physical-expr-common/src/datum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,14 @@ pub fn compare_op_for_nested(
189189
(false, false) | (true, true) => NullBuffer::union(l.nulls(), r.nulls()),
190190
(true, false) => {
191191
// When left is null-scalar and right is array, expand left nulls to match result length
192-
match l.nulls().filter(|nulls| !nulls.is_valid(0)) {
192+
match l.nulls().filter(|nulls| nulls.is_null(0)) {
193193
Some(_) => Some(NullBuffer::new_null(len)), // Left scalar is null
194194
None => r.nulls().cloned(), // Left scalar is non-null
195195
}
196196
}
197197
(false, true) => {
198198
// When right is null-scalar and left is array, expand right nulls to match result length
199-
match r.nulls().filter(|nulls| !nulls.is_valid(0)) {
199+
match r.nulls().filter(|nulls| nulls.is_null(0)) {
200200
Some(_) => Some(NullBuffer::new_null(len)), // Right scalar is null
201201
None => l.nulls().cloned(), // Right scalar is non-null
202202
}

datafusion/physical-expr/src/expressions/cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ mod tests {
336336
for (i, x) in $VEC.iter().enumerate() {
337337
match x {
338338
Some(x) => assert_eq!(result.value(i), *x),
339-
None => assert!(!result.is_valid(i)),
339+
None => assert!(result.is_null(i)),
340340
}
341341
}
342342
}};
@@ -388,7 +388,7 @@ mod tests {
388388
for (i, x) in $VEC.iter().enumerate() {
389389
match x {
390390
Some(x) => assert_eq!(result.value(i), *x),
391-
None => assert!(!result.is_valid(i)),
391+
None => assert!(result.is_null(i)),
392392
}
393393
}
394394
}};

datafusion/physical-expr/src/expressions/try_cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ mod tests {
206206
for (i, x) in $VEC.iter().enumerate() {
207207
match x {
208208
Some(x) => assert_eq!(result.value(i), *x),
209-
None => assert!(!result.is_valid(i)),
209+
None => assert!(result.is_null(i)),
210210
}
211211
}
212212
}};
@@ -260,7 +260,7 @@ mod tests {
260260
for (i, x) in $VEC.iter().enumerate() {
261261
match x {
262262
Some(x) => assert_eq!(result.value(i), *x),
263-
None => assert!(!result.is_valid(i)),
263+
None => assert!(result.is_null(i)),
264264
}
265265
}
266266
}};

datafusion/sqllogictest/src/engines/datafusion_engine/normalize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ macro_rules! get_row_value {
186186
///
187187
/// Floating numbers are rounded to have a consistent representation with the Postgres runner.
188188
pub fn cell_to_string(col: &ArrayRef, row: usize, is_spark_path: bool) -> Result<String> {
189-
if !col.is_valid(row) {
189+
if col.is_null(row) {
190190
// represent any null value with the string "NULL"
191191
Ok(NULL_STR.to_string())
192192
} else {

0 commit comments

Comments
 (0)