Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fix quirks in dataset spec types #207

Merged
merged 9 commits into from
Dec 1, 2023

Conversation

spencerwilson
Copy link
Contributor

@spencerwilson spencerwilson commented Nov 28, 2023

  • Convert TableSchemaField from an enum w/ one struct-like variant per data type => a struct with fields common to all data types—name/description/constraints—plus a field type_: FieldType. FieldType would hold the data type-specific bits, but currently there are none so the enum is just a "unit-only enum".
  • Remove missing_values field, and other unused generated code
  • Convert Table.schema from Option<TableSchema> => TableSchema
  • Drop remaining relics of typify codegen

If you like you can go commit by commit to see step-by-step how I was able to do all this.

A cousin PR of this one was #98, which has more context on the origin of the cruft removed here.

Test plan

Verified that the serialized representation is safely changed, i.e., it retained the aspects our system actually depends on, while dropping unused bits. Running init in this branch produced a spec like:

{
  "id": "018c1760-7c8e-7ddf-a60c-c97a093adcbe",
  "name": "demo",
  "description": null,
  "version": "0.1.0",
  "accelerated": false,
  "dataset": [
    {
      "name": "GOLDEN_TYPES",
      "description": null,
      "source": {
        "id": "909f4a68-179f-41c0-9ace-d48ba554a33b",
        "path": {
          "type": "snowflake",
          "schema": "TEST_SUITE",
          "table": "GOLDEN_TYPES"
        }
      },
      "schema": {
        "fields": [
          {
            "name": "FLOAT",
            "type": "number",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "TIMESTAMP_TZ",
            "type": "datetime",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "TIMESTAMP_LTZ",
            "type": "datetime",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "VARCHAR",
            "type": "string",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "DATE",
            "type": "date",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "NUMBER",
            "type": "number",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "BOOLEAN",
            "type": "boolean",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "VARIANT",
            "type": "string",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "TIMESTAMP",
            "type": "datetime",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "ARRAY",
            "type": "array",
            "constraints": {
              "required": false
            }
          },
          {
            "name": "TIMESTAMP_NTZ",
            "type": "datetime",
            "constraints": {
              "required": false
            }
          }
        ],
        "primaryKey": [
          "FLOAT"
        ]
      }
    }
  ]
}

Copy link
Contributor Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

Copy link
Contributor

@ajmasci ajmasci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You win the red-diff challenge. 🥇

@spencerwilson spencerwilson merged commit c4258bb into main Dec 1, 2023
10 checks passed
@spencerwilson spencerwilson deleted the pat-3895-simplify-spec branch December 1, 2023 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants