projjal commented on a change in pull request #11054:
URL: https://github.com/apache/arrow/pull/11054#discussion_r702907009



##########
File path: cpp/src/gandiva/precompiled/string_ops_test.cc
##########
@@ -53,6 +53,37 @@ TEST(TestStringOps, TestAscii) {
   EXPECT_EQ(ascii_utf8("999", 3), 57);
 }
 
+TEST(TestStringOps, TestChr) {
+  // CHR
+  gandiva::ExecutionContext ctx;
+  uint64_t ctx_ptr = reinterpret_cast<gdv_int64>(&ctx);
+  int32_t out_len = 0;
+
+  auto out = chr_int32(ctx_ptr, 88, &out_len);

Review comment:
       Also add unit tests for punctuations, non printable control codes, 
non-ascii number (>127)

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1361,6 +1361,26 @@ gdv_int32 ascii_utf8(const char* data, gdv_int32 
data_len) {
   return static_cast<gdv_int32>(data[0]);
 }
 
+// Returns the ASCII character having the binary equivalent to A.
+// If A is larger than 256 the result is equivalent to chr(A % 256).
+GANDIVA_EXPORT
+const char* chr_int32(gdv_int64 context, gdv_int32 in, gdv_int32* out_len) {
+  in = in > 255 ? in % 256 : in;

Review comment:
       keep it as in = in % 256;
   i checked hive chr also prints for negative numbers




-- 
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-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to