Any idea what can be wrong with the query below? I...
# suiteql
s
Any idea what can be wrong with the query below? I want to extract all entities but mask Employee data. However
type
filter does now work at all. It always returns the
entityid
Copy code
SELECT 
  E.type, 
  E.id,
  E.isinactive,
  CASE WHEN E.type = 'Employee' THEN 'Masked' ELSE E.entityid END AS "Name"
FROM entity E
t
@Selcuk Dogru Try using the BUILTIN.DF function, like this:
Copy code
SELECT
  E.type, 
  E.id,
  E.isinactive,
  CASE WHEN BUILTIN.DF( E.type ) = 'Employee' THEN 'Masked' ELSE E.entityid END AS "Name"
FROM entity E
s
thanks @tdietrich, that was the trick
but I don’t get it as the column type is VARCHAR.
t
It's confusing, I know. But I think that behind the scenes the entity type is actually stored internally as an integer. The BUILTIN.DF function does the translation. Where it gets confusing is that we don't seem to be able to see the entity type value as an integer. In other words, I think SuiteQL is automatically handling the conversion from the numeric to varchar value.
s
well, at the end what we see is the DB views, we can assume many things 🙂
t
Agreed. There's a level of abstraction that SuiteQL imposes, and it isn't always apparent that this is happening. It would be nice to get to the raw data - and to be able to create our own views as well.