Hi everyone,
I am creating a JS KNIME node and found out this bug when trying to deserialize a table from JSON. My custom node is similar to the Javascript Table View but is deserializing the table as well.
When serializing, the JSONDataTableSpec constructor in the line 195 is saving the names of the column types (not the actual enum values).
if (!Arrays.asList(excludeColumns).contains(colName)) { colNames.add(colName); orgTypes.add(spec.getColumnSpec(i).getType().getName()); DataType colType = spec.getColumnSpec(i).getType(); colTypes.add(getJSONType(colType).name); numColumns++; }
Yet later when I tried to deserialize the JSONDataTable to a regular BufferedDataTable with the method JSONDataTable#createBufferedDataTable, the JSONDataTableSpec#createDataTableSpec in the line 215 is trying to get the enum values from the name properties of the enum JSTypes instead of the actual string representation.
for (int i = 0; i < m_numColumns; i++) { JSTypes type = JSTypes.valueOf(m_colTypes.get(i)); DataType dataType = null; switch (type) { case BOOLEAN:
The JSTypes enum is using uppercase for its values and lowercase for its name property. For example I cannot access with a "boolean" column type a column of type JSType.BOOLEAN. The valueOf is failing here.
BOOLEAN("boolean"), NUMBER("number"), STRING("string"), /** @since 2.10 */ PNG("png"), /** @since 2.10 */ SVG("svg"), /** @since 2.11 */ DATE_TIME("dateTime"), UNDEFINED("undefined");
As a result deserializing a toy table with string columns produces this exception.
ERROR JavaScript Editable Table 0:77 Execute failed: No enum constant org.knime.js.core.JSONDataTableSpec.JSTypes.string
Best regards and happy coding,
Miguel