vvellanki commented on a change in pull request #9750:
URL: https://github.com/apache/arrow/pull/9750#discussion_r741913957



##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -307,6 +310,21 @@ CAST_NUMERIC_FROM_STRING(double, arrow::DoubleType, FLOAT8)
 
 #undef CAST_NUMERIC_FROM_STRING
 
+#define GDV_FN_TO_CHAR(IN_TYPE, ARROW_TYPE, TYPE_NAME)                         
        \
+  GANDIVA_EXPORT                                                               
        \
+  const char* gdv_fn_to_char_##TYPE_NAME##_utf8(                               
        \
+      int64_t context, gdv_##IN_TYPE data, const char* format, int32_t 
format_len) {   \
+    gandiva::ToCharHolder* holder = 
reinterpret_cast<gandiva::ToCharHolder*>(context); \
+    return holder->Format<gdv_##IN_TYPE>(data);                                
        \
+  }
+
+GDV_FN_TO_CHAR(int32, arrow::Int32Type, INT)
+GDV_FN_TO_CHAR(int64, arrow::Int64Type, BIGINT)
+GDV_FN_TO_CHAR(float32, arrow::FloatType, FLOAT4)
+GDV_FN_TO_CHAR(float64, arrow::DoubleType, FLOAT8)
+
+#undef CAST_NUMERIC_FROM_STRING

Review comment:
       Shouldn't this be #undef GDV_FN_TO_CHAR?

##########
File path: cpp/src/gandiva/to_char_holder.h
##########
@@ -0,0 +1,79 @@
+// 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/status.h"
+
+#include "gandiva/execution_context.h"
+#include "gandiva/function_holder.h"
+#include "gandiva/node.h"
+#include "gandiva/visibility.h"
+
+namespace gandiva {
+/// Function Holder for SQL 'to_char'
+
+class GANDIVA_EXPORT ToCharHolder : public FunctionHolder {
+ public:
+  ~ToCharHolder() override = default;
+
+  static Status Make(const FunctionNode& node, std::shared_ptr<ToCharHolder>* 
holder);
+
+  static Status Make(const std::string& java_pattern,
+                     std::shared_ptr<ToCharHolder>* holder);
+
+  template <typename T>
+  const char* Format(T number) {
+    return "";
+  }
+
+ private:
+  explicit ToCharHolder(const char* pattern, int32_t pattern_size)
+      : pattern_(pattern), pattern_size_(pattern_size) {
+    maximumFractionDigits_ = Setup();
+  }
+
+  // Sets the format's metadata, such as the maximum number of decimal digits 
and if
+  // the patterns contains a dollar sign.
+  int32_t Setup() {
+    int32_t ret = 0;
+    bool is_decimal_part = false;
+    has_dollar_sign_ = false;
+    for (size_t i = 0; i < pattern_size_; ++i) {
+      if (pattern_[i] == '$') {
+        has_dollar_sign_ = true;

Review comment:
       Add continue here




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


Reply via email to