Skip to content

Commit

Permalink
Support PRIMARY_KEY magic field
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannedolan committed Jul 10, 2024
1 parent 1c869a4 commit a73cff5
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public SqlNode visit(SqlCall call) {

/**
* Implements a CREATE TABLE...WITH... DDL statement.
*
* N.B. the following magic:
* - field 'PRIMARY_KEY' is treated as a PRIMARY KEY
*/
class ConnectorImplementor implements ScriptImplementor {
private final String database;
Expand All @@ -189,8 +192,11 @@ public void implement(SqlWriter w) {
(new CompoundIdentifierImplementor(database, name)).implement(w);
SqlWriter.Frame frame1 = w.startList("(", ")");
(new RowTypeSpecImplementor(rowType)).implement(w);
if (rowType.getField("PRIMARY_KEY", true, false) != null) {
w.sep(",");
w.literal("PRIMARY KEY (PRIMARY_KEY) NOT ENFORCED");
}
w.endList(frame1);
// TODO support PRIMARY KEY for Tables that support it
// TODO support PARTITIONED BY for Tables that support it
w.keyword("WITH");
SqlWriter.Frame frame2 = w.startList("(", ")");
Expand Down

0 comments on commit a73cff5

Please # to comment.