TableCompare_management throwing error on 'hidden' native SQL field

837
2
10-29-2012 10:53 PM
ChrisBeaudette
Occasional Contributor
I'm attempting to use arcpy.TableCompare_management and am passing tables that have a SHAPE.STLength() field, since we're using SQL Server Native spatial types.  I include 'SHAPE.STLength()' in my "omit fields list", but it throws the error:


omitFields = ["SHAPE_Length", "SHAPE.len", "SHAPE", "OBJECTID", "SHAPE.STLength()", "STLength__"]
arcpy.TableCompare_management(baseTable, testTable, "OBJECTID", "SCHEMA_ONLY", "", "", omitFields, "CONTINUE_COMPARE", "")
ExecuteError: ERROR 000622: Failed to execute (TableCompare). Parameters are not valid.
ERROR 000800: The value is not a member of OBJECTID | AUTOCAD_LAYER | PIPENO | ASSETNUMBER | SHAPE | SHAPE.len | SHAPE.STLength().
ERROR 000800: The value is not a member of OBJECTID | AUTOCAD_LAYER | PIPENO | ASSETNUMBER | SHAPE | SHAPE.len | SHAPE.STLength().
Failed to execute (TableCompare).


If I run TableCompare in ArcCatalog, the field shows up in the list of available fields to omit, and when I do so it works fine.  If I do an arcpy.ListFields on the feature classes, it correctly shows me the SHAPE.STLength() field:

SHAPE.STLength() is a type of Double with a length of 0


Any thoughts on how I can get arcpy.TableCompare_management to work as I need it to?
Tags (2)
0 Kudos
2 Replies
ArkadiuszMatoszka
Occasional Contributor II
Hi,
Never have this problem, but usually in cases like this I put tool to model builder and then export to python.
Then copy this to your script and make cosmetics 😉
Cheers
Arek
0 Kudos
ChrisBeaudette
Occasional Contributor
Excellent!  Should've thought of that.

Got it working.  Turns out defining the fields to omit as a semi-colon-separated string instead of a list worked for me.  I.e this didn't work:

omitFields = ["SHAPE_Length", "SHAPE.len", "SHAPE", "OBJECTID", "SHAPE.STLength()"]

And this worked:

"OBJECTID;SHAPE;SHAPE.STLength();SHAPE.len"

What's more (and probably more relevant) is that the fields in the list of fields to omit must actually be in one of the feature classes being compared, i.e. you can't throw a bunch of fields in the omit list "just in case" they're in the feature classes.  If you include a field that's not in one of the feature classes, you get the "ERROR 000800".

So still not sure how/if this will work effectively if I throw a bunch of feature classes at it that have native SQL Server geometry types, since having that seems to create many oddly-named fields.
0 Kudos