Ah - the Result<T> is for error handling. So either:

1) Return arrow::Status from this function, and use the ARROW_ASSIGN_OR_RAISE 
macro:

ARROW_ASSIGN_OR_RAISE(auto scalar, arrow::MakeScalar(...));
..., cp::literal(std::move(scalar)) ...

2) For experimentation purposes, just assume it'll succeed:

..., cp::literal(*arrow::MakeScalar(...)) ...

3) Directly construct the right scalar 
(https://github.com/apache/arrow/blob/master/cpp/src/arrow/scalar.h#L340):

..., cp::literal(std::make_shared<arrow::Time64Scalar>(time, TimeUnit::NANO)) 
...

-David

On Mon, Feb 7, 2022, at 12:23, Li Jin wrote:
> So I think I am getting close... now I have
>
>   cp::Expression predicate = cp::call(
>                                       "equal",
>                                        {...}
>
>  cp::literal(arrow::MakeScalar(arrow::time64(arrow::TimeUnit::NANO), time))}
>                                       );
>
> And got
>
> /usr/include/arrow/compute/exec/expression.h:143:18: error: no matching
> conversion for functional-style cast from
>       'arrow::Result<std::shared_ptr<arrow::Scalar>>' to 'arrow::Datum'
>   return literal(Datum(std::forward<Arg>(arg)));
>                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/icexelloss/workspace/bamboo-streaming/examples/msw_filter_time.cc:66:44:
> note: in instantiation of function template
>       specialization
> 'arrow::compute::literal<arrow::Result<std::shared_ptr<arrow::Scalar>>>'
> requested here
>
>  cp::literal(arrow::MakeScalar(arrow::time64(arrow::TimeUnit::NANO), time))}
>
> Any help / pointers are much appreciated!
>
> On Mon, Feb 7, 2022 at 12:13 PM Li Jin <ice.xell...@gmail.com> wrote:
>
>> Another question - what is the correct way of creating a constant Scalar
>> that represents a time64 from a string in C++ (e.g. "10:00:00") ?
>>
>> I am trying to use cp::literal(arrow::MakeScalar(...)) but not sure what
>> to fill in the body of MakeScalar
>>
>> On Mon, Feb 7, 2022 at 12:05 PM Li Jin <ice.xell...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Did some more work on this. Follow up question on this:
>>>
>>> I am doing a
>>>
>>>                                                 {cp::call("cast",
>>>
>>> {cp::field_ref("time_ns")},
>>>
>>> cp::CastOptions::Safe(arrow::timestamp(arrow::TimeUnit::NANO, timezone)))},
>>>
>>> And got:
>>>
>>> NotImplemented: Unsupported cast from uint64 to timestamp using function
>>> cast_timestamp
>>>
>>> Is this the wrong way to convert uint64 to timestamp or is it just not
>>> supported right now?
>>>
>>> On Thu, Feb 3, 2022 at 12:29 PM Rok Mihevc <rok.mih...@gmail.com> wrote:
>>>
>>>> By the way - if you're extracting components to segment time you might
>>>> prefer temporal rounding
>>>>
>>>> https://arrow.apache.org/docs/dev/cpp/compute.html?highlight=floor_temporal#conversions
>>>> .
>>>>
>>>> On Thu, Feb 3, 2022 at 5:19 PM Li Jin <ice.xell...@gmail.com> wrote:
>>>> >
>>>> > Gotcha. Thanks for the pointer!
>>>> >
>>>> > On Thu, Feb 3, 2022 at 11:06 AM Rok Mihevc <rok.mih...@gmail.com>
>>>> wrote:
>>>> >
>>>> > > > Gotcha. "Assume timezone" is like "tz_localize" in pandas.
>>>> > >
>>>> > > Indeed!
>>>> > >
>>>> > > > I didn't see any target timezone information being passed in the
>>>> "cast"
>>>> > > > function - how would I do that?
>>>> > >
>>>> > > Just cast with:
>>>> > > auto options = CastOptions::Safe(timestamp(TimeUnit::NANO,
>>>> > > "America/New_York"));
>>>> > > See examples in:
>>>> > >
>>>> > >
>>>> https://github.com/apache/arrow/blob/master/cpp/src/arrow/compute/kernels/scalar_cast_test.cc
>>>> > >
>>>>
>>>

Reply via email to