While working with the ChEMBL v36 database I noticed that the DB Query Reader node returns different data for the same column when I use the SQLite dump vs the PostgreSQL version. On SQLite, I see behaviour that looks unexpected and possibly problematic.
Setup:
-
ChEMBL v36 SQLite dump
-
SQLite Connector + DB Query Reader
-
Default type mapping (notably
NUMERIC → String → String)
Column of interest:
-
Table:
activities -
Column:
standard_value(declaredNUMERIC)
From the schema (PRAGMA table_info(activities);), the column is defined as: 6|standard_value|NUMERIC|0||0.
In SQLite itself:
SELECT activity_id, typeof(standard_value), standard_value
FROM activities
WHERE activity_id = 31906;
Returns:
31906 | real | 0.18
So for activity_id = 31906, the value is a REAL 0.18.
In KNIME, DB Query Reader gives different types/values for the same column depending on the query:
Query 1 – standard_value becomes integer, 0.18 → 0
SELECT
activity_id,
standard_value
FROM activities
WHERE
standard_value IS NOT NULL
LIMIT 10000;
In DB Query Reader:
-
standard_valuehas integer type. -
For
activity_id = 31906, value is 0 (truncated), not 0.18.
This seems to ignore the default NUMERIC → String mapping and loses the decimal part.
Query 2 – same column, now string, 0.18 preserved
SELECT
activity_id,
standard_value
FROM activities
WHERE
standard_value IS NOT NULL
AND activity_id = 31906;
In DB Query Reader:
-
standard_valuehas String type. -
For
activity_id = 31906, value is"0.18"(correct).
So, for the same table/column and default mapping, the KNIME type (and value) of standard_value depends on the query: a broad query returns an integer column with 0.18 → 0; a narrow query returns a String "0.18".
I’ve attached a small workflow with these two DB Query Reader nodes to illustrate.
Is this behaviour expected for SQLite NUMERIC columns in DB Query Reader, or is there a recommended way to avoid this other than always using CAST(standard_value AS REAL) in the SQL?
Thanks in advance for any feedback!
Gio
sqlite_type_mapping_problem.knwf (131.3 KB)





