gene-db commented on code in PR #48779: URL: https://github.com/apache/spark/pull/48779#discussion_r1838663578
########## common/variant/src/main/java/org/apache/spark/types/variant/VariantSchema.java: ########## @@ -0,0 +1,153 @@ +/* + * 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.spark.types.variant; + +import java.util.HashMap; +import java.util.Map; + +/** + * Defines a valid shredding schema, as described in + * https://github.com/apache/parquet-format/blob/master/VariantShredding.md. + * A shredding schema contains a value and optional typed_value field. + * If a typed_value is an array or struct, it recursively contain its own shredding schema for + * elements and fields, respectively. + * The schema also contains a metadata field at the top level, but not in recursively shredded + * fields. + */ +public class VariantSchema { + + // Represents one field of an object in the shredding schema. + public static final class ObjectField { + public final String fieldName; + public final VariantSchema schema; + + public ObjectField(String fieldName, VariantSchema schema) { + this.fieldName = fieldName; + this.schema = schema; + } + + @Override + public String toString() { + return "ObjectField{" + + "fieldName=" + fieldName + + ", schema=" + schema + + '}'; + } + } + + public abstract static class ScalarType { + } + + public static final class StringType extends ScalarType { + } + + public enum IntegralSize { + BYTE, SHORT, INT, LONG + } + + public static final class IntegralType extends ScalarType { + public final IntegralSize size; + + public IntegralType(IntegralSize size) { + this.size = size; + } + } + + public static final class FloatType extends ScalarType { + } + + public static final class DoubleType extends ScalarType { + } + + public static final class BooleanType extends ScalarType { + } + + public static final class BinaryType extends ScalarType { + } + + public static final class DecimalType extends ScalarType { + public final int precision; + public final int scale; + + public DecimalType(int precision, int scale) { + this.precision = precision; + this.scale = scale; + } + } + + public static final class DateType extends ScalarType { + } + + public static final class TimestampType extends ScalarType { + } + + public static final class TimestampNTZType extends ScalarType { + } + + // The index of the typed_value, value, and metadata fields in the schema, respectively. I given Review Comment: ```suggestion // The index of the typed_value, value, and metadata fields in the schema, respectively. If given ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
