# Null, -2147483648 or what am I doing wrong?

**URL:** <https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807>\
**Category:** Community\
**Created:** [April 14, 2025, 11:40am UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807 "2025-04-14T11:40:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BepTheWolf](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/bepthewolf/32/377_2.png) [@BepTheWolf](https://community.questdb.com/u/BepTheWolf)\
**Post date:** [April 14, 2025, 11:40am UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/1 "2025-04-14T11:40:14Z")

</div>

Hi, I have a question:

I make a table:  
CREATE TABLE ‘MyTab’ (  
index\_time TIMESTAMP,  
ColA DOUBLE NULL,  
ColB DOUBLE NULL,  
ColC DOUBLE NULL,  
ColD DOUBLE NULL  
) timestamp(index\_time) PARTITION BY DAY WAL  
DEDUP UPSERT KEYS(index\_time);index\_time;

I run this query:  
INSERT INTO MyTab (index\_time, ColA, ColB, ColC, ColD)  
SELECT ‘2025-04-09 17:20:00.000’ as “index\_time”, 100 as “ColA”, null as ColB, 102 as “ColC”, 103 as “ColD”;  
I get this result:  
2025-04-09T17:20:00.000000Z, 100, null, 102, 103.

TRUNCATE TABLE MyTab;

I run this query:  
WITH MyTmp AS (  
SELECT ‘2025-04-09 17:20:00.000’ as “index\_time”, 100 as “ColA”, null as ColB, 102 as “ColC”, 103 as “ColD”  
)  
INSERT INTO MyTab (“index\_time”, “ColA”, “ColB”, “ColC”, “ColD”)  
select “index\_time”, “ColA”, “ColB”, “ColC”, “ColD” from MyTmp limit 1;  
I get this result:  
2025-04-09T17:20:00.000000Z, 100, null, 102, 103.

TRUNCATE TABLE MyTab;

I run this query:  
WITH MyTmp AS (  
SELECT ‘2025-04-09 17:20:00.000’ as “index\_time”, 100 as “ColA”, 101 as “ColB”, 102 as “ColC”, 103 as “ColD” FROM MyTab WHERE index\_time = ‘2025-04-09 17:20:00.000’  
UNION  
SELECT ‘2025-04-09 17:20:00.000’ as “index\_time”, 100 as “ColA”, null as ColB, 102 as “ColC”, 103 as “ColD”  
)  
INSERT INTO MyTab (“index\_time”, “ColA”, “ColB”, “ColC”, “ColD”)  
select “index\_time”, “ColA”, “ColB”, “ColC”, “ColD” from MyTmp limit 1;  
I get this result:  
2025-04-09T17:20:00.000000Z, 100, -2147483648, 102, 103.

I find -2147483648 instead of null.

Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![nwoolmer](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/nwoolmer/32/24_2.png) [@nwoolmer](https://community.questdb.com/u/nwoolmer)\
**Post date:** [April 14, 2025, 11:55am UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/2 "2025-04-14T11:55:02Z")

</div>

Hi @BepTheWolf ,

Thanks for the report! I was able to reproduce this, it looks like a potential bug converting from the null `LONG` to a `DOUBLE`. Let me look into it!

---

<div class="post-metadata">

**Author:** ![nwoolmer](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/nwoolmer/32/24_2.png) [@nwoolmer](https://community.questdb.com/u/nwoolmer)\
**Post date:** [April 14, 2025, 11:56am UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/3 "2025-04-14T11:56:52Z")

</div>

Are you on Windows, by any chance?

---

<div class="post-metadata">

**Author:** ![BepTheWolf](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/bepthewolf/32/377_2.png) [@BepTheWolf](https://community.questdb.com/u/BepTheWolf)\
**Post date:** [April 14, 2025, 12:17pm UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/4 "2025-04-14T12:17:29Z")

</div>

Hi, no I’m on Mac OS

---

<div class="post-metadata">

**Author:** ![nwoolmer](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/nwoolmer/32/24_2.png) [@nwoolmer](https://community.questdb.com/u/nwoolmer)\
**Post date:** [April 14, 2025, 12:35pm UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/5 "2025-04-14T12:35:04Z")

</div>

Cool, I have confirmed this as two bugs.

1. When the `INT` is copied into the table’s `DOUBLE` column, the conversion is not null-aware. We use `-2147483648` to denote a null int, and `NaN` for a null double. So you are seeing the result of a direct conversion without checking for nulls.

~~2. On the first insert, you see the value at all, when it should be `101`. Indeed you see the `101` if you try the insert again. So there is an issue with how the `UNION` is handled.~~

In the meantime, if you change your code to perform a double conversion i.e.

```auto
101::double
null::double

```

It will work as expected 🙂

---

<div class="post-metadata">

**Author:** ![BepTheWolf](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.questdb.com/bepthewolf/32/377_2.png) [@BepTheWolf](https://community.questdb.com/u/BepTheWolf)\
**Post date:** [April 14, 2025, 3:25pm UTC](https://community.questdb.com/t/null-2147483648-or-what-am-i-doing-wrong/807/6 "2025-04-14T15:25:11Z")

</div>

Great.  
Thanks a lot 🙂
