JingsongLi commented on code in PR #2473:
URL: https://github.com/apache/incubator-paimon/pull/2473#discussion_r1435986933


##########
paimon-common/src/main/java/org/apache/paimon/utils/StringFormatter.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.utils;
+
+import org.apache.paimon.types.DataType;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+import java.util.function.Function;
+
+/**
+ * Formatter to format a data to string.
+ *
+ * @param <T> The type of the data to format.
+ */
+public interface StringFormatter<T> {
+    String format(T t);
+
+    /**
+     * Create a StringFormatter from a data type and a data generator.
+     *
+     * @param dataType The data type of the dataGenerator result.
+     * @param dataGenerator The data generator to generate the data to format.
+     * @param <T> The type of the data to format.
+     */
+    static <T> StringFormatter<T> createStringFormat(
+            DataType dataType, Function<T, Object> dataGenerator) {
+        switch (dataType.getTypeRoot()) {
+            case BINARY:
+            case VARBINARY:
+                return row -> {
+                    byte[] bytes = (byte[]) dataGenerator.apply(row);
+                    if (bytes == null) {
+                        return null;
+                    }
+                    return StandardCharsets.ISO_8859_1

Review Comment:
   I'm not sure if this is the standard to string method, is your PR from a 
real business? Can we simply prohibit partition fields from being bytes type in 
the SchemeValidation?



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