zeroshade commented on a change in pull request #10071:
URL: https://github.com/apache/arrow/pull/10071#discussion_r619903362



##########
File path: go/parquet/schema/logical_types.go
##########
@@ -0,0 +1,1089 @@
+// 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 schema
+
+import (
+       "encoding/json"
+       "fmt"
+       "math"
+
+       "github.com/apache/arrow/go/parquet"
+       "github.com/apache/arrow/go/parquet/internal/debug"
+       format "github.com/apache/arrow/go/parquet/internal/gen-go/parquet"
+)
+
+// DecimalMetadata is a struct for managing scale and precision information 
between
+// converted and logical types.
+type DecimalMetadata struct {
+       IsSet     bool
+       Scale     int32
+       Precision int32
+}
+
+func getLogicalType(l *format.LogicalType) LogicalType {
+       switch {
+       case l.IsSetSTRING():
+               return StringLogicalType{}
+       case l.IsSetMAP():
+               return MapLogicalType{}
+       case l.IsSetLIST():
+               return ListLogicalType{}
+       case l.IsSetENUM():
+               return EnumLogicalType{}
+       case l.IsSetDECIMAL():
+               return &DecimalLogicalType{typ: l.DECIMAL}
+       case l.IsSetDATE():
+               return DateLogicalType{}
+       case l.IsSetTIME():
+               if timeUnitFromThrift(l.TIME.Unit) == TimeUnitUnknown {
+                       panic("parquet: TimeUnit must be one of MILLIS, MICROS, 
or NANOS for Time logical type")
+               }
+               return &TimeLogicalType{typ: l.TIME}
+       case l.IsSetTIMESTAMP():
+               if timeUnitFromThrift(l.TIMESTAMP.Unit) == TimeUnitUnknown {
+                       panic("parquet: TimeUnit must be one of MILLIS, MICROS, 
or NANOS for Timestamp logical type")
+               }
+               return &TimestampLogicalType{typ: l.TIMESTAMP}
+       case l.IsSetINTEGER():
+               return &IntLogicalType{typ: l.INTEGER}
+       case l.IsSetUNKNOWN():
+               return NullLogicalType{}
+       case l.IsSetJSON():
+               return JSONLogicalType{}
+       case l.IsSetBSON():
+               return BSONLogicalType{}
+       case l.IsSetUUID():
+               return UUIDLogicalType{}
+       case l == nil:
+               return NoLogicalType{}
+       default:
+               panic("invalid logical type")
+       }
+}
+
+// TimeUnitType is an enum for denoting whether a time based logical type
+// is using milliseconds, microseconds or nanoseconds.
+type TimeUnitType int
+
+// Constants for the TimeUnitType
+const (
+       TimeUnitMillis TimeUnitType = iota
+       TimeUnitMicros
+       TimeUnitNanos
+       TimeUnitUnknown
+)
+
+// LogicalType is the descriptor that defines the usage of a physical primitive
+// type in the schema, such as an Interval, Date, etc.
+type LogicalType interface {
+       // Returns true if a nested type like List or Map
+       IsNested() bool
+       // Returns true if this type can be serialized, ie: not 
Unknown/NoType/Interval

Review comment:
       
https://github.com/apache/arrow/blob/master/cpp/src/parquet/parquet.thrift#L340
   
   The current parquet.thrift file has the logical type for INTERVAL commented 
out so the generated code doesn't contain a LogicalType for Interval and thus 
it's unable to be serialized. This also comes from the C++ implementation too 
https://github.com/apache/arrow/blob/master/cpp/src/parquet/schema.cc#L520




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

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


Reply via email to