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/07/28 10:08:11 UTC

[GitHub] [arrow] SG011 commented on a diff in pull request #13656: ARROW-17144: [C++][Gandiva] Add sqrt function

SG011 commented on code in PR #13656:
URL: https://github.com/apache/arrow/pull/13656#discussion_r932030590


##########
cpp/src/gandiva/tests/projector_test.cc:
##########
@@ -3384,4 +3384,111 @@ TEST_F(TestProjector, TestMaskDefault) {
   EXPECT_ARROW_ARRAY_EQUALS(exp_mask, outputs.at(0));
 }
 
+TEST_F(TestProjector, TestSqrt) {
+  // input fields
+  auto field1 = field("f1", arrow::int32());
+  auto field2 = field("f2", arrow::int64());
+  auto field3 = field("f3", arrow::float32());
+  auto field4 = field("f4", arrow::float64());
+
+  // schema fields
+  auto schema1 = arrow::schema({field1});
+  auto schema2 = arrow::schema({field2});
+  auto schema3 = arrow::schema({field3});
+  auto schema4 = arrow::schema({field4});
+
+  // output fields
+  auto field5 = field("sqrt_int32", arrow::float64());
+  auto field6 = field("sqrt_int64", arrow::float64());
+  auto field7 = field("sqrt_float32", arrow::float64());
+  auto field8 = field("sqrt_float64", arrow::float64());
+
+  // Build expression
+  auto sqrt_int32 = TreeExprBuilder::MakeExpression("sqrt", {field1}, field5);
+  auto sqrt_int64 = TreeExprBuilder::MakeExpression("sqrt", {field2}, field6);
+  auto sqrt_float32 = TreeExprBuilder::MakeExpression("sqrt", {field3}, field7);
+  auto sqrt_float64 = TreeExprBuilder::MakeExpression("sqrt", {field4}, field8);
+
+  std::shared_ptr<Projector> projector1;
+
+  auto status = Projector::Make(schema1, {sqrt_int32}, TestConfiguration(), &projector1);
+  EXPECT_TRUE(status.ok()) << status.message();

Review Comment:
   Also we have done the same in another functions also.



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