You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Cerdore (via GitHub)" <gi...@apache.org> on 2024/02/01 16:43:07 UTC
[PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Cerdore opened a new pull request, #39888:
URL: https://github.com/apache/arrow/pull/39888
### Rationale for this change
Support showing metadata of nested DataType which have child fields.
### What changes are included in this PR?
Add an optional argument "show_metadata" to the ToString() of DataType and other DataType derived class. And we also add it to TypeHolder::ToString().
### Are these changes tested?
Yes, I add test for them.
### Are there any user-facing changes?
No.
Closes: #39866
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "Cerdore (via GitHub)" <gi...@apache.org>.
Cerdore commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1921759196
MapType::ToString() don't show the metadata currently. It use type().ToString() and field.name().
I didn't change here.
```
const auto print_field_name = [](std::ostream& os, const Field& field,
const char* std_name) {
if (field.name() != std_name) {
os << " ('" << field.name() << "')";
}
};
const auto print_field = [&](std::ostream& os, const Field& field,
const char* std_name) {
os << field.type()->ToString(show_metadata);
print_field_name(os, field, std_name);
};
```
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "conbench-apache-arrow[bot] (via GitHub)" <gi...@apache.org>.
conbench-apache-arrow[bot] commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1968843763
After merging your PR, Conbench analyzed the 7 benchmarking runs that have been run so far on merge-commit c5f60a02fe5c7106960824cb500f553623b7d97e.
There were no benchmark performance regressions. 🎉
The [full Conbench report](https://github.com/apache/arrow/runs/22075785067) has more details. It also includes information about 12 possible false positives for unstable benchmarks that are known to sometimes produce them.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on code in PR #39888:
URL: https://github.com/apache/arrow/pull/39888#discussion_r1482644992
##########
cpp/src/arrow/testing/gtest_util.cc:
##########
@@ -238,7 +238,7 @@ std::string ToStringWithMetadata(const T& t, bool show_metadata) {
}
std::string ToStringWithMetadata(const DataType& t, bool show_metadata) {
- return t.ToString();
+ return t.ToString(show_metadata);
}
Review Comment:
Thanks, but this can actually be simplified now. `ToStringWithMetadata` was created because `DataType::ToString` didn't support the `show_metadata` argument. Now that it does, `ToStringWithMetadata` can probably be suppressed and all calls to `ToStringWithMetadata(t, show_metadata)` replaced with `t.ToString(show_metadata)`.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou merged PR #39888:
URL: https://github.com/apache/arrow/pull/39888
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1921752155
:warning: GitHub issue #39864 **has been automatically assigned in GitHub** to PR creator.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "mapleFU (via GitHub)" <gi...@apache.org>.
mapleFU commented on code in PR #39888:
URL: https://github.com/apache/arrow/pull/39888#discussion_r1477337106
##########
cpp/src/arrow/type_test.cc:
##########
@@ -2124,6 +2135,12 @@ TEST(TestStructType, TestFieldsDifferOnlyInMetadata) {
AssertTypeEqual(s0, s1);
AssertTypeNotEqual(s0, s1, /* check_metadata = */ true);
+ ASSERT_NE(s0.ToString(), s1.ToString(true));
+
+ std::string expected = R"(struct<f: string
+-- metadata --
+foo: baz, f: string>)";
+ ASSERT_EQ(s1.ToString(true), expected);
Review Comment:
```suggestion
ASSERT_EQ(s1.ToString(/*show_metadata=*/true), expected);
```
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "pitrou (via GitHub)" <gi...@apache.org>.
pitrou commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1932240779
I mean change these now that `DataType::ToString` accepts a `show_metadata` argument:
https://github.com/apache/arrow/blob/8ffc2140af3c994240b62f3c6412b8dbc889f604/cpp/src/arrow/testing/gtest_util.cc#L235-L242
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "Cerdore (via GitHub)" <gi...@apache.org>.
Cerdore commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1972603521
> I've made a few minor changes. Thanks @Cerdore for tackling this, I'll be merging this PR if CI passes.
Sorry, I've been busy with some other things lately... And thank you very much for your suggestions and subsequent changes!
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "Cerdore (via GitHub)" <gi...@apache.org>.
Cerdore commented on code in PR #39888:
URL: https://github.com/apache/arrow/pull/39888#discussion_r1481264617
##########
cpp/src/arrow/type_test.cc:
##########
@@ -2124,6 +2135,12 @@ TEST(TestStructType, TestFieldsDifferOnlyInMetadata) {
AssertTypeEqual(s0, s1);
AssertTypeNotEqual(s0, s1, /* check_metadata = */ true);
+ ASSERT_NE(s0.ToString(), s1.ToString(true));
+
+ std::string expected = R"(struct<f: string
+-- metadata --
+foo: baz, f: string>)";
+ ASSERT_EQ(s1.ToString(true), expected);
Review Comment:
Already changed. Thank you!
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "Cerdore (via GitHub)" <gi...@apache.org>.
Cerdore commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1932260079
> I mean change these now that `DataType::ToString` accepts a `show_metadata` argument:
Thank you! I see.
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GH-39864: [C++] DataType::ToString support optionally show metadata [arrow]
Posted by "Cerdore (via GitHub)" <gi...@apache.org>.
Cerdore commented on PR #39888:
URL: https://github.com/apache/arrow/pull/39888#issuecomment-1932169231
> Can you also change `AssertTypeEqual` so that it shows the metadata on error?
`AssertTypeEqual(ty1, ty2, /*check_metadata*/true);
`
Should I do it above way or modify the implementation of AssertTypeEqual?
--
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@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org