diff --git a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/ScriptImplementor.java b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/ScriptImplementor.java index e9368ef..6a5e6e8 100644 --- a/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/ScriptImplementor.java +++ b/hoptimator-catalog/src/main/java/com/linkedin/hoptimator/catalog/ScriptImplementor.java @@ -170,7 +170,7 @@ public SqlNode visit(SqlCall call) { * Implements a CREATE TABLE...WITH... DDL statement. * * N.B. the following magic: - * - field 'KEY' is treated as a PRIMARY KEY + * - non-nullable field 'KEY' is treated as a PRIMARY KEY */ class ConnectorImplementor implements ScriptImplementor { private final String database; @@ -192,7 +192,8 @@ public void implement(SqlWriter w) { (new CompoundIdentifierImplementor(database, name)).implement(w); SqlWriter.Frame frame1 = w.startList("(", ")"); (new RowTypeSpecImplementor(rowType)).implement(w); - if (rowType.getField("KEY", true, false) != null) { + RelDataTypeField key = rowType.getField("KEY", true, false); + if (key != null && key.getType().isNullable() == false) { w.sep(","); w.literal("PRIMARY KEY (KEY) NOT ENFORCED"); }