From 35d8dbfdfcb34f43ebc99b377f3057fc6929e723 Mon Sep 17 00:00:00 2001 From: DiegoGCh Date: Thu, 26 Dec 2024 11:10:13 -0500 Subject: [PATCH 1/8] Added cornzyblack test fix --- .../fixtures/s3-json-remote/datacontract.yaml | 81 +++++++++---------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/tests/fixtures/s3-json-remote/datacontract.yaml b/tests/fixtures/s3-json-remote/datacontract.yaml index 36cb7416..d6dc8d1a 100644 --- a/tests/fixtures/s3-json-remote/datacontract.yaml +++ b/tests/fixtures/s3-json-remote/datacontract.yaml @@ -4,8 +4,8 @@ info: title: Orders Latest version: 2.0.0 description: | - Successful customer orders in the webshop. - All orders since 2020-01-01. + Successful customer orders in the webshop. + All orders since 2020-01-01. Orders with their line items are in their current state (no history included). owner: Checkout Team contact: @@ -63,13 +63,13 @@ models: required: true examples: - 9999 -# quality: -# - type: sql -# description: 95% of all order total values are expected to be between 10 and 499 EUR. -# query: | -# SELECT quantile_cont(order_total, 0.95) AS percentile_95 -# FROM orders -# mustBeBetween: [1000, 49900] + quality: + - type: sql + description: 95% of all order total values are expected to be between 10 and 499 EUR. + query: | + SELECT quantile_cont(order_total, 0.95) AS percentile_95 + FROM orders + mustBeBetween: [1000, 49900] customer_id: description: Unique identifier for the customer. type: text @@ -98,15 +98,12 @@ models: jsonType: string jsonFormat: date-time quality: -# - type: sql -# description: The maximum duration between two orders should be less that 3600 seconds -# query: | -# SELECT MAX(duration) AS max_duration -# FROM ( -# SELECT epoch(order_timestamp - LAG(order_timestamp) OVER (ORDER BY order_timestamp)) AS duration -# FROM orders -# ) subquery -# mustBeLessThan: 3600 + - type: sql + description: The maximum duration between two orders should be less that 3600 seconds + query: | + SELECT MAX(duration) AS max_duration FROM (SELECT EXTRACT(EPOCH FROM (order_timestamp - LAG(order_timestamp) + OVER (ORDER BY order_timestamp))) AS duration FROM orders) + mustBeLessThan: 3600 - type: sql description: Row Count query: | @@ -115,17 +112,17 @@ models: mustBeGreaterThan: 5 examples: - | - order_id,order_timestamp,order_total,customer_id,customer_email_address,processed_timestamp - "1001","2030-09-09T08:30:00Z",2500,"1000000001","mary.taylor82@example.com","2030-09-09T08:31:00Z" - "1002","2030-09-08T15:45:00Z",1800,"1000000002","michael.miller83@example.com","2030-09-09T08:31:00Z" - "1003","2030-09-07T12:15:00Z",3200,"1000000003","michael.smith5@example.com","2030-09-09T08:31:00Z" - "1004","2030-09-06T19:20:00Z",1500,"1000000004","elizabeth.moore80@example.com","2030-09-09T08:31:00Z" - "1005","2030-09-05T10:10:00Z",4200,"1000000004","elizabeth.moore80@example.com","2030-09-09T08:31:00Z" - "1006","2030-09-04T14:55:00Z",2800,"1000000005","john.davis28@example.com","2030-09-09T08:31:00Z" - "1007","2030-09-03T21:05:00Z",1900,"1000000006","linda.brown67@example.com","2030-09-09T08:31:00Z" - "1008","2030-09-02T17:40:00Z",3600,"1000000007","patricia.smith40@example.com","2030-09-09T08:31:00Z" - "1009","2030-09-01T09:25:00Z",3100,"1000000008","linda.wilson43@example.com","2030-09-09T08:31:00Z" - "1010","2030-08-31T22:50:00Z",2700,"1000000009","mary.smith98@example.com","2030-09-09T08:31:00Z" + order_id,order_timestamp,order_total,customer_id,customer_email_address,processed_timestamp + "1001","2030-09-09T08:30:00Z",2500,"1000000001","mary.taylor82@example.com","2030-09-09T08:31:00Z" + "1002","2030-09-08T15:45:00Z",1800,"1000000002","michael.miller83@example.com","2030-09-09T08:31:00Z" + "1003","2030-09-07T12:15:00Z",3200,"1000000003","michael.smith5@example.com","2030-09-09T08:31:00Z" + "1004","2030-09-06T19:20:00Z",1500,"1000000004","elizabeth.moore80@example.com","2030-09-09T08:31:00Z" + "1005","2030-09-05T10:10:00Z",4200,"1000000004","elizabeth.moore80@example.com","2030-09-09T08:31:00Z" + "1006","2030-09-04T14:55:00Z",2800,"1000000005","john.davis28@example.com","2030-09-09T08:31:00Z" + "1007","2030-09-03T21:05:00Z",1900,"1000000006","linda.brown67@example.com","2030-09-09T08:31:00Z" + "1008","2030-09-02T17:40:00Z",3600,"1000000007","patricia.smith40@example.com","2030-09-09T08:31:00Z" + "1009","2030-09-01T09:25:00Z",3100,"1000000008","linda.wilson43@example.com","2030-09-09T08:31:00Z" + "1010","2030-08-31T22:50:00Z",2700,"1000000009","mary.smith98@example.com","2030-09-09T08:31:00Z" line_items: description: A single article that is part of an order. type: table @@ -142,18 +139,18 @@ models: $ref: '#/definitions/sku' primaryKey: ["order_id", "line_item_id"] examples: - - | - line_item_id,order_id,sku - "LI-1","1001","5901234123457" - "LI-2","1001","4001234567890" - "LI-3","1002","5901234123457" - "LI-4","1002","2001234567893" - "LI-5","1003","4001234567890" - "LI-6","1003","5001234567892" - "LI-7","1004","5901234123457" - "LI-8","1005","2001234567893" - "LI-9","1005","5001234567892" - "LI-10","1005","6001234567891" + - | + line_item_id,order_id,sku + "LI-1","1001","5901234123457" + "LI-2","1001","4001234567890" + "LI-3","1002","5901234123457" + "LI-4","1002","2001234567893" + "LI-5","1003","4001234567890" + "LI-6","1003","5001234567892" + "LI-7","1004","5901234123457" + "LI-8","1005","2001234567893" + "LI-9","1005","5001234567892" + "LI-10","1005","6001234567891" definitions: order_id: title: Order ID @@ -173,7 +170,7 @@ definitions: examples: - "96385074" description: | - A Stock Keeping Unit (SKU) is an internal unique identifier for an article. + A Stock Keeping Unit (SKU) is an internal unique identifier for an article. It is typically associated with an article's barcode, such as the EAN/GTIN. links: wikipedia: https://en.wikipedia.org/wiki/Stock_keeping_unit From a9812d27f78acf52aba531874d2bb110f685030c Mon Sep 17 00:00:00 2001 From: DiegoGCh Date: Thu, 26 Dec 2024 11:48:19 -0500 Subject: [PATCH 2/8] changed primary to primaryKey in yaml --- tests/datacontract-1.html | 114 +-- .../breaking/datacontract-fields-v2.yaml | 2 +- .../breaking/datacontract-fields-v3.yaml | 2 +- tests/fixtures/dbml/datacontract.yaml | 4 +- tests/fixtures/dbml/import/datacontract.yaml | 18 +- .../import/datacontract_schema_filtered.yaml | 6 +- .../import/datacontract_table_filtered.yaml | 12 +- .../examples/datacontract_formats_valid.yaml | 2 +- .../lint/valid_datacontract_references.yaml | 2 +- .../adventureworks-example.datacontract.yml | 834 ++++++++-------- .../odcs_v2/full-example.datacontract.yml | 6 +- ...cs-postgresql-adventureworks-contract.yaml | 916 +++++++++--------- .../odcs_v3/adventureworks.datacontract.yml | 914 ++++++++--------- .../odcs_v3/full-example.datacontract.yml | 6 +- tests/test_import_sql.py | 4 +- 15 files changed, 1422 insertions(+), 1420 deletions(-) diff --git a/tests/datacontract-1.html b/tests/datacontract-1.html index fd036dce..779e3dee 100644 --- a/tests/datacontract-1.html +++ b/tests/datacontract-1.html @@ -1748,62 +1748,64 @@

-
dataContractSpecification: 1.1.0
-id: orders-unit-test
-info:
-  title: Orders Unit Test
-  version: 1.0.0
-  description: The orders data contract
-  owner: checkout
-  contact:
-    url: https://wiki.example.com/teams/checkout
-    email: team-orders@example.com
-servers:
-  production:
-    type: snowflake
-    account: my-account
-    database: my-database
-    schema_: my-schema
-terms:
-  usage: This data contract serves to demo datacontract CLI export.
-  limitations: Not intended to use in production
-  billing: free
-  noticePeriod: P3M
-models:
-  orders:
-    description: The orders model
-    type: table
-    fields:
-      order_id:
-        type: varchar
-        required: true
-        primary: false
-        unique: true
-        pii: true
-        classification: sensitive
-        pattern: ^B[0-9]+$
-        minLength: 8
-        maxLength: 10
-        tags:
-        - order_id
-      order_total:
-        type: bigint
-        required: true
-        primary: false
-        unique: false
-        description: The order_total field
-        minimum: 0
-        maximum: 1000000
-      order_status:
-        type: text
-        required: true
-        primary: false
-        unique: false
-        enum:
-        - pending
-        - shipped
-        - delivered
-
+
+              
+                dataContractSpecification: 1.1.0
+                id: orders-unit-test
+                info:
+                  title: Orders Unit Test
+                  version: 1.0.0
+                  description: The orders data contract
+                  owner: checkout
+                  contact:
+                    url: https://wiki.example.com/teams/checkout
+                    email: team-orders@example.com
+                servers:
+                  production:
+                    type: snowflake
+                    account: my-account
+                    database: my-database
+                    schema_: my-schema
+                terms:
+                  usage: This data contract serves to demo datacontract CLI export.
+                  limitations: Not intended to use in production
+                  billing: free
+                  noticePeriod: P3M
+                models:
+                  orders:
+                    description: The orders model
+                    type: table
+                    fields:
+                      order_id:
+                        type: varchar
+                        required: true
+                        primaryKey: false
+                        unique: true
+                        pii: true
+                        classification: sensitive
+                        pattern: ^B[0-9]+$
+                        minLength: 8
+                        maxLength: 10
+                        tags:
+                        - order_id
+                      order_total:
+                        type: bigint
+                        required: true
+                        primaryKey: false
+                        unique: false
+                        description: The order_total field
+                        minimum: 0
+                        maximum: 1000000
+                      order_status:
+                        type: text
+                        required: true
+                        primaryKey: false
+                        unique: false
+                        enum:
+                        - pending
+                        - shipped
+                        - delivered
+