lowka commented on code in PR #2100:
URL: https://github.com/apache/ignite-3/pull/2100#discussion_r1209327227


##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/exec/rel/TableScanNodeExecutionTest.java:
##########
@@ -109,44 +130,24 @@ public void testScanNodeDataPropagation() {
                 ++cnt;
             }
 
-            assertEquals(sizes[i++] * partsWithTerms.size(), cnt);
-        }
-    }
-
-    private static class TestTable extends AbstractPlannerTest.TestTable {
-        private static final Object[] res = {1, "2", 3};
+            assertTrue(internalTable.latch.await(1, TimeUnit.SECONDS), 
"execution timeout. iteration: " + i);

Review Comment:
   This test case had some multithreading issues that are now fixed.



##########
modules/sql-engine/src/test/java/org/apache/ignite/internal/sql/engine/planner/ImplicitCastsTest.java:
##########
@@ -223,7 +216,7 @@ private static Stream<Arguments> joinColumnTypes() {
             } else {
                 return TYPE_FACTORY.createSqlType(t);
             }
-        }).collect(Collectors.toList());
+        }).filter(t -> t.getSqlTypeName() != 
SqlTypeName.FLOAT).collect(Collectors.toList());

Review Comment:
   I should have added a comment but I think you should be aware that 
SqlTypeName.FLOAT type is not supported type - NativeType's ColumnType's Float 
is Calcite's REAL type.



##########
modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/TypeUtils.java:
##########
@@ -483,4 +486,147 @@ public static RelDataType 
native2relationalType(RelDataTypeFactory factory, Nati
                 throw new IllegalStateException("Unexpected native type " + 
nativeType);
         }
     }
+
+    /** Converts a {@link ColumnType} to corresponding {@link RelDataType}.*/
+    public static RelDataType columnTypeToRelType(IgniteTypeFactory 
typeFactory, ColumnType columnType, int precision, int scale) {
+        switch (columnType) {
+            case BOOLEAN:
+                return typeFactory.createSqlType(SqlTypeName.BOOLEAN);
+            case INT8:
+                return typeFactory.createSqlType(SqlTypeName.TINYINT);
+            case INT16:
+                return typeFactory.createSqlType(SqlTypeName.SMALLINT);
+            case INT32:
+                return typeFactory.createSqlType(SqlTypeName.INTEGER);
+            case INT64:
+                return typeFactory.createSqlType(SqlTypeName.BIGINT);
+            case FLOAT:
+                return typeFactory.createSqlType(SqlTypeName.REAL);
+            case DOUBLE:
+                return typeFactory.createSqlType(SqlTypeName.DOUBLE);
+            case DECIMAL:
+                return typeFactory.createSqlType(SqlTypeName.DECIMAL, 
precision, scale);
+            case DATE:
+                return typeFactory.createSqlType(SqlTypeName.DATE);
+            case TIME:
+                return typeFactory.createSqlType(SqlTypeName.TIME, precision);
+            case DATETIME:
+                return typeFactory.createSqlType(SqlTypeName.TIMESTAMP, 
precision);
+            case TIMESTAMP:
+                return 
typeFactory.createSqlType(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE, 
precision);
+            case UUID:
+                return typeFactory.createCustomType(UuidType.NAME);
+            case BITMASK:
+                throw new IllegalArgumentException("Type is not supported: " + 
columnType);
+            case STRING:
+                return typeFactory.createSqlType(SqlTypeName.VARCHAR, 
precision);
+            case BYTE_ARRAY:
+                return typeFactory.createSqlType(SqlTypeName.VARBINARY, 
precision);
+            case PERIOD:
+                SqlIntervalQualifier yearInterval = new SqlIntervalQualifier(
+                        org.apache.calcite.avatica.util.TimeUnit.YEAR, 
org.apache.calcite.avatica.util.TimeUnit.MONTH, SqlParserPos.ZERO);
+                return typeFactory.createSqlIntervalType(yearInterval);
+            case DURATION:
+                SqlIntervalQualifier dayInterval = new SqlIntervalQualifier(
+                        org.apache.calcite.avatica.util.TimeUnit.DAY, 
org.apache.calcite.avatica.util.TimeUnit.HOUR, SqlParserPos.ZERO);
+                return typeFactory.createSqlIntervalType(dayInterval);
+                //fallthrough
+            case NUMBER:
+            case NULL:
+            default:
+                throw new IllegalArgumentException("Type is not supported: " + 
columnType);
+        }
+    }
+
+    /** Converts provides {@link RelDataType} to {@link NativeType}.*/
+    public static NativeType relType2NativeType(RelDataType dataType) {

Review Comment:
   Looks like a similar function exists in IgniteTypeFactory and that function 
should be used instead.



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