parquet_schema Derived Type

type, public :: parquet_schema

Bundles a parsed MAML source together with the column schema (cinfo) and table metadata (metadata) that parquet_parse_maml derives from it, so a single variable carries everything parquet_open_writer needs. %cinfo and %metadata are public: their fields (col(:), items(:)) and own type-bound procedures stay directly reachable, and the procedures below are flat convenience passthroughs (schema%set_column_available("id") instead of schema%cinfo%set_column_available("id")).

On the read side a qc-maml is populated into %maml alone -- either by parquet_load_qc_maml_file or schema%add_col_qc -- and is never run through parquet_parse_maml (a qc-maml has no data_type and would fail the full schema validation), so %cinfo/%metadata stay empty; parquet_open_reader consumes only %maml.


Components

Type Visibility Attributes Name Initial
type(parquet_maml_file), public :: maml

Raw MAML source plus (once parsed) missing-columns/col_map.

type(parquet_column_info), public :: cinfo

Per-field schema/QC state, derived from %maml by parquet_parse_maml.

type(parquet_table_metadata), public :: metadata

Flat key-value table metadata, derived from %maml's keyarray:.


Constructor

public interface parquet_schema

Overrides the default structure constructor so a schema can be built in one expression (my_maml = parquet_schema(table="my_table")) as an alternative to call my_maml%init(table="my_table"); both call parquet_schema_new/schema_init under the hood. table is the only required argument (the MAML table: key); survey, dataset, version, date, author, description, license, and maml_version are all optional and set the correspondingly-named MAML header key when given. Returns the newly initialized schema.

  • private interface parquet_schema_new()

    Arguments

    None

Type-Bound Procedures

procedure, public :: init => schema_init

Initializes a from-scratch schema (table: key + optional metadata).

  • interface

    private module subroutine schema_init(this, table, survey, dataset, version, date, author, description, license, maml_version, force)

    Initializes a from-scratch parquet_schema: sets the (required) table: key and any of the optional scalar top-level MAML keys given, and marks this schema ready for %add_field. Error stops if this schema is already initialized (this%is_init() == .true., whether from an earlier %init call or a MAML parse -- e.g. calling %init on a schema already loaded via parquet_parse_maml), unless force=.true. is given (see below). List-shaped top-level sections (coauthors:, comments:, keywords:, DOIs:, depends:, keyarray:, extra:) are out of scope here -- keyarray: already has its own API (add_metadata); the others aren't supported by %init/%add_field at all yet.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema being initialized (must not already be initialized, unless force=.true.).

    character(len=*), intent(in) :: table

    required table: key.

    character(len=*), intent(in), optional :: survey

    optional survey: key.

    character(len=*), intent(in), optional :: dataset

    optional dataset: key.

    character(len=*), intent(in), optional :: version

    optional version: key.

    character(len=*), intent(in), optional :: date

    optional date: key.

    character(len=*), intent(in), optional :: author

    optional author: key.

    character(len=*), intent(in), optional :: description

    optional description: key.

    character(len=*), intent(in), optional :: license

    optional license: key.

    character(len=*), intent(in), optional :: maml_version

    optional MAML_version: key.

    logical, intent(in), optional :: force

    if .true., bypass the "already initialized" error stop and fully reset this schema (discarding any fields/qc/metadata already added, and %cinfo/%metadata if %parquet_parse_maml had already run) before re-initializing, as if %init were being called for the first time (default .false.).

procedure, public :: is_init => schema_is_init

Whether this schema is ready to use (via %init or a MAML parse).

  • interface

    private module function schema_is_init(this)

    Whether this schema is ready to use -- .true. once either %init/parquet_schema(...) has completed (the in-code builder path) or parquet_parse_maml has populated %cinfo (a schema loaded from a .maml file/object, which never calls %init at all); .false. only for a just-declared parquet_schema that has had neither happen yet. Note %add_field's own "call schema%init(...) before adding fields" guard checks %init having been called specifically, not this broader readiness -- %add_field only makes sense on a from-scratch schema, so it is not satisfied merely by is_init() being .true. via a MAML parse.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    Return Value logical

procedure, public :: is_parsed => schema_is_parsed

Whether %cinfo has actually been populated by parquet_parse_maml.

  • interface

    private module function schema_is_parsed(this)

    Whether %cinfo has actually been populated by parquet_parse_maml -- .true. only once a parse has run (from a .maml file/object, or via %init/%add_field followed by parquet_parse_maml on the same schema), .false. otherwise, including for a from-scratch schema that has only had %init/%add_field called and never been parsed. This is the readiness check %print_schema_info itself requires (it error stops if %cinfo is unpopulated, unless allow_uninitialized=.true. is given) -- %is_init() is not equivalent here, since %is_init() is already .true. after %init alone, before any parse. Since %is_parsed() == .true. implies %cinfo%col is allocated, which itself already implies %is_init() == .true., %is_parsed() is always .false. whenever %is_init() is .false.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    Return Value logical

procedure, public :: clear => schema_clear

Resets the entire schema back to its pristine, just-declared (never-initialized) state.

  • interface

    private module subroutine schema_clear(this)

    Resets this schema to exactly the state a freshly declared, never-initialized parquet_schema starts in: %maml/%cinfo/%metadata all back to their defaults (no lines, no fields, no metadata items) and is_init() == .false. again. Unlike %init(..., force=.true.) (which resets and immediately rebuilds with new header-key arguments), %clear leaves the schema uninitialized -- call %init again afterward to reuse the variable, or let it go out of scope. Always succeeds, even on an already-blank schema (a no-op in that case).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema being reset to its pristine state.

procedure, public :: add_field => schema_add_field

Appends one fields: entry to a from-scratch schema.

  • interface

    private module subroutine schema_add_field(this, name, data_type, unit, info, ucd, array_size, col_size, qc_min, qc_max, qc_miss)

    Appends one fields: entry to a schema built from scratch (%init must be called first). name/data_type are required (data_type must be one of the supported types); unit/info/ucd/array_size/ col_size and qc_min/qc_max/qc_miss are optional, the latter three forming an optional qc: sub-block (same min:/max: operator-direction and miss: Null/NA rules %add_col_qc enforces, checked independently here -- %add_field is a distinct API from %add_col_qc, not built on top of it: %add_col_qc is for read-time qc-mamls (name + qc: only, no data_type) and explicitly rejects a column already declared as a field, so it cannot be layered onto a field %add_field just added). Validates eagerly (name/data_type/duplicate/qc all checked here, not deferred to parquet_validate_maml).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema being built (%init must have been called first).

    character(len=*), intent(in) :: name

    field name.

    character(len=*), intent(in) :: data_type

    field's data type (must be one of the supported types).

    character(len=*), intent(in), optional :: unit

    unit of measurement.

    character(len=*), intent(in), optional :: info

    short description.

    character(len=*), intent(in), optional :: ucd

    IVOA Unified Content Descriptor.

    integer, intent(in), optional :: array_size

    maximum string length (string fields only).

    integer, intent(in), optional :: col_size

    vector-column element count.

    character(len=*), intent(in), optional :: qc_min

    qc: min: bound (operator prefix allowed).

    character(len=*), intent(in), optional :: qc_max

    qc: max: bound (operator prefix allowed).

    character(len=*), intent(in), optional :: qc_miss

    Sets qc: miss:. Absent means no miss: is declared, i.e. nothing is said about Nulls and none are checked. An explicit EMPTY string declares that Nulls are NOT expected and turns Null validation on. "Null"/"NA" (case-insensitive) declares that they are expected. Presence, not content, is what is tested -- see parquet_column_type%qc_allow_null.

procedure, public :: add_field_from => schema_add_field_from

Copies one field's definition from another (already-parsed) schema and appends it here via %add_field.

  • interface

    private module subroutine schema_add_field_from(this, source_schema, name)

    Copies name's full field definition from source_schema (via %get_field) and appends an equivalent field here via %add_field -- so two schemas can share a column definition (e.g. a handful of "identity" columns common to several output tables) without the caller re-typing its type/unit/info/qc by hand and risking drift between the copies. source_schema must already be parsed (see %get_field); this must already have %init called, exactly like a direct %add_field call would require. Subject to the same qc_min/qc_max/qc_miss round-trip caveats as %get_field: the copy is semantically equivalent to the source field, not necessarily a byte-identical MAML re-declaration.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema gaining the copied field (%init already called).

    type(parquet_schema), intent(in) :: source_schema

    already-parsed schema to copy name from.

    character(len=*), intent(in) :: name

    name of the field to copy (looked up in source_schema).

procedure, public :: set_column_available

Enables a column, or every column if no name is given.

  • interface

    private module subroutine set_column_available(this, name)

    Forwards to %cinfo%set_column_available; enables name, or every non-deactivated column if name is absent.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema whose cinfo is updated.

    character(len=*), intent(in), optional :: name

    column to enable; every column if absent.

procedure, public :: set_column_unavailable

Disables a column, or every column if no name is given.

  • interface

    private module subroutine set_column_unavailable(this, name)

    Forwards to %cinfo%set_column_unavailable; disables name, or every non-deactivated column if name is absent.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema whose cinfo is updated.

    character(len=*), intent(in), optional :: name

    column to disable; every column if absent.

procedure, public :: set_col_size => schema_set_col_size

Resolves a column's col_size before parquet_open_writer.

  • interface

    private module subroutine schema_set_col_size(this, name, col_size, force)

    Forwards to %cinfo%set_col_size.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema whose cinfo is updated.

    character(len=*), intent(in) :: name

    column to resolve.

    integer, intent(in) :: col_size

    new col_size (must be a positive integer).

    logical, intent(in), optional :: force

    .true. allows overriding a col_size that isn't currently "auto" (default .false.: only an "auto" col_size may be resolved this way).

procedure, public :: set_protected => schema_set_protected

Marks/unmarks a column Null-protected.

  • interface

    private module subroutine schema_set_protected(this, name, protected)

    Forwards to %cinfo%set_protected.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema whose cinfo is updated.

    character(len=*), intent(in) :: name

    column to mark (internal name, as declared).

    logical, intent(in), optional :: protected

    .false. to unprotect; default .true.

procedure, public :: set_array_size => schema_set_array_size

Resolves a string column's array_size before parquet_open_writer.

  • interface

    private module subroutine schema_set_array_size(this, name, array_size, force)

    Forwards to %cinfo%set_array_size.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(inout) :: this

    schema whose cinfo is updated.

    character(len=*), intent(in) :: name

    string column to resolve.

    integer, intent(in) :: array_size

    new array_size (must be a positive integer).

    logical, intent(in), optional :: force

    .true. allows overriding an array_size that isn't currently "auto" (default .false.: only an "auto" array_size may be resolved this way).

procedure, public :: get_column_index => schema_get_column_index

1-based index of a column by name; error stops if not found.

  • interface

    private module function schema_get_column_index(this, name)

    Forwards to %cinfo%get_column_index.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to search.

    character(len=*), intent(in) :: name

    column name to look up.

    Return Value integer

procedure, public :: is_column_set => schema_is_column_set

Whether a column is currently enabled to be written; error stops if not found.

  • interface

    private module function schema_is_column_set(this, name)

    Forwards to %cinfo%is_column_set.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to search.

    character(len=*), intent(in) :: name

    column name to look up.

    Return Value logical

procedure, public :: get_num_fields => schema_get_num_fields

Total number of declared fields.

  • interface

    private module function schema_get_num_fields(this)

    Forwards to %cinfo%get_num_fields.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    Return Value integer

procedure, public :: get_field_name => schema_get_field_name

Field name at a given 1-based MAML source position.

  • interface

    private module subroutine schema_get_field_name(this, index, name)

    Forwards to %cinfo%get_field_name.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    integer, intent(in) :: index

    1-based field position in MAML source order.

    character(len=:), intent(out), allocatable :: name

    field name at that position.

procedure, public :: get_field_by_name => schema_get_field_by_name

Full field definition by name; error stops if not found.

  • interface

    private module subroutine schema_get_field_by_name(this, name, data_type, unit, info, ucd, array_size, col_size, qc_min, qc_max, qc_miss)

    Forwards to %cinfo%get_field_by_name -- see that procedure's own doc comment (parquet_column_info's spec, above) for the full contract, including the qc_min/ qc_max/qc_miss round-trip caveats and the "schema must already be parsed" precondition.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    character(len=*), intent(in) :: name

    field name to look up.

    character(len=:), intent(out), optional, allocatable :: data_type

    field's data type.

    character(len=:), intent(out), optional, allocatable :: unit

    unit of measurement, if declared.

    character(len=:), intent(out), optional, allocatable :: info

    short description, if declared.

    character(len=:), intent(out), optional, allocatable :: ucd

    IVOA Unified Content Descriptor, if declared.

    integer, intent(out), optional :: array_size

    maximum string length (string fields only).

    integer, intent(out), optional :: col_size

    vector-column element count.

    character(len=:), intent(out), optional, allocatable :: qc_min

    Reconstructed qc: min: bound, operator-prefixed; empty if none was declared.

    character(len=:), intent(out), optional, allocatable :: qc_max

    Reconstructed qc: max: bound, operator-prefixed; empty if none was declared.

    character(len=:), intent(out), optional, allocatable :: qc_miss

    "Null" if this field allows Nulls (declared miss: Null/NA, or no miss: at all), else "" for the explicit empty miss: that asks for Null validation.

procedure, public :: get_field_by_index => schema_get_field_by_index

Full field definition by 1-based MAML source position.

  • interface

    private module subroutine schema_get_field_by_index(this, index, name, data_type, unit, info, ucd, array_size, col_size, qc_min, qc_max, qc_miss)

    Forwards to %cinfo%get_field_by_index -- see get_field_by_name above for the full per-argument contract; the only difference is the lookup key (1-based MAML source position instead of name) and that name itself is returned (not optional, since the caller doesn't already know it).

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema to query.

    integer, intent(in) :: index

    1-based field position in MAML source order.

    character(len=:), intent(out), allocatable :: name

    field name at that position.

    character(len=:), intent(out), optional, allocatable :: data_type

    field's data type.

    character(len=:), intent(out), optional, allocatable :: unit

    unit of measurement, if declared.

    character(len=:), intent(out), optional, allocatable :: info

    short description, if declared.

    character(len=:), intent(out), optional, allocatable :: ucd

    IVOA Unified Content Descriptor, if declared.

    integer, intent(out), optional :: array_size

    maximum string length (string fields only).

    integer, intent(out), optional :: col_size

    vector-column element count.

    character(len=:), intent(out), optional, allocatable :: qc_min

    Reconstructed qc: min: bound, operator-prefixed; empty if none was declared.

    character(len=:), intent(out), optional, allocatable :: qc_max

    Reconstructed qc: max: bound, operator-prefixed; empty if none was declared.

    character(len=:), intent(out), optional, allocatable :: qc_miss

    "Null" if this field allows Nulls (declared miss: Null/NA, or no miss: at all), else "" for the explicit empty miss: that asks for Null validation.

generic, public :: get_field => get_field_by_name, get_field_by_index

Reads back a field's full, add_field-equivalent definition, by name or by 1-based source position; forwards to %cinfo%get_field.

  • private interface schema_get_field_by_name()

    Arguments

    None
  • private interface schema_get_field_by_index()

    Arguments

    None

procedure, public :: print_schema_info => schema_print_schema_info

Writes a "Table name:" line plus an aligned name/unit/type/len/ucd/info listing of enabled (is_set) columns to a unit/file.

  • interface

    private module subroutine schema_print_schema_info(this, unit, filename, prefix, header, table_name, dash_before_header, dash_after_header, dash_after_fields, dash_char, allow_uninitialized)

    Writes a fixed-width, aligned listing of this schema's enabled (is_set) columns, one per output line, in the order name/unit/data_type/col_size/ucd/info -- the last (info) column is left unpadded so no line carries trailing whitespace. Column widths are derived from the longest value actually present across the enabled columns (and, when header=.true., the header label itself), so each call produces its own self-contained, internally-aligned block; two calls for different schemas are not aligned with each other. Exactly one of unit/filename must identify the destination: unit (an already-open unit, e.g. opened once by the caller and reused across several schemas' worth of calls to build up one combined listing) or filename (opened here with position="append", written, and closed again before returning). Giving neither, or an unopened/read-only unit, or a unit+filename pair where filename does not match (exact, trimmed string equality against inquire(unit=unit, name=)) the file unit is already connected to, all error stop. Calling this on a schema that has not been parsed yet (schema%cinfo not populated -- neither parquet_parse_maml nor, for an in-code schema, %init/%add_field followed by parquet_parse_maml, has run) also error stops by default, with the message "schema is not initialized (not parsed)" -- pass allow_uninitialized=.true. to silently print nothing instead (a complete no-op: no file is opened/touched, even in filename= mode) rather than aborting. Use schema%is_parsed() to check readiness before calling, rather than schema%is_init(): a from-scratch schema that has only had %init/%add_field called (never parsed) has is_init() == .true. but is_parsed() == .false., and would still error stop here. Conversely, a schema loaded via parquet_parse_maml (from a file or an already-populated object) is fully valid here even though it never calls %init -- is_parsed() == .true. covers that case too.

    Arguments

    Type IntentOptional Attributes Name
    class(parquet_schema), intent(in) :: this

    schema whose enabled (is_set) columns are listed.

    integer, intent(in), optional :: unit

    already-open unit to write to (see filename for the alternative).

    character(len=*), intent(in), optional :: filename

    output path; opened with position="append" if unit absent.

    character(len=*), intent(in), optional :: prefix

    prepended to every emitted line (default: none).

    logical, intent(in), optional :: header

    print a "name unit type len ucd info" header row (default .true.).

    logical, intent(in), optional :: table_name

    print a "Table name:

    " line, using this schema's required MAML table: key, positioned after dash_before_header and before the header row (default .true.).

    logical, intent(in), optional :: dash_before_header

    dashed separator line before the header (default .false.).

    logical, intent(in), optional :: dash_after_header

    dashed separator line after the header (default .true.).

    logical, intent(in), optional :: dash_after_fields

    dashed separator line after the last field row (default .false.).

    character(len=1), intent(in), optional :: dash_char

    character used to draw dashed lines (default "-").

    logical, intent(in), optional :: allow_uninitialized

    if .true., an unparsed schema (%cinfo not populated) is silently skipped (no output, no error) instead of error-stopping (default .false.).

    procedure, public :: add_col_qc => schema_add_col_qc

    Appends one qc: field entry from a compact string.

    • interface

      private module subroutine schema_add_col_qc(this, qc_input, col_name)

      Subroutine form of %add_col_qc: forwards to %maml%add_col_qc. See parquet_maml_add_col_qc (parquet_maml_base_add_col_qc.f90) for the "col, min, max, miss" input syntax and validation rules.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %maml gains one fields: entry.

      character(len=*), intent(in) :: qc_input

      compact "col, min, max, miss" string.

      character(len=:), intent(out), optional, allocatable :: col_name

      parsed column name.

    procedure, public :: set_col_qc => schema_set_col_qc

    In-place form of %add_col_qc; parses the name into its argument.

    • interface

      private module subroutine schema_set_col_qc(this, col_name)

      In-place form of %add_col_qc: forwards to %maml%set_col_qc. col_name is intent(inout), not separate in/out arguments: on entry it holds the compact "col, min, max, miss" string, and on exit it holds just the parsed column name -- so a caller reuses one variable (call schema%set_col_qc(col)) rather than assigning a function result back into it (a subroutine can't alias the same actual argument to separate intent(in)/intent(out) dummies).

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %maml gains one fields: entry.

      character(len=:), intent(inout), allocatable :: col_name

      compact "col, min, max, miss" string on entry; parsed column name on exit.

    procedure, public :: schema_add_metadata_int32

    int32 specific.

    • interface

      private module subroutine schema_add_metadata_int32(this, key, value, description, warn)

      int32 specific of %add_metadata; forwards to %metadata%add_metadata (see the parquet_get_metadata generic interface above for the read-side counterpart and its stored-representation semantics). Error stops if the schema has not been parsed yet (%cinfo not populated -- parquet_parse_maml must run before %add_metadata is called, not after), since an entry added before that point would otherwise be silently discarded when %cinfo%col/%metadata%items are (re)built by the parse that follows.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      integer(kind=int32), intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_int64

    int64 specific.

    • interface

      private module subroutine schema_add_metadata_int64(this, key, value, description, warn)

      int64 specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      integer(kind=int64), intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_float32

    float32 specific.

    • interface

      private module subroutine schema_add_metadata_float32(this, key, value, description, fmt, warn)

      float32 specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      real(kind=real32), intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      character(len=*), intent(in), optional :: fmt

      optional Fortran edit descriptor for the stored text.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_float64

    float64 specific.

    • interface

      private module subroutine schema_add_metadata_float64(this, key, value, description, fmt, warn)

      float64 specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      real(kind=real64), intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      character(len=*), intent(in), optional :: fmt

      optional Fortran edit descriptor for the stored text.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_logical

    logical specific.

    • interface

      private module subroutine schema_add_metadata_logical(this, key, value, description, warn)

      logical specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      logical, intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_string

    string specific.

    • interface

      private module subroutine schema_add_metadata_string(this, key, value, description, warn)

      string specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      character(len=*), intent(in) :: value

      metadata value.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_int32_array

    int32 array specific.

    • interface

      private module subroutine schema_add_metadata_int32_array(this, key, value, description, warn)

      int32 array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      integer(kind=int32), intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_int64_array

    int64 array specific.

    • interface

      private module subroutine schema_add_metadata_int64_array(this, key, value, description, warn)

      int64 array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      integer(kind=int64), intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_float32_array

    float32 array specific.

    • interface

      private module subroutine schema_add_metadata_float32_array(this, key, value, description, fmt, warn)

      float32 array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      real(kind=real32), intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      character(len=*), intent(in), optional :: fmt

      optional Fortran edit descriptor for the stored text.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_float64_array

    float64 array specific.

    • interface

      private module subroutine schema_add_metadata_float64_array(this, key, value, description, fmt, warn)

      float64 array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      real(kind=real64), intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      character(len=*), intent(in), optional :: fmt

      optional Fortran edit descriptor for the stored text.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_logical_array

    logical array specific.

    • interface

      private module subroutine schema_add_metadata_logical_array(this, key, value, description, warn)

      logical array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      logical, intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    procedure, public :: schema_add_metadata_string_array

    string array specific.

    • interface

      private module subroutine schema_add_metadata_string_array(this, key, value, description, warn)

      string array specific of %add_metadata; see schema_add_metadata_int32.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata gains one entry.

      character(len=*), intent(in) :: key

      metadata key.

      character(len=*), intent(in) :: value(:)

      metadata values.

      character(len=*), intent(in), optional :: description

      optional free-text description.

      logical, intent(in), optional :: warn

      .false. suppresses the duplicate-key warning (default .true.).

    Appends one flat key-value metadata entry; dispatched by value's type/kind/rank.

    • private interface schema_add_metadata_int32()

      Arguments

      None
    • private interface schema_add_metadata_int64()

      Arguments

      None
    • private interface schema_add_metadata_float32()

      Arguments

      None
    • private interface schema_add_metadata_float64()

      Arguments

      None
    • private interface schema_add_metadata_logical()

      Arguments

      None
    • private interface schema_add_metadata_string()

      Arguments

      None
    • private interface schema_add_metadata_int32_array()

      Arguments

      None
    • private interface schema_add_metadata_int64_array()

      Arguments

      None
    • private interface schema_add_metadata_float32_array()

      Arguments

      None
    • private interface schema_add_metadata_float64_array()

      Arguments

      None
    • private interface schema_add_metadata_logical_array()

      Arguments

      None
    • private interface schema_add_metadata_string_array()

      Arguments

      None

    procedure, public :: clear_metadata => schema_clear_metadata

    Forwards to %metadata%clear_metadata.

    • interface

      private module subroutine schema_clear_metadata(this)

      Forwards to %metadata%clear_metadata: discards every %add_metadata entry added after the most recent parquet_parse_maml, keeping the base (header keys + keyarray:) entries from the schema's %init/%add_field build or MAML source.

      Arguments

      Type IntentOptional Attributes Name
      class(parquet_schema), intent(inout) :: this

      schema whose %metadata is truncated.

    Source Code

        type parquet_schema
            type(parquet_maml_file)      :: maml     !! Raw MAML source plus (once parsed) missing-columns/col_map.
            type(parquet_column_info)    :: cinfo    !! Per-field schema/QC state, derived from %maml by parquet_parse_maml.
            type(parquet_table_metadata) :: metadata !! Flat key-value table metadata, derived from %maml's keyarray:.
            !> Set by %init: guards %add_field, which otherwise has no "fields:"
            !> header (or even a %maml at all) to append to. Only %init and
            !> %add_field are meaningful for a schema being built from scratch in
            !> memory -- a schema populated via parquet_parse_maml (from a real
            !> MAML file/object) never calls %init and never needs %add_field.
            logical, private :: is_initialized = .false.
        contains
            procedure :: init => schema_init !! Initializes a from-scratch schema (table: key + optional metadata).
            procedure :: is_init => schema_is_init !! Whether this schema is ready to use (via %init or a MAML parse).
            procedure :: is_parsed => schema_is_parsed !! Whether %cinfo has actually been populated by parquet_parse_maml.
            procedure :: clear => schema_clear !! Resets the entire schema back to its pristine,
            !! just-declared (never-initialized) state.
            procedure :: add_field => schema_add_field !! Appends one fields: entry to a from-scratch schema.
            procedure :: add_field_from => schema_add_field_from !! Copies one field's definition from another
            !! (already-parsed) schema and appends it here via %add_field.
            procedure :: set_column_available !! Enables a column, or every column if no name is given.
            procedure :: set_column_unavailable !! Disables a column, or every column if no name is given.
            procedure :: set_col_size => schema_set_col_size !! Resolves a column's col_size before parquet_open_writer.
            procedure :: set_protected => schema_set_protected !! Marks/unmarks a column Null-protected.
            procedure :: set_array_size => schema_set_array_size !! Resolves a string column's array_size before
            !! parquet_open_writer.
            procedure :: get_column_index => schema_get_column_index !! 1-based index of a column by
            !! name; error stops if not found.
            procedure :: is_column_set => schema_is_column_set !! Whether a column is currently enabled to be
            !! written; error stops if not found.
            procedure :: get_num_fields => schema_get_num_fields !! Total number of declared fields.
            procedure :: get_field_name => schema_get_field_name !! Field name at a given 1-based MAML source position.
            procedure :: get_field_by_name => schema_get_field_by_name !! Full field definition by name; error
            !! stops if not found.
            procedure :: get_field_by_index => schema_get_field_by_index !! Full field definition by 1-based
            !! MAML source position.
            generic :: get_field => get_field_by_name, get_field_by_index !! Reads back a field's full,
            !! add_field-equivalent definition, by name or by 1-based source position; forwards to %cinfo%get_field.
            procedure :: print_schema_info => schema_print_schema_info !! Writes a "Table name:" line plus an aligned
            !! name/unit/type/len/ucd/info listing of enabled (is_set) columns to a unit/file.
            ! add_col_qc/set_col_qc build a read-time qc-maml. Two intentional
            ! naming choices here: (1) "col_qc" is a deliberate domain abbreviation
            ! for "column quality-control" (the qc: block of a fields: entry) --
            ! kept short because it appears in every qc-building call. (2) set_col_qc
            ! is named set_ (not get_) precisely because it MUTATES the schema (it
            ! appends the entry, like add_col_qc): the set_ form exists so a caller
            ! can reuse one variable in place (call schema%set_col_qc(col) -- col holds
            ! the qc_input string on entry, the parsed column name on exit) instead of
            ! separately naming an input and an output variable the way add_col_qc's
            ! optional col_name argument requires. It is a builder that also returns
            ! the name, not a pure query -- and, being a subroutine, never returns
            ! character(len=:), allocatable as a function result (see "Build and
            ! compiler notes" in CLAUDE.md for why that matters).
            procedure :: add_col_qc => schema_add_col_qc !! Appends one qc: field entry from a compact string.
            procedure :: set_col_qc => schema_set_col_qc !! In-place form of %add_col_qc; parses the name into its argument.
            procedure :: schema_add_metadata_int32 !! int32 specific.
            procedure :: schema_add_metadata_int64 !! int64 specific.
            procedure :: schema_add_metadata_float32 !! float32 specific.
            procedure :: schema_add_metadata_float64 !! float64 specific.
            procedure :: schema_add_metadata_logical !! logical specific.
            procedure :: schema_add_metadata_string !! string specific.
            procedure :: schema_add_metadata_int32_array !! int32 array specific.
            procedure :: schema_add_metadata_int64_array !! int64 array specific.
            procedure :: schema_add_metadata_float32_array !! float32 array specific.
            procedure :: schema_add_metadata_float64_array !! float64 array specific.
            procedure :: schema_add_metadata_logical_array !! logical array specific.
            procedure :: schema_add_metadata_string_array !! string array specific.
            !> Appends one flat key-value metadata entry; dispatched by value's type/kind/rank.
            generic :: add_metadata => schema_add_metadata_int32, schema_add_metadata_int64, &
                                        schema_add_metadata_float32, schema_add_metadata_float64, &
                                        schema_add_metadata_logical, schema_add_metadata_string, &
                                        schema_add_metadata_int32_array, schema_add_metadata_int64_array, &
                                        schema_add_metadata_float32_array, schema_add_metadata_float64_array, &
                                        schema_add_metadata_logical_array, schema_add_metadata_string_array
            procedure :: clear_metadata => schema_clear_metadata !! Forwards to %metadata%clear_metadata.
        end type parquet_schema