Skip to content

Commit 3481fdf

Browse files
committed
The Babel parser can supply null for column strategies
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
1 parent 1fea942 commit 3481fdf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

core/src/main/java/org/apache/calcite/sql/ddl/SqlColumnDeclaration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class SqlColumnDeclaration extends SqlCall {
5858
public final SqlIdentifier name;
5959
public final SqlDataTypeSpec dataType;
6060
public final @Nullable SqlNode expression;
61+
// The Babel parser can supply null for the strategy
6162
public final @Nullable ColumnStrategy strategy;
6263

6364
/** Creates a SqlColumnDeclaration; use {@link SqlDdlNodes#column}. */

server/src/main/java/org/apache/calcite/server/ServerDdlExecutor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,12 @@ public void execute(SqlCreateTable create,
519519
if (d.strategy != ColumnStrategy.VIRTUAL) {
520520
storedBuilder.add(d.name.getSimple(), type);
521521
}
522-
b.add(ColumnDef.of(d.expression, type, d.strategy));
522+
final ColumnStrategy strategy = d.strategy != null
523+
? d.strategy
524+
: type.isNullable()
525+
? ColumnStrategy.NULLABLE
526+
: ColumnStrategy.NOT_NULLABLE;
527+
b.add(ColumnDef.of(d.expression, type, strategy));
523528
} else if (c.e instanceof SqlIdentifier) {
524529
final SqlIdentifier id = (SqlIdentifier) c.e;
525530
if (queryRowType == null) {

0 commit comments

Comments
 (0)