You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/08 02:14:26 UTC

[GitHub] [arrow] ZMZ91 commented on a diff in pull request #14073: ARROW-17658: [C++][Gandiva] Support int64 seed for udf random.

ZMZ91 commented on code in PR #14073:
URL: https://github.com/apache/arrow/pull/14073#discussion_r990574046


##########
cpp/src/gandiva/random_generator_holder.cc:
##########
@@ -35,11 +35,14 @@ Status RandomGeneratorHolder::Make(const FunctionNode& node,
 
   auto literal_type = literal->return_type()->id();
   ARROW_RETURN_IF(
-      literal_type != arrow::Type::INT32,
-      Status::Invalid("'random' function requires an int32 literal as parameter"));
+      literal_type != arrow::Type::INT32 && literal_type != arrow::Type::INT64,
+      Status::Invalid("'random' function requires an int32/int64 literal as parameter"));
 
-  *holder = std::shared_ptr<RandomGeneratorHolder>(new RandomGeneratorHolder(
-      literal->is_null() ? 0 : arrow::util::get<int32_t>(literal->holder())));
+  auto seed = literal_type == arrow::Type::INT32
+                  ? static_cast<int64_t>(arrow::util::get<int32_t>(literal->holder()))
+                  : arrow::util::get<int64_t>(literal->holder());
+  *holder = std::shared_ptr<RandomGeneratorHolder>(

Review Comment:
   Seems make_shared is not doable since the constructor is private and this is in a static method.



-- 
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