rdblue commented on code in PR #12311:
URL: https://github.com/apache/iceberg/pull/12311#discussion_r1970492212


##########
api/src/main/java/org/apache/iceberg/variants/VariantUtil.java:
##########
@@ -18,21 +18,112 @@
  */
 package org.apache.iceberg.variants;
 
+import java.math.BigDecimal;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
 import java.nio.charset.StandardCharsets;
+import java.util.Map;
 import java.util.function.Function;
 import org.apache.iceberg.relocated.com.google.common.base.Preconditions;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.types.Type;
+import org.apache.iceberg.types.Types;
 
-class VariantUtil {
+public class VariantUtil {
   private static final int BASIC_TYPE_MASK = 0b11;
   private static final int BASIC_TYPE_PRIMITIVE = 0;
   private static final int BASIC_TYPE_SHORT_STRING = 1;
   private static final int BASIC_TYPE_OBJECT = 2;
   private static final int BASIC_TYPE_ARRAY = 3;
 
+  // TODO: Implement PhysicalType.TIME
+  // TODO: Implement PhysicalType.TIMESTAMPNTZ_NANO and 
PhysicalType.TIMESTAMPTZ_NANO
+  // TODO: Implement PhysicalType.UUID
+  private static final Map<Type, PhysicalType> NO_CONVERSION_NEEDED =
+      ImmutableMap.<Type, PhysicalType>builder()
+          .put(Types.IntegerType.get(), PhysicalType.INT32)
+          .put(Types.LongType.get(), PhysicalType.INT64)
+          .put(Types.FloatType.get(), PhysicalType.FLOAT)
+          .put(Types.DoubleType.get(), PhysicalType.DOUBLE)
+          .put(Types.DateType.get(), PhysicalType.DATE)
+          .put(Types.TimestampType.withoutZone(), PhysicalType.TIMESTAMPNTZ)
+          .put(Types.TimestampType.withZone(), PhysicalType.TIMESTAMPTZ)
+          .put(Types.StringType.get(), PhysicalType.STRING)
+          .put(Types.BinaryType.get(), PhysicalType.BINARY)
+          .put(Types.UnknownType.get(), PhysicalType.NULL)
+          .build();
+
   private VariantUtil() {}
 
+  @SuppressWarnings("unchecked")
+  public static <T> T castTo(VariantValue value, Type type) {

Review Comment:
   I moved this so that it is now package-private within expressions.



-- 
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: issues-unsubscr...@iceberg.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to