Select to view content in your preferred language

Arcade: Add Function to Join Featuresets

1296
2
05-17-2023 12:54 PM
Status: Open
JohannesLindner
MVP Frequent Contributor

Joining two Featuresets in Arcade is frickly. You have to manually create a new featureset, iterate through the input fs, Filter() the corresponding Feature from the join fs, and copy all attributes from both Featuresets.

This is not only a lot of code for a simple operation, but using Filter() in a loop massively impacts performance, so either you write even more code to load the Featuresets into RAM (until it is hopefully added into native Arcade functionality) or your expression is really slow.

Joining Featuresets is one of the most basic database/GIS operations and really should be a native function.

Especially now, as Arcade gains popularity. I answered multiple questions about joining fields in the last weeks. The current way to do it is absolutely not suited for new or inexperience users. And lacking such basic functionality really isn't a great look for a language focused on data manipulation.

 

I envision something like this:

var in_fs = FeaturesetByPortalItem(...)
var join_fs = FeaturesetByPortalItem(...)

# option 1: single field key, join all fields
var joined_fs = Join(in_fs, "PrimaryKey", join_fs, "ForeignKey")

# option 2: multiple fields key, select fields to join
var joined_fs = Join(in_fs, ["PrimaryKey1", "PrimaryKey2"], join_fs, ["ForeignKey1", "ForeignKey2"], ["JoinField1", "JoinField2", "JoinField3"])

 

So the signature would be something like this

Join(inFS, primaryKeys, joinFS, foreignKeys, joinFields=["*"])

 

Tags (1)
2 Comments
jtmouw_NCDOT

This is a great suggestion and it is frustrating that such a basic database functionality is not already built-in.

Speaking as someone who hosts lots of services with related 'assessment' type tables, a frequent need is to have "Feature Record +  Most Recent Assessment Record" as a single line item and trying to do the filter loop for large datasets absolutely crushes the performance of dashboards etc.

Vinzafy

Full support for this idea! Though the argument exists that simpler use cases of a single join can be achieved though a joined view layer, this isn't always possible and having a joined view layer locks the schema of a hosted feature layer. If you need to add a field down the road, that means you have to remove the joined view layer to add the field. If that joined view layer is implemented across your org in various locations... Big issues!

In more complex use cases of joining multiple tables, the only way to achieve this is programmatically. As mentioned, running a script that uses filter in a loop makes scripts incredibly inefficient and results in hundreds to thousands of requests to the servers.

Having a built in function that joins FeatureSets would be incredibly helpful not only to users, but also on servers as it would prevent an unnecessarily high number of server requests contained within a single script.