Skip to content

[DO NOT MERGE] Adds generate serde for PartiQL shapes.#4

Open
rchowell wants to merge 4 commits intomainfrom
linac
Open

[DO NOT MERGE] Adds generate serde for PartiQL shapes.#4
rchowell wants to merge 4 commits intomainfrom
linac

Conversation

@rchowell
Copy link
Copy Markdown

Description of changes:

  • Adds linac module in partiql-beamline-serde
  • Adds shape.rs (the generated sources)
  • Includesruntime.rs from the codegen runtime helpers
  • The file serde.rs contains the PartiqlShapeEncoder impls

Model

type shape union {

    // Any
    t_dynamic,

    // Logical
    t_unknown,
    t_bool,

    // Exact Numeric
    t_int8,
    t_int16,
    t_int32,
    t_int64,
    t_int,
    t_decimal,
    t_numeric: struct {
        precision: int,
        scale: int,
    },

    // Approximate Numeric
    t_float32,
    t_float64,
    t_float: struct { precision: int },

    // Character Strings
    t_string,
    t_string_fixed: struct { length: int },
    t_string_varying: struct { length: int },

    // Lobs
    t_blob,
    t_clob,

    // Date/Time
    t_date,
    t_time: struct { precision: int },
    t_time_tz: struct {
        precision: int,
        offset_hour: int,
        offset_minute: int,
    },
    t_timestamp: struct { precision: int },
    t_timestamp_tz: struct {
        precision: int,
        offset_hour: int,
        offset_minute: int,
    },

    // Collections
    t_bag: struct { items: shape },
    t_array: struct { items: shape },
    t_struct: struct { fields: field[] },

    // Any of
    t_union: struct { variants: shape[] },
};

type field struct {
  name: string,
  shape: shape,
};

Example

cargo run --release --all-features infer-shape -f linac  \ 
    --seed-auto --start-auto \
    --script-path ./partiql-beamline-sim/tests/scripts/sensors.ion

{
  seed: -494180438918385056,
  shapes: {
    sensors: partiql::shape::v0::'shape.t_bag'::{
      items: 'shape.t_struct'::{
        fields: [
          field::{
            name: "a",
            shape: 'shape.t_union'::{
              variants: [
                'shape.t_int64'::unit,
                'shape.t_numeric'::{
                  precision: 5,
                  scale: 4
                },
                'shape.t_float64'::unit,
                'shape.t_string'::unit
              ]
            }
          },
          field::{
            name: "d",
            shape: 'shape.t_numeric'::{
              precision: 2,
              scale: 0
            }
          },
          field::{
            name: "f",
            shape: 'shape.t_float64'::unit
          },
          field::{
            name: "i8",
            shape: 'shape.t_int64'::unit
          },
          field::{
            name: "tick",
            shape: 'shape.t_int64'::unit
          },
          field::{
            name: "w",
            shape: 'shape.t_numeric'::{
              precision: 5,
              scale: 4
            }
          }
        ]
      }
    }
  }
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rchowell rchowell requested a review from am357 May 21, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant