You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "zjregee (via GitHub)" <gi...@apache.org> on 2025/01/21 04:03:55 UTC
[PR] implement display for ColumnarValue [datafusion]
zjregee opened a new pull request, #14220:
URL: https://github.com/apache/datafusion/pull/14220
## Which issue does this PR close?
Closes #14176.
## Rationale for this change
## What changes are included in this PR?
Add a unified presentation for ColumnarValue.
## Are these changes tested?
Yes.
## Are there any user-facing changes?
None.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "zjregee (via GitHub)" <gi...@apache.org>.
zjregee commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926426256
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -218,6 +220,28 @@ impl ColumnarValue {
}
}
+// Implement Display trait for ColumnarValue
+//
+// # Panics
Review Comment:
Thanks for your help and suggestions, I have fixed this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926047838
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -218,6 +220,28 @@ impl ColumnarValue {
}
}
+// Implement Display trait for ColumnarValue
+//
+// # Panics
Review Comment:
In general I think it would be surprising of a Display impl `panic`d.
Instead in this case perhaps we can convert the errors to a string
One way to do that is instead of
```rust
pretty_format_columns("ColumnarValue(ArrayRef)", &[Arc::clone(array)])
.unwrap()
```
You can fallback on error like this:
```rust
if let Ok(formatted) = pretty_format_columns("ColumnarValue(ArrayRef)", &[Arc::clone(array)]) {
write!(f, "{}", formatted)
} else {
write!(f, "Error formatting columnar value")
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926469474
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -329,6 +354,35 @@ mod tests {
/// Makes an array of length `len` with all elements set to `val`
fn make_array(val: i32, len: usize) -> ArrayRef {
- Arc::new(arrow::array::Int32Array::from(vec![val; len]))
+ Arc::new(Int32Array::from(vec![val; len]))
+ }
+
+ #[test]
+ fn test_display_scalar() {
+ let column = ColumnarValue::from(ScalarValue::from("foo"));
+ assert_eq!(
+ column.to_string(),
+ "+----------------------------+\n\
+| ColumnarValue(ScalarValue) |\n\
++----------------------------+\n\
+| foo |\n\
++----------------------------+"
Review Comment:
I mean every line here doesn't seem to be aligned?
ideally:
```
"+----------------------------+\n\
| ColumnarValue(ScalarValue) |\n\
+----------------------------+\n\
| foo |\n\
+----------------------------+"
...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "zjregee (via GitHub)" <gi...@apache.org>.
zjregee commented on PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#issuecomment-2603613021
cc: @jayzhan211
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "zjregee (via GitHub)" <gi...@apache.org>.
zjregee commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926503055
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -329,6 +354,35 @@ mod tests {
/// Makes an array of length `len` with all elements set to `val`
fn make_array(val: i32, len: usize) -> ArrayRef {
- Arc::new(arrow::array::Int32Array::from(vec![val; len]))
+ Arc::new(Int32Array::from(vec![val; len]))
+ }
+
+ #[test]
+ fn test_display_scalar() {
+ let column = ColumnarValue::from(ScalarValue::from("foo"));
+ assert_eq!(
+ column.to_string(),
+ "+----------------------------+\n\
+| ColumnarValue(ScalarValue) |\n\
++----------------------------+\n\
+| foo |\n\
++----------------------------+"
Review Comment:
Got this, thanks and updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "xudong963 (via GitHub)" <gi...@apache.org>.
xudong963 commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926213478
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -329,6 +354,35 @@ mod tests {
/// Makes an array of length `len` with all elements set to `val`
fn make_array(val: i32, len: usize) -> ArrayRef {
- Arc::new(arrow::array::Int32Array::from(vec![val; len]))
+ Arc::new(Int32Array::from(vec![val; len]))
+ }
+
+ #[test]
+ fn test_display_scalar() {
+ let column = ColumnarValue::from(ScalarValue::from("foo"));
+ assert_eq!(
+ column.to_string(),
+ "+----------------------------+\n\
+| ColumnarValue(ScalarValue) |\n\
++----------------------------+\n\
+| foo |\n\
++----------------------------+"
Review Comment:
the format does not align
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] implement display for ColumnarValue [datafusion]
Posted by "zjregee (via GitHub)" <gi...@apache.org>.
zjregee commented on code in PR #14220:
URL: https://github.com/apache/datafusion/pull/14220#discussion_r1926431830
##########
datafusion/expr-common/src/columnar_value.rs:
##########
@@ -329,6 +354,35 @@ mod tests {
/// Makes an array of length `len` with all elements set to `val`
fn make_array(val: i32, len: usize) -> ArrayRef {
- Arc::new(arrow::array::Int32Array::from(vec![val; len]))
+ Arc::new(Int32Array::from(vec![val; len]))
+ }
+
+ #[test]
+ fn test_display_scalar() {
+ let column = ColumnarValue::from(ScalarValue::from("foo"));
+ assert_eq!(
+ column.to_string(),
+ "+----------------------------+\n\
+| ColumnarValue(ScalarValue) |\n\
++----------------------------+\n\
+| foo |\n\
++----------------------------+"
Review Comment:
I don't quite understand the meaning of `align` here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org