TheNeuralBit commented on a change in pull request #15733:
URL: https://github.com/apache/beam/pull/15733#discussion_r739572667



##########
File path: 
sdks/java/extensions/sbe/src/main/java/org/apache/beam/sdk/extensions/sbe/TimeValues.java
##########
@@ -0,0 +1,460 @@
+/*
+ * 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.beam.sdk.extensions.sbe;
+
+import static org.apache.beam.sdk.extensions.sbe.Schemas.TZ_TIME_SCHEMA;
+import static 
org.apache.beam.sdk.extensions.sbe.Schemas.TimeFieldNames.TIME_FIELD_NAME;
+import static 
org.apache.beam.sdk.extensions.sbe.Schemas.TimeFieldNames.TIME_ZONE_HOUR_FIELD_NAME;
+import static 
org.apache.beam.sdk.extensions.sbe.Schemas.TimeFieldNames.TIME_ZONE_MINUTE_FIELD_NAME;
+import static 
org.apache.beam.sdk.extensions.sbe.Schemas.TimeFieldNames.UNIT_FIELD_NAME;
+import static org.apache.beam.sdk.extensions.sbe.Schemas.UTC_TIME_SCHEMA;
+import static 
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument;
+
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
+import java.util.Objects;
+import java.util.concurrent.TimeUnit;
+import org.apache.beam.sdk.values.Row;
+import org.checkerframework.checker.initialization.qual.Initialized;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
+/**
+ * Representations of SBE value types.
+ *
+ * <p>These are convertible to/from a {@link Row} that is a direct mapping of 
an SBE composite type.
+ */
+public final class TimeValues {

Review comment:
       So I have two main concerns with this approach:
   1. I really don't want to get in the business of maintaining a date/time 
library :)
   1. It would be preferable to have a library of common types that most 
connectors are using, so that it's trivial to interop with the schemas that 
they produce.
   
   We could maybe alleviate (1) by discouraging users from using these types 
directly, instead preferring to convert to java time or joda time if they need 
to.
   
   Note we can encode more information in the schema logical type than is 
represented in the Java type that it maps to. So another approach to be able to 
represent the mixed vs. fixed precision case could be to have a family of 
logical types that all map to `Instant`, but that have different representation 
types (i.e. wire types):
   - micros_instant
   - millis_instant
   - seconds_instant
   - variable_unit_instant (or something)
   
   In the variable unit case the representation type could be `row<int64 
timestamp, int64 unit>`. The drawback with this approach would be that the user 
can't interrogate the precision of the instant in their Java code, but I'm not 
so sure that's a significant problem.




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