arcpy.env.qualifiedFieldNames = False not working when using arcpy.AddJoin_management

379
3
12-07-2017 06:16 AM
MaximeDemers
Occasional Contributor III

I would like to add a join on a layer while keeping the original fields names, so I thought setting the qualifiedFieldNames  environment parameter to False would do the job, as the documentation says, but it has no effect.

import arcpy, os
arcpy.env.qualifiedFieldNames = False

input_fc = os.path.join("C:\\", "temp", "GEODEV.sde", "dataset", "my_feature_class")
join_table = arcpy.TableToTable_conversion(os.path.join("C:\\", "temp", "to_join.csv"), "in_memory", "join_table")
layer = arcpy.MakeFeatureLayer_management(input_fc, "in_memory\\layer")
arcpy.AddJoin_management(layer, "MY_IN_FIELD", join_table, "MY_JOIN_FIELD")‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

print([f.name for f in arcpy.ListFields(layer)])

>>>'["GEODEV.dataset.field1", "GEODEV.dataset.field2", "GEODEV.dataset.field3", "join_table.fieldA", "join_table.fieldB", "join_table.fieldC"]'‍‍‍‍‍‍‍‍‍‍‍

What am I doing wrong?

Thank you for your help!

0 Kudos
3 Replies
DanPatterson_Retired
MVP Esteemed Contributor

either the sde source... that you are using in_memory... you might need to SaveToLayer before the join

MaximeDemers
Occasional Contributor III

I suppose there is no other solution?

I dont want to save anything to the disk as it's a part of a Geoprocessing Service that output some json string only.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Maxime, I am just trying to see what made it work.  in_memory is a tad over-rated since you can simply add Delete_management to the workflow to remove what you don't want to persist on disk.  Local is best, in any event, there are more sde and in_memory 'issues' on geonet... only rivaled by projection issues