AnsweredAssumed Answered

SQL query doesn't filter nulls for label expressions?

Question asked by jeff.thomasilm on Oct 17, 2019
Latest reply on Oct 17, 2019 by jeff.thomasilm

I'm trying to split a string and label only a particular part of it. (I'm using Python because Arcade doesn't seem to have sufficient capability to specify which part of the string I want to label, but that's a separate gripe.)

This expression cannot be verified if any nulls are present in the field:

def FindLabel ( [ValMap] ):
  return [ValMap].split("_")[1]

You'll get this error:

But you can get around that by putting an if statement in the expression:

def FindLabel ( [ValMap] ):
  if [ValMap] != None:
    return [ValMap].split("_")[1]

But then I thought, "Wait, I shouldn't have to filter nulls in the expression; that's what the SQL query on the label class is for!" I had already applied this filter to the label class:

SELECT * FROM FeatureClass WHERE ValMap IS NOT NULL

For testing, I applied the same SQL query to the definition query of the layer. Either way, it doesn't prevent the error on the expression. I thought maybe this is a bug in Pro but the same thing happens in ArcMap, which makes it less likely to be a bug(?). So now I just want to understand the mechanics of SQL queries on label classes and layer definitions, and their apparent (non-)effect on label expressions.

Outcomes