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

Object Arrays in SQL Not Being Created #467

Open
mr-griffles opened this issue Oct 17, 2024 · 1 comment
Open

Object Arrays in SQL Not Being Created #467

mr-griffles opened this issue Oct 17, 2024 · 1 comment
Labels
good first issue Good for newcomers

Comments

@mr-griffles
Copy link

Arrays of objects/structs are not being outputted in the SQL schema automated generation.

Example Contract

dataContractSpecification: 0.9.3
id: worms
info:
  title: Worms
  version: 0.0.1
  description: List of Worm Teams
  links:
    blog: hungovercoders.com
servers:
  production:
    type: databricks # this will default to context running in - see servers in data contract spec if want to be more remote 
    catalog: main
    schema: worms
models:
  worm_team:
    description: Worm teams and their members
    type: table
    fields:
      team_name:
        type: string
        enum: 
          - Aliens
          - South Park
          - Ghostbusters
          - The A Team
        required: true
        primary: true
        unique: true
        description: Name of the worms team
        example: "Aliens"
        pii: false
        domain: Worms
      team_members:
        type: array
        items:
          type: object
          description: Worm team members
          fields:
            name:
              type: string
              required: true
              description: Name of the worm
              example: "Hudson"
              pii: false
              domain: Worms
            age:
              type: integer
              required: true
              description: Age of the worm
              example: "10"
              pii: false
              domain: Worms

Current Output

-- Data Contract: worms
-- SQL Dialect: databricks
CREATE OR REPLACE TABLE main.worms.worm_team (
  team_name STRING not null primary key COMMENT "Name of the worms team",
  team_members ARRAY
) COMMENT "Worm teams and their members";

Desired Output

-- Data Contract: worms
-- SQL Dialect: databricks
CREATE OR REPLACE TABLE main.worms.worm_team (
  team_name STRING not null primary key COMMENT "Name of the worms team",
  team_members ARRAY <STRUCT<name STRING, age INT>> COMMENT "Worm Team Members"
) COMMENT "Worm teams and their members";
@simonharrer simonharrer added the good first issue Good for newcomers label Oct 17, 2024
@simonharrer
Copy link
Contributor

Thanks for reporting this nicely written issue! I second this. This is also a good starting point for anyone who wants to contribute to the Data Contract CLI tool. @mr-griffles would you, by any chance, would like to have a go to contribute a pull request for this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants