-
Notifications
You must be signed in to change notification settings - Fork 102
feat: add support for create table like #95
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE UNLOGGED TABLE cities (name text, population real, altitude double, identifier smallint, postal_code int, foreign_id bigint); | ||
/* TODO: CREATE TABLE IF NOT EXISTS distributors (name varchar(40) DEFAULT 'Luso Films', len interval hour to second(3), name varchar(40) DEFAULT 'Luso Films', did int DEFAULT nextval('distributors_serial'), stamp timestamp DEFAULT now() NOT NULL, stamptz timestamp with time zone, "time" time NOT NULL, timetz time with time zone, CONSTRAINT name_len PRIMARY KEY (name, len)); */ SELECT 1; | ||
/* TODO: CREATE TABLE types (a real, b double precision, c numeric(2, 3), d char(4), e char(5), f varchar(6), g varchar(7)); */ SELECT 1; | ||
/* TODO: CREATE TABLE types (a geometry(point) NOT NULL); */ SELECT 1; | ||
CREATE TABLE tablename (colname int NOT NULL DEFAULT nextval('tablename_colname_seq')); | ||
CREATE TABLE capitals (state char(2)) INHERITS (cities); | ||
/* TODO: CREATE TEMPORARY TABLE temp AS SELECT c FROM t; */ SELECT 1; | ||
/* TODO: CREATE TABLE films2 AS SELECT * FROM films; */ SELECT 1; | ||
/* TODO: CREATE TEMPORARY TABLE films_recent ON COMMIT DROP AS SELECT * FROM films WHERE date_prod > $1; */ SELECT 1; | ||
CREATE TABLE like_constraint_rename_cache (LIKE constraint_rename_cache INCLUDING ALL); | ||
CREATE TABLE distributors (did int, name varchar(40), UNIQUE (name) WITH (fillfactor=70)) WITH (fillfactor=70); |
412 changes: 412 additions & 0 deletions
412
crates/parser/tests/snapshots/statements/valid/0043@1.snap
Large diffs are not rendered by default.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
crates/parser/tests/snapshots/statements/valid/0043@10.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
--- | ||
source: crates/parser/tests/statement_parser_test.rs | ||
description: CREATE TABLE like_constraint_rename_cache (LIKE constraint_rename_cache INCLUDING ALL); | ||
--- | ||
Parse { | ||
cst: SourceFile@0..87 | ||
CreateStmt@0..87 | ||
Create@0..6 "CREATE" | ||
Whitespace@6..7 " " | ||
Table@7..12 "TABLE" | ||
Whitespace@12..13 " " | ||
RangeVar@13..41 | ||
Ident@13..41 "like_constraint_renam ..." | ||
Whitespace@41..42 " " | ||
Ascii40@42..43 "(" | ||
TableLikeClause@43..85 | ||
Like@43..47 "LIKE" | ||
Whitespace@47..48 " " | ||
RangeVar@48..71 | ||
Ident@48..71 "constraint_rename_cache" | ||
Whitespace@71..72 " " | ||
Including@72..81 "INCLUDING" | ||
Whitespace@81..82 " " | ||
All@82..85 "ALL" | ||
Ascii41@85..86 ")" | ||
Ascii59@86..87 ";" | ||
, | ||
errors: [], | ||
stmts: [ | ||
RawStmt { | ||
stmt: CreateStmt( | ||
CreateStmt { | ||
relation: Some( | ||
RangeVar { | ||
catalogname: "", | ||
schemaname: "", | ||
relname: "like_constraint_rename_cache", | ||
inh: true, | ||
relpersistence: "p", | ||
alias: None, | ||
location: 13, | ||
}, | ||
), | ||
table_elts: [ | ||
Node { | ||
node: Some( | ||
TableLikeClause( | ||
TableLikeClause { | ||
relation: Some( | ||
RangeVar { | ||
catalogname: "", | ||
schemaname: "", | ||
relname: "constraint_rename_cache", | ||
inh: true, | ||
relpersistence: "p", | ||
alias: None, | ||
location: 48, | ||
}, | ||
), | ||
options: 2147483647, | ||
relation_oid: 0, | ||
}, | ||
), | ||
), | ||
}, | ||
], | ||
inh_relations: [], | ||
partbound: None, | ||
partspec: None, | ||
of_typename: None, | ||
constraints: [], | ||
options: [], | ||
oncommit: OncommitNoop, | ||
tablespacename: "", | ||
access_method: "", | ||
if_not_exists: false, | ||
}, | ||
), | ||
range: 0..86, | ||
}, | ||
], | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cvng why is this todo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have at least 3 more PRs based on this one and I was trying to keep it smaller
For now each
TODO
is a failing case with either a parser bug (no panics but produces an incorrect tree) or missing node properties, egTypeName
The next PRs should be smaller reproduction cases