You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "llama90 (via GitHub)" <gi...@apache.org> on 2023/12/12 08:28:51 UTC
[PR] GH-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
llama90 opened a new pull request, #39192:
URL: https://github.com/apache/arrow/pull/39192
<!--
Thanks for opening a pull request!
If this is your first pull request you can find detailed information on how
to contribute here:
* [New Contributor's Guide](https://arrow.apache.org/docs/dev/developers/guide/step_by_step/pr_lifecycle.html#reviews-and-merge-of-the-pull-request)
* [Contributing Overview](https://arrow.apache.org/docs/dev/developers/overview.html)
If this is not a [minor PR](https://github.com/apache/arrow/blob/main/CONTRIBUTING.md#Minor-Fixes). Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose
Opening GitHub issues ahead of time contributes to the [Openness](http://theapacheway.com/open/#:~:text=Openness%20allows%20new%20users%20the,must%20happen%20in%20the%20open.) of the Apache Arrow project.
Then could you also rename the pull request title in the following format?
GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
or
MINOR: [${COMPONENT}] ${SUMMARY}
In the case of PARQUET issues on JIRA the title also supports:
PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}
-->
### Rationale for this change
Add deprecate macro to `CastTo` function for maintenance.
<!--
Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.
-->
### What changes are included in this PR?
* Add deprecated macro to `CastTo` function.
* Wrap the code using the `CastTo` function with `ARROW_SUPPRESS_DEPRECATION_WARNING` and `ARROW_UNSUPPRESS_DEPRECATION_WARNING` macros.
* Remove legacy code that was no longer needed and could be easily deleted without any additional implementation. (Related to #39050)
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
### Are these changes tested?
Yes. It is passed by existing test cases.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
### Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please uncomment the line below and explain which changes are breaking.
-->
<!-- **This PR includes breaking changes to public APIs.** -->
<!--
Please uncomment the line below (and provide explanation) if the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld). We use this to highlight fixes to issues that may affect users without their knowledge. For this reason, fixing bugs that cause errors don't count, since those are usually obvious.
-->
<!-- **This PR contains a "Critical Fix".** -->
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "AlenkaF (via GitHub)" <gi...@apache.org>.
AlenkaF commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1925346864
> Could you help me identify any broken workflows related to Python? I searched the codebase for `CastTo`, but couldn't find it in the Python parts. I'm puzzled as to why the workflow error mentions `CastTo`.
>
> * https://github.com/apache/arrow/actions/runs/7765982118/job/21181283847?pr=39192
>
> * `pyarrow_cython_example.cpp:8782:46: error: 'using element_type = std::remove_extent<arrow::Scalar>::type' {aka 'struct arrow::Scalar'} has no member named 'CastTo'; did you mean 'cast'?`
There are occurrences in Cython that still bind to/use `CastTo` from C++ and so [Cython tests](https://github.com/apache/arrow/blob/22f2cfd1e1ebe49016b6d97c49f494287a98d02f/python/pyarrow/tests/test_cython.py) fail, see https://github.com/search?q=repo%3Aapache%2Farrow+CastTo+language%3ACython&type=code&l=Cython
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1880292147
:warning: GitHub issue #39182 **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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1477187843
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
Review Comment:
Sorry. I'm missing this context. Could you explain what is the problem and what we need to solve it?
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1855224698
@bkietz I got it.
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1444123716
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +997,11 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ auto maybe_repr = Cast(CastToExplicitScalar(), utf8());
Review Comment:
If explicit conversions to Scalar types are not made, calling a test like the one below results in an error due to casting failure.
https://github.com/apache/arrow/blob/de3130ede1a2db7bbe9e129f21856ee80de0f8cb/cpp/src/arrow/datum_test.cc#L155
The part where an error occurs
https://github.com/apache/arrow/blob/de3130ede1a2db7bbe9e129f21856ee80de0f8cb/cpp/src/arrow/array/data.cc#L333-L523
For example, in the case of the above unit test, the Scalar type that should be passed to the `FillFromScalar` function is `Int8Scalar`. However, if it is not explicitly converted, it is passed as a generic `Scalar` type. Consequently, when performing a conversion like `const auto& scalar = checked_cast<const internal::PrimitiveScalarBase&>(value);`, an error "C++ exception with description 'std::bad_cast' thrown in the test body." occurs.
I am curious if there is a better approach. 🤔
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "thisisnic (via GitHub)" <gi...@apache.org>.
thisisnic commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-3547438582
Thank you for your contribution. Unfortunately, this
pull request has been marked as stale because it has had no activity in the past 365 days. Please remove the stale label
or comment below, or this PR will be closed in 14 days. Feel free to re-open this if it has been closed in error. If you
do not have repository permissions to reopen the PR, please tag a maintainer.
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "bkietz (via GitHub)" <gi...@apache.org>.
bkietz commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1478495963
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
Review Comment:
ToString shouldn't be extended here. I think that adding options would decrease the C++ API's usability; we rely on ToString being a simple string representation in unit testing and error messages.
Please add special cases as necessary to preserve the existing behavior for Scalar::ToString; I think it'd be worthwhile in a follow-up to remove those special cases but that'd be a breaking change and should be guarded accordingly.
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1426230318
##########
c_glib/arrow-glib/scalar.cpp:
##########
@@ -385,7 +385,9 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ ARROW_SUPPRESS_DEPRECATION_WARNING
auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ ARROW_UNSUPPRESS_DEPRECATION_WARNING
Review Comment:
@kou hello. Thank you for your review.
Is it recommended to create a new issue for making a new PR, or is it okay if multiple PRs are linked to an existing issue?
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1424433287
##########
c_glib/arrow-glib/scalar.cpp:
##########
@@ -385,7 +385,9 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ ARROW_SUPPRESS_DEPRECATION_WARNING
auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ ARROW_UNSUPPRESS_DEPRECATION_WARNING
Review Comment:
Could you use the following instead of this?
```diff
diff --git a/c_glib/arrow-glib/scalar.cpp b/c_glib/arrow-glib/scalar.cpp
index d25bdaf89d..64503ea430 100644
--- a/c_glib/arrow-glib/scalar.cpp
+++ b/c_glib/arrow-glib/scalar.cpp
@@ -26,6 +26,8 @@
#include <arrow-glib/interval.hpp>
#include <arrow-glib/scalar.hpp>
+#include <arrow/compute/cast.h>
+
G_BEGIN_DECLS
/**
@@ -385,9 +387,10 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
- auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ auto arrow_casted_scalar_result =
+ arrow::compute::Cast(arrow_scalar, arrow_data_type);
if (garrow::check(error, arrow_casted_scalar_result, "[scalar][cast]")) {
- auto arrow_casted_scalar = *arrow_casted_scalar_result;
+ auto arrow_casted_scalar = (*arrow_casted_scalar_result).scalar();
return garrow_scalar_new_raw(&arrow_casted_scalar,
"scalar", &arrow_casted_scalar,
"data-type", data_type,
```
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1424433780
##########
c_glib/arrow-glib/scalar.cpp:
##########
@@ -385,7 +385,9 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ ARROW_SUPPRESS_DEPRECATION_WARNING
auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ ARROW_UNSUPPRESS_DEPRECATION_WARNING
Review Comment:
(A separated PR is better.)
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1851532428
@bkietz Hello. Is this your intention in creating the issue?
Also, thank you for creating the issue. It helped me spot and remove some code I missed.
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1925305107
Could you help me identify any broken workflows related to Python? I searched the codebase for `CastTo`, but couldn't find it in the Python parts. I'm puzzled as to why the workflow error mentions `CastTo`.
- https://github.com/apache/arrow/actions/runs/7765982118/job/21181283847?pr=39192
- `pyarrow_cython_example.cpp:8782:46: error: 'using element_type = std::remove_extent<arrow::Scalar>::type' {aka 'struct arrow::Scalar'} has no member named 'CastTo'; did you mean 'cast'?`
cc @AlenkaF @jorisvandenbossche
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1426243159
##########
c_glib/arrow-glib/scalar.cpp:
##########
@@ -385,7 +385,9 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ ARROW_SUPPRESS_DEPRECATION_WARNING
auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ ARROW_UNSUPPRESS_DEPRECATION_WARNING
Review Comment:
Could you open one issue per PR?
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1925247240
### For recoding
#### glib test log
<details><summary>test log</summary>
```bash
î‚° BUNDLE_GEMFILE=../c_glib/Gemfile bundle exec ../c_glib/test/run-test.sh
[72/81] Generating arrow-flight-glib/ArrowFlight-1.0.gir with a custom command (wrapped by meson to set env)
Package 'arrow', required by 'arrow-glib-uninstalled', not found
[74/81] Generating gandiva-glib/Gandiva-1.0.gir with a custom command (wrapped by meson to set env)
Package 'arrow', required by 'arrow-glib-uninstalled', not found
[76/81] Generating parquet-glib/Parquet-1.0.gir with a custom command (wrapped by meson to set env)
Package 'arrow', required by 'arrow-glib-uninstalled', not found
[78/81] Generating arrow-dataset-glib/ArrowDataset-1.0.gir with a custom command (wrapped by meson to set env)
Package 'arrow', required by 'arrow-glib-uninstalled', not found
[80/81] Generating arrow-flight-sql-glib/ArrowFlightSQL-1.0.gir with a custom command (wrapped by meson to set env)
Package 'arrow', required by 'arrow-glib-uninstalled', not found
[81/81] Generating arrow-flight-sql-glib/ArrowFlightSQL-1.0.typelib with a custom command
Loaded suite test
Started
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_context(TestCUDA::Buffer)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_copy(TestCUDA::Buffer)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_export(TestCUDA::Buffer)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_default(TestCUDA::Buffer::#read_record_batch)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_options(TestCUDA::Buffer::#read_record_batch)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_new(TestCUDA::BufferInputStream)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_buffer(TestCUDA::BufferOutputStream)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_new(TestCUDA::BufferOutputStream)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_allocated_size(TestCUDA::Context)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: Arrow CUDA is required [test_new(TestCUDA::HostBuffer)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-cuda.rb:23:in `setup'
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestDayTimeIntervalScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-day-time-interval-scalar.rb:41:in `test_to_s'
38: end
39:
40: def test_to_s
=> 41: assert_equal("3d100ms", @scalar.to_s)
42: end
43:
44: def test_value
<"3d100ms"> expected but was
<"[\n" + " 3d100ms\n" + "]">
diff:
+ [
? 3d100ms
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestDenseUnionScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-dense-union-scalar.rb:52:in `test_to_s'
49: end
50:
51: def test_to_s
=> 52: assert_equal("union{number: int8 = -29}", @scalar.to_s)
53: end
54:
55: def test_value
<"union{number: int8 = -29}"> expected but was
<"-- is_valid: all not null\n" +
"-- type_ids: [\n" +
" 2\n" +
" ]\n" +
"-- value_offsets: [\n" +
" 0\n" +
" ]\n" +
"-- child 0 type: int8\n" +
" [\n" +
" -29\n" +
" ]\n" +
"-- child 1 type: string\n" +
" []">
diff:
+ -- is_valid: all not null
+ -- type_ids: [
+ 2
+ ]
+ -- value_offsets: [
+ 0
+ ]
? un ion{numb er: int8 = -29}
? -- ch ld 0 typ
? ?? ??????? - -------
+ [
+ -29
+ ]
+ -- child 1 type: string
+ []
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: gobject-introspection gem doesn't support implementing methods for GLib object yet [test_extension_name(TestExtensionDataType)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-extension-data-type.rb:66:in `test_extension_name'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: gobject-introspection gem doesn't support implementing methods for GLib object yet [test_to_s(TestExtensionDataType)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-extension-data-type.rb:54:in `test_to_s'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: gobject-introspection gem doesn't support implementing methods for GLib object yet [test_wrap_array(TestExtensionDataType)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-extension-data-type.rb:72:in `test_wrap_array'
==================================================================================================================================================================================================
O
==================================================================================================================================================================================================
Omission: gobject-introspection gem doesn't support implementing methods for GLib object yet [test_wrap_chunked_array(TestExtensionDataType)]
/Users/lama/workspace/arrow-latest/c_glib/test/test-extension-data-type.rb:88:in `test_wrap_chunked_array'
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestListScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-list-scalar.rb:44:in `test_to_s'
41: end
42:
43: def test_to_s
=> 44: assert_equal("list<item: list<value: int8>>[list<value: int8>[1, 2, 3]]",
45: @scalar.to_s)
46: end
47:
<"list<item: list<value: int8>>[list<value: int8>[1, 2, 3]]"> expected but was
<"[\n" + " [\n" + " 1,\n" + " 2,\n" + " 3\n" + " ]\n" + "]">
diff:
+ [
+ [
+ 1,
? list<item: list<value: int8>>[list<value: int8>[1, 2, 3]]
?
? ?????????????????????????????????????????????????? ----
+ 3
+ ]
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestMapScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-map-scalar.rb:59:in `test_to_s'
56: end
57:
58: def test_to_s
=> 59: assert_equal(<<-MAP.strip, @scalar.to_s)
60: map<string, int8>[{key:string = hello, value:int8 = 1}, {key:string = world, value:int8 = 2}]
61: MAP
62: end
<"map<string, int8>[{key:string = hello, value:int8 = 1}, {key:string = world, value:int8 = 2}]"> expected but was
<"[\n" +
" keys:\n" +
" [\n" +
" \"hello\",\n" +
" \"world\"\n" +
" ]\n" +
" values:\n" +
" [\n" +
" 1,\n" +
" 2\n" +
" ]\n" +
"]">
diff:
+ [
+ keys:
+ [
+ "hello",
+ "world"
+ ]
? map<string, int8>[{key:string = hello, value :int8 = 1}, {key:string = world, value:int8 = 2}]
? s
? ?????????????????????????????????????? + ------------------------------------------------
+ [
+ 1,
+ 2
+ ]
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestMonthDayNanoIntervalScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-month-day-nano-interval-scalar.rb:41:in `test_to_s'
38: end
39:
40: def test_to_s
=> 41: assert_equal("3M10d100ns", @scalar.to_s)
42: end
43:
44: def test_value
<"3M10d100ns"> expected but was
<"[\n" + " 3M10d100ns\n" + "]">
diff:
+ [
? 3M10d100ns
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestMonthIntervalScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-month-interval-scalar.rb:41:in `test_to_s'
38: end
39:
40: def test_to_s
=> 41: assert_equal("1M", @scalar.to_s)
42: end
43:
44: def test_value
<"1M"> expected but was
<"[\n" + " 1M\n" + "]">
diff:
+ [
? 1M
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestSparseUnionScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-sparse-union-scalar.rb:52:in `test_to_s'
49: end
50:
51: def test_to_s
=> 52: assert_equal("union{number: int8 = -29}", @scalar.to_s)
53: end
54:
55: def test_value
<"union{number: int8 = -29}"> expected but was
<"-- is_valid: all not null\n" +
"-- type_ids: [\n" +
" 2\n" +
" ]\n" +
"-- child 0 type: int8\n" +
" [\n" +
" -29\n" +
" ]\n" +
"-- child 1 type: string\n" +
" [\n" +
" null\n" +
" ]">
diff:
+ -- is_valid: all not null
+ -- type_ids: [
+ 2
+ ]
? un ion{numb er: int8 = -29}
? -- ch ld 0 typ
? ?? ??????? - -------
+ [
+ -29
+ ]
+ -- child 1 type: string
+ [
+ null
+ ]
==================================================================================================================================================================================================
F
==================================================================================================================================================================================================
Failure: test_to_s(TestStructScalar)
/Users/lama/workspace/arrow-latest/c_glib/test/test-struct-scalar.rb:51:in `test_to_s'
48: end
49:
50: def test_to_s
=> 51: assert_equal("{score:int8 = -29, enabled:bool = true}", @scalar.to_s)
52: end
53:
54: def test_value
<"{score:int8 = -29, enabled:bool = true}"> expected but was
<"-- is_valid: all not null\n" +
"-- child 0 type: int8\n" +
" [\n" +
" -29\n" +
" ]\n" +
"-- child 1 type: bool\n" +
" [\n" +
" true\n" +
" ]">
diff:
+ -- is_valid: all not null
? {s cor e: int8 = -29, enabled:bool = true}
? -- hild 0 typ
? ?? ?? + ----------------------------
+ [
+ -29
+ ]
+ -- child 1 type: bool
+ [
+ true
+ ]
==================================================================================================================================================================================================
\/Users/lama/workspace/arrow-latest/cpp/src/gandiva/cache.cc:50: Creating gandiva cache with capacity of 500
/Users/lama/workspace/arrow-latest/cpp/src/gandiva/engine.cc:265: Detected CPU Name : apple-m1
/Users/lama/workspace/arrow-latest/cpp/src/gandiva/engine.cc:266: Detected CPU Features: []
Finished in 72.076868 seconds.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1922 tests, 2092 assertions, 8 failures, 0 errors, 0 pendings, 14 omissions, 0 notifications
99.5807% passed
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
26.67 tests/s, 29.02 assertions/s
```
</details>
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1426230318
##########
c_glib/arrow-glib/scalar.cpp:
##########
@@ -385,7 +385,9 @@ garrow_scalar_cast(GArrowScalar *scalar,
{
const auto arrow_scalar = garrow_scalar_get_raw(scalar);
const auto arrow_data_type = garrow_data_type_get_raw(data_type);
+ ARROW_SUPPRESS_DEPRECATION_WARNING
auto arrow_casted_scalar_result = arrow_scalar->CastTo(arrow_data_type);
+ ARROW_UNSUPPRESS_DEPRECATION_WARNING
Review Comment:
@kou hello.
Is it recommended to create a new issue for making a new PR, or is it okay if multiple PRs are linked to an existing issue?
--
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-39182: [C++] Add Deprecate Macro to CastTo function [arrow]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1851522094
:warning: GitHub issue #39182 **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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-1936869581
We want to address issues that are connected with other languages (`ruby`, `python`..) first, especially those parts that can be solved independently for each language.
- #40023
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 closed pull request #39192: GH-39182: [C++] Remove Legacy CastTo function
URL: https://github.com/apache/arrow/pull/39192
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "bkietz (via GitHub)" <gi...@apache.org>.
bkietz commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1475152098
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +997,11 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ auto maybe_repr = Cast(CastToExplicitScalar(), utf8());
Review Comment:
I'm not sure what the intent of CastToExplicitScalar is. I'm guessing that you only need it in order to pass a `shared_ptr<Scalar>` to `Cast`. Have you tried using `shared_from_this` instead?
```suggestion
auto maybe_repr = Cast(shared_from_this(), utf8());
```
As for the bad_cast exception, I don't think I have enough information to understand how that would be raised.
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1477007607
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +997,11 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ auto maybe_repr = Cast(CastToExplicitScalar(), utf8());
Review Comment:
By referencing your comment, I fixed it.
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +997,11 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ auto maybe_repr = Cast(CastToExplicitScalar(), utf8());
Review Comment:
@kou Hello, It's not complete yet, but do you have any better ideas about this part?
Additionally, the issues related to the failure of this workflow include the following items, and all seem to be associated with `ToString`:
- Replace from the legacy `CastTo` to the new `Cast` within `ToString`
- Improve some output formats (for `List`) for `ToString`
```
Value of: scalar.ToString()
Expected: (has substring "item: int16") and (ends with "[1, 2, null]")
Actual: "[\n [\n 1,\n 2,\n null\n ]\n]"
```
- Fix the GLib test cases related to this
Would it be better to handle these in a single PR?
Thank you as always.
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
Review Comment:
I am currently facing a dilemma regarding the output formatting. It has become challenging to handle it in the same manner as before.
Here are the approaches I'm considering:
1. proceed with the current output format in `ToString`, then create an issue to add a feature similar to `pretty_print.cc`. However, I'm concerned about the impact on languages that are binding to the C++ code.
2. make `ToString` more extensible. How should we go about this?
I would greatly appreciate any guidance or advice on how to proceed.
cc @kou @bkietz
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
+ }
+
+ if (type->id() == Type::RUN_END_ENCODED) {
+ auto ree_scalar = checked_cast<const RunEndEncodedScalar*>(this);
+ return ree_scalar->value->ToString();
Review Comment:
same as `list`
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "kou (via GitHub)" <gi...@apache.org>.
kou commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1479125755
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
Review Comment:
Can we use `arrow::PrettyPrint()` directly here? We can customize pretty print behavior by `arrow::PrettyPrintOptions`.
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on code in PR #39192:
URL: https://github.com/apache/arrow/pull/39192#discussion_r1477194281
##########
cpp/src/arrow/scalar.cc:
##########
@@ -884,9 +885,24 @@ std::string Scalar::ToString() const {
return dict_scalar->value.dictionary->ToString() + "[" +
dict_scalar->value.index->ToString() + "]";
}
- auto maybe_repr = CastTo(utf8());
+
+ if (type->id() == Type::LIST || type->id() == Type::LARGE_LIST ||
+ type->id() == Type::LIST_VIEW || type->id() == Type::LARGE_LIST_VIEW ||
+ type->id() == Type::FIXED_SIZE_LIST) {
+ auto list_scalar = checked_cast<const BaseListScalar*>(this);
+ return list_scalar->value->ToString();
Review Comment:
Yes, more time has passed since we created this PR than we initially thought.
The purpose of this PR is to completely remove the `CastTo` function.
Initially, `CastTo` was being used in the Scalar's `ToString` function, and I have added code to replace it with `Cast`.
This change necessitates addressing the following issues:
- `ToString` now outputs a format different from the original, causing unit tests to fail (for example, `BaseListScalar` and `RunEndEncodedScalar`).
- https://github.com/apache/arrow/actions/runs/7765982125/job/21181284567?pr=39192
- Relatedly, tests in `glib` also fail.
- https://github.com/apache/arrow/actions/runs/7765982121/job/21181284546?pr=39192
- Errors occur due to legacy `CastTo` being bound in Cython.
- https://github.com/apache/arrow/actions/runs/7765982118/job/21181283847?pr=39192
--
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-39182: [C++] Remove Legacy CastTo function [arrow]
Posted by "llama90 (via GitHub)" <gi...@apache.org>.
llama90 commented on PR #39192:
URL: https://github.com/apache/arrow/pull/39192#issuecomment-3592895559
Hello, I don't have enough time to work on this issue/PR at the moment.
So I will close this PR. If anyone is interested, please feel free to continue the work.
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