Class FieldAccessDescriptor

  • All Implemented Interfaces:
    java.io.Serializable

    @Experimental(SCHEMAS)
    public abstract class FieldAccessDescriptor
    extends java.lang.Object
    implements java.io.Serializable
    Used inside of a DoFn to describe which fields in a schema type need to be accessed for processing.

    This class always puts the selected fields in a deterministic order.

    See Also:
    Serialized Form
    • Constructor Detail

      • FieldAccessDescriptor

        public FieldAccessDescriptor()
    • Method Detail

      • getAllFields

        public abstract boolean getAllFields()
        If true, all fields are being accessed.
      • withFieldNames

        public static FieldAccessDescriptor withFieldNames​(java.lang.String... names)
        Return a descriptor that access the specified fields.

        By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. The syntax for a field name allows specifying nested fields and wildcards, as specified in the file-level Javadoc. withNestedField can also be called to specify recursive field access.

      • withFieldNames

        public static FieldAccessDescriptor withFieldNames​(java.lang.Iterable<java.lang.String> fieldNames)
        Return a descriptor that access the specified fields.

        By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. The syntax for a field name allows specifying nested fields and wildcards, as specified in the file-level Javadoc. withNestedField can also be called to specify recursive field access.

      • withFieldNamesAs

        public static FieldAccessDescriptor withFieldNamesAs​(java.util.Map<java.lang.String,​java.lang.String> fieldNamesAs)
        Return a descriptor that accesses the specified fields, renaming those fields.
      • withFieldNames

        public static FieldAccessDescriptor withFieldNames​(FieldAccessDescriptor baseDescriptor,
                                                           java.lang.String... fieldNames)
        Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.

        This is only supported when baseDescriptor refers to a single field.

      • withFieldNames

        public static FieldAccessDescriptor withFieldNames​(FieldAccessDescriptor baseDescriptor,
                                                           java.lang.Iterable<java.lang.String> fieldNames)
        Return a descriptor that accesses the specified field names as nested subfields of the baseDescriptor.

        This is only supported when baseDescriptor refers to a single field.

      • withFieldIds

        public static FieldAccessDescriptor withFieldIds​(FieldAccessDescriptor baseDescriptor,
                                                         java.lang.Integer... fieldIds)
        Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.

        This is only supported when baseDescriptor refers to a single field.

      • withFieldIds

        public static FieldAccessDescriptor withFieldIds​(FieldAccessDescriptor baseDescriptor,
                                                         java.lang.Iterable<java.lang.Integer> fieldIds)
        Return a descriptor that accesses the specified field ids as nested subfields of the baseDescriptor.

        This is only supported when baseDescriptor refers to a single field.

      • withFieldIds

        public static FieldAccessDescriptor withFieldIds​(java.lang.Integer... ids)
        Return a descriptor that access the specified fields.

        By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. For finer-grained acccess to nested rows, call withNestedField and pass in a recursive FieldAccessDescriptor.

      • withFieldIds

        public static FieldAccessDescriptor withFieldIds​(java.lang.Iterable<java.lang.Integer> ids)
        Return a descriptor that access the specified fields.

        By default, if the field is a nested row (or a container containing a row), all fields of said rows are accessed. For finer-grained acccess to nested rows, call withNestedField and pass in a recursive FieldAccessDescriptor.

      • withFieldNameAs

        public FieldAccessDescriptor withFieldNameAs​(java.lang.String fieldName,
                                                     java.lang.String fieldRename)
        Add a field with a new name. This is only valid if the fieldName references a single field (wildcards are not allowed here).
      • withNestedField

        public FieldAccessDescriptor withNestedField​(int nestedFieldId,
                                                     FieldAccessDescriptor fieldAccess)
        Return a descriptor that access the specified nested field. The nested field must be of type Schema.TypeName.ROW, and the fieldAccess argument specifies what fields of the nested type will be accessed.
      • withNestedField

        public FieldAccessDescriptor withNestedField​(java.lang.String nestedFieldName,
                                                     FieldAccessDescriptor fieldAccess)
        Return a descriptor that access the specified nested field. The nested field must be of type Schema.TypeName.ROW, and the fieldAccess argument specifies what fields of the nested type will be accessed.
      • referencesSingleField

        public boolean referencesSingleField()
        Returns true if this descriptor references only a single, non-wildcard field.
      • resolve

        public FieldAccessDescriptor resolve​(Schema schema)
        Resolve the FieldAccessDescriptor against a schema.

        Resolve will resolve all of the field names into field ids, validating that all field names specified in the descriptor exist in the actual schema.

      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object