westonpace commented on code in PR #14659: URL: https://github.com/apache/arrow/pull/14659#discussion_r1025898821
########## cpp/src/arrow/util/literal_operators.h: ########## @@ -0,0 +1,56 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "arrow/scalar.h" +#include "arrow/type_fwd.h" +#include "arrow/util/checked_cast.h" +#include "arrow/util/value_parsing.h" + +namespace arrow { +namespace util { +namespace arrow_literals { + +inline TimestampScalar TimestampScalarFromString(const char* s, size_t length, + TimeUnit::type unit) { + TimestampScalar out{timestamp(unit)}; + out.is_valid = ::arrow::internal::ParseValue( + ::arrow::internal::checked_cast<const TimestampType&>(*out.type), s, length, + &out.value); Review Comment: I know I encouraged it but maybe let's drop the timestamp literals in favor of simple helper functions: ``` ARROW_ASSIGN_OR_RAISE(Datum christmas, ParseTimestampISO8601("2022-12-25T00:00:00+00:00")); ``` is probably compact enough. Then we can keep the duration literals since it looks like you're using the standard `chrono` ones and they should be pretty familiar to people (and we don't have to worry about invalid cases). -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
