Repository navigation
feat(schema): model LIKE and PARTITION OF tables and partition links - #67
Merged
Merged
Conversation
CREATE TABLE copies the columns of a modeled LIKE source or partition parent in written order, models () as a table without columns, and rejects AS SELECT, OF type, and INHERITS with their line. A partition follows its parent's column changes, rename, and DROP TABLE until DETACH PARTITION, and ATTACH PARTITION of a modeled table links it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Schema sources that create tables with
CREATE TABLE ... (LIKE t ...)orCREATE TABLE ... PARTITION OF tpreviously produced tables with missing columns or failed internally. sqlcj now copies the source table's columns, keeps partitions in step with their parent, and rejects theCREATE TABLEforms whose columns it cannot determine, so a table is never modeled with missing columns.Changes
LIKE t, with anyINCLUDING/EXCLUDINGoptions, copies the columns, types, and nullability of the modeled tabletat its position in the element list, beside column definitions, table constraints, or furtherLIKEclauses, in written order. A repeated column name fails asColumn already exists in table <t>: <c>.PARTITION OF twithFOR VALUES FROM ... TO,IN,WITH (MODULUS ...), orDEFAULT, and an optional table-constraint list, starts with its parent's columns.Table not found in schema: <t>.()is modeled as a table without columns.AS SELECT,OF <type>, andINHERITSare rejected asUnsupported CREATE TABLE clause: <clause> at line <n>. ACREATE TABLEwith no element list,(), orPARTITION OFis rejected as unsupported table DDL.ADD,DROP, andRENAME COLUMN,ALTER COLUMN ... TYPE, andSET/DROP NOT NULLreach partitions recursively. Renaming the parent keeps the link.DROP TABLEof a parent removes its partitions recursively. Every name of oneDROP TABLEis resolved before anything is dropped, soDROP TABLE parent, partitionloads.ATTACH PARTITIONof a modeled table starts the link andDETACH PARTITIONends it. A partition sqlcj does not model is still ignored. ALIKEcopy never follows its source.LIKEorPARTITION OFsource, or anATTACH/DETACH PARTITIONpartition, resolves by its unqualified name, sopublic.tist. The same name qualified with any other schema fails asTable not found in schema: <schema>.<t>.Scope and non-goals
ALTER TABLE ... INHERITare not modeled. Schemas other thanpublicare not modeled beyond the qualified-name rule above.PARTITION OForOF <type>andAS SELECT ... WITH NO DATAcannot be read by the SQL parser and stay rejected as unreadable table DDL.PARTITION OF, are not validated.