partiql / partiql-lang-kotlin

PartiQL libraries and tools in Kotlin.
https://partiql.org/
Apache License 2.0
538 stars 60 forks source link

DDL Plan Model. #1461

Closed yliuuuu closed 2 months ago

yliuuuu commented 4 months ago

Relevant Issues

Description

Reviewer Note:

I recommend taking a look at the test cases first. Then the internal plan modeling.

Plan Vs Internal Plan: the diff between the two is large in this PR, this is because we want to continue experimenting with model of the ddl plan and type system, while maintain a relatively stable public plan.

Internal Plan:

DDL:

  d_d_l::{
    shape: static_type,
    op: ddl_op,
  },

The DDL Operation carries a shape properties and an op properties.

The shape properties describe the resulting shape of data after performed the DDL Operation. This split between Op and shape can be helpful when we incorporate other DDL operation, like ALTER

DdlOpCreateTable

  create_table::{
    name: identifier,
    shape: '.type.collection',
    partition_by: optional::partition_by,
    table_properties: list::[table_property],
}

Public Plan:

  d_d_l::{
    op: ddl_op,
  }

ddl_op::[
  create_table::{
    name: identifier,
    shape: 'static_type',
    partition_by: optional::partition_by,
    table_properties: list::[table_property],
  },
]

The public plan is designed to have minimum interference with the existing public APIs. Hence we switch the shape in create table to use static type.

Notice that DDL node will not carry the static type in the public plan, this is a decision that can be revisited. But I opt to not included this properties in this PR. Depending on the status of the type work do over, we can potentially just use the new Type APIs instead of the migration plan. Because we are only working on Create Table, no information will be lost.

Constraints

We should distinguish those from the constraint concept from typed lambda calculus and the constraint concept from SQL Spec.

Not Null Constraints

Check constraints.

Primary key constraint:

This is, given

CREATE TABLE tbl (
     a INT2 PRIMARY KEY
)

The type will be:

Bag (
   STRUCT (
       a : INT2
   )
   PK : ["a"]
)

Other aspect of the PR

Other Information

License Information

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

github-actions[bot] commented 4 months ago

Conformance comparison report-Cross Engine

Base (eval) legacy +/-
% Passing 90.70% 92.51% 1.80%
:white_check_mark: Passing 5278 5382 104
:x: Failing 541 436 -105
:large_orange_diamond: Ignored 0 0 0
Total Tests 5819 5818 -1

Number passing in both: 5071

Number failing in both: 229

Number passing in eval engine but fail in legacy engine: 207

Number failing in eval engine but pass in legacy engine: 312 :interrobang: CONFORMANCE REPORT REGRESSION DETECTED :interrobang: The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact. 312 test(s) were failing in eval but now pass in legacy. Before merging, confirm they are intended to pass. The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

Conformance comparison report-Cross Commit-EVAL

Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) 4588ef844bf159add96505831fabbc78fc45a592 +/-
% Passing 90.70% 90.70% 0.00%
:white_check_mark: Passing 5278 5278 0
:x: Failing 541 541 0
:large_orange_diamond: Ignored 0 0 0
Total Tests 5819 5819 0

Number passing in both: 5278

Number failing in both: 541

Number passing in Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) but now fail: 1

Number failing in Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) but now pass: 1 :interrobang: CONFORMANCE REPORT REGRESSION DETECTED :interrobang:. The following test(s) were previously passing but now fail:

Click here to see - Example 6 — Value Coercion, compileOption: LEGACY

The following test(s) were previously failing but now pass. Before merging, confirm they are intended to pass:

Click here to see - Example 6 — Value Coercion, compileOption: LEGACY

Conformance comparison report-Cross Commit-LEGACY

Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) 4588ef844bf159add96505831fabbc78fc45a592 +/-
% Passing 92.51% 92.51% 0.00%
:white_check_mark: Passing 5382 5382 0
:x: Failing 436 436 0
:large_orange_diamond: Ignored 0 0 0
Total Tests 5818 5818 0

Number passing in both: 5382

Number failing in both: 436

Number passing in Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) but now fail: 0

Number failing in Base (4f89c2dd4cb6a6199f8056bedc2064db32ea2ce2) but now pass: 0

yliuuuu commented 2 months ago

Close this PR for now.

We'd like to merge DDL as a post-V1 Feature.