tledkov-gridgain commented on a change in pull request #484:
URL: https://github.com/apache/ignite-3/pull/484#discussion_r761904821



##########
File path: 
modules/calcite/src/main/java/org/apache/ignite/internal/processors/query/calcite/prepare/ddl/DdlSqlToCommandConverter.java
##########
@@ -138,77 +134,147 @@ public DdlCommand convert(SqlDdl ddlNode, 
PlanningContext ctx) {
      */
     private CreateTableCommand convertCreateTable(IgniteSqlCreateTable 
createTblNode, PlanningContext ctx) {
         CreateTableCommand createTblCmd = new CreateTableCommand();
-
+        
         createTblCmd.schemaName(deriveSchemaName(createTblNode.name(), ctx));
         createTblCmd.tableName(deriveObjectName(createTblNode.name(), ctx, 
"tableName"));
         createTblCmd.ifNotExists(createTblNode.ifNotExists());
-
+        
         if (createTblNode.createOptionList() != null) {
             for (SqlNode optNode : createTblNode.createOptionList().getList()) 
{
                 IgniteSqlCreateTableOption opt = (IgniteSqlCreateTableOption) 
optNode;
-
+                
                 tblOptionProcessors.getOrDefault(opt.key(), 
UNSUPPORTED_OPTION_PROCESSOR).process(opt, ctx, createTblCmd);
             }
         }
-
+        
         List<SqlColumnDeclaration> colDeclarations = 
createTblNode.columnList().getList().stream()
                 .filter(SqlColumnDeclaration.class::isInstance)
                 .map(SqlColumnDeclaration.class::cast)
                 .collect(Collectors.toList());
-
+        
         IgnitePlanner planner = ctx.planner();
-
-        List<ColumnDefinition> cols = new ArrayList<>();
-
+        IgniteTypeFactory typeFactory = ctx.typeFactory();
+        
+        List<ColumnDefinition> cols = new ArrayList<>(colDeclarations.size());
+        
         for (SqlColumnDeclaration col : colDeclarations) {
             if (!col.name.isSimple()) {
                 throw new IgniteException("Unexpected value of columnName ["
                         + "expected a simple identifier, but was " + col.name 
+ "; "
-                        + "querySql=\"" + ctx.query() + "\"]"/*, 
IgniteQueryErrorCode.PARSING*/);
+                        + "querySql=\"" + ctx.query() + "\"]");
             }
-
+            
             String name = col.name.getSimple();
-            RelDataType type = planner.convert(col.dataType);
-
+            RelDataType relType = planner.convert(col.dataType);
+            
             Object dflt = null;
             if (col.expression != null) {
                 dflt = ((SqlLiteral) col.expression).getValue();
             }
-
-            cols.add(new ColumnDefinition(name, type, dflt));
+            
+            ColumnDefinitionBuilder col0 = SchemaBuilders.column(name, 
typeFactory.columnType(relType));

Review comment:
       ```suggestion
               ColumnDefinitionBuilder col0 = SchemaBuilders.column(name, 
typeFactory.columnType(relType))
                       .asNullable(relType.isNullable())
                       .withDefaultValueExpression(dflt);
   ```




-- 
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]


Reply via email to