sql_clause with UpdateCursor does not honor DISTINCT like SearchCursor does

199
0
12-07-2023 01:57 AM
Clubdebambos
Occasional Contributor III

Using ArcGIS Pro 3.2

Here is the SearchCursor with sql_clause 

 

with arcpy.da.SearchCursor('Buildings', "type", sql_clause=("DISTINCT type", None)) as cursor:
    for row in cursor:
        print(row[0])
office
church
retail
residential
commercial
public

 

 

and the UpdateCursor with sql_clause

 

with arcpy.da.UpdateCursor('Buildings', "type", sql_clause=("DISTINCT type", None)) as cursor:
    for row in cursor:
        print(row[0])

church
commercial
residential
commercial
commercial
commercial
commercial
retail
church
commercial
retail
commercial
retail
...

 

 

UpdateCursor does not honor the DISTINCT sql_clause like the SearchCursor does. Why?

There is an example in the Esri docs

 

with arcpy.da.UpdateCursor(
        in_features, 
        ["OID@", "STREET_NAME"], 
        sql_clause=("DISTINCT STREET_NAME", None)
) as cur:

 

 

~ Mapping my way to retirement
0 Kudos
0 Replies