I am using the following query to inner join two tables. The columns I join on, are both of type varchar.
However when I use the following query, it results in Error: NULL result in a Non-Nullable Column
"RAW"."DB_FOO"."table" is a standard table. where EXTERNALID is of type VARCHAR(16777216)
EXTERNALID is NOT DECLARED as a "VARCHAR NOT NULL" in "RAW"."DB_FOO"."table" definition. It is nullable.
"RAW"."DB_BAR"."view" is a view where OPP_ID is of type VARCHAR(16777216)
SELECT
a.EXTERNALID
,c.OPP_ID
FROM
"RAW"."DB_FOO"."table" AS a
JOIN
"RAW"."DB_BAR"."view" AS c
ON
a.EXTERNALID = c.OPP_ID
When I try to explicity cast the type to varchar the query executes/works
SELECT
a.column
,c.column
FROM
"RAW"."DB_FOO"."table" AS a
JOIN
"RAW"."DB_BAR"."view" AS c
ON
a.EXTERNALID::varchar = c.OPP_ID::varchar
I have no idea why is that happening. Any help is greatly appreciated.