AMashenkov commented on code in PR #2105:
URL: https://github.com/apache/ignite-3/pull/2105#discussion_r1217772080
##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/ddl/DdlSqlToCommandConverter.java:
##########
@@ -415,6 +423,41 @@ private DefaultValueDefinition convertDefault(SqlNode
expression, RelDataType re
return DefaultValueDefinition.constant(val);
}
+ private AlterColumnCommand convertAlterColumn(IgniteSqlAlterColumn
alterColumnNode, PlanningContext ctx) {
+ AlterColumnCommand cmd = new AlterColumnCommand();
+
+ cmd.schemaName(deriveSchemaName(alterColumnNode.name(), ctx));
+ cmd.tableName(deriveObjectName(alterColumnNode.name(), ctx, "table
name"));
+ cmd.ifTableExists(alterColumnNode.ifExists());
+ cmd.columnName(alterColumnNode.columnName().getSimple());
+
+ if (alterColumnNode.dataType() != null) {
+ cmd.type(ctx.planner().convert(alterColumnNode.dataType(), true));
+ }
+
+ if (alterColumnNode.notNull() != null) {
+ cmd.notNull(alterColumnNode.notNull());
+ }
+
+ if (alterColumnNode.expression() != null) {
+ SqlNode expr = alterColumnNode.expression();
+
+ Function<ColumnType, DefaultValue> resolveDfltFunc;
+
+ if (expr instanceof SqlLiteral) {
+ resolveDfltFunc = type ->
DefaultValue.constant(fromLiteral(type, (SqlLiteral) expr));
+ } else if (expr == null) {
Review Comment:
`expr` is always != null here.
Looks like top=level `if (alterColumnNode.expression() != null)` is not
needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]