Many data functions you want triggered from markings. However, when nothing is marked, empty inputs are sent to the DF which causes errors. So you have to create specific error handling code for TERR to detect # rows for input and send out empty data.frames if there are 0 rows. In R, this can often require wrapping large blocks of code with if-statements.
This isn't really how one typically scripts in R, Python, etc natively since when you run a script outside Spotfire, you already have your data loaded, not empty inputs. It's the Spotfire paradigm of marking that requires empty data.frames to come out as outputs, but the coding itself could be much more simplified if Spotfire just knew not to execute the DF at all if no rows were marked. This would make it easier to copy/paste code from RStudio, etc into Spotfire directly.
I think the ideal situation would be to have a drop down option in the data function configuration on how the data function behaves with the marking, much like is present on visuals e.g.
If no data is marked either:
Pass all data
Do not run data function
Raise warning/error (much like display message for a visual)
We often have scenarios where we want the whole dataset to be passed when no marking is present so I think this would be a useful option as well as do nothing, and raise an error.
I am not sure we want the function not to throw an error when the user fails to select or mark for the definition of the inputs.
I have struggle with this myself, I feel you need the function to throw an error, or perhaps a warning, if the inputs are not been passed to the data function. The way we have worked around this issue is to use document controls to trigger the data function to run. In my mind, the problem is running the function automatically instead of letting the user decide when to run the function.
I agree that when you execute a data function on empty you don't really want an output
It would be useful in general not to execute data functions with empty inputs. I sometimes have this situation without limiting by marking. If you use on-demand data, it sometimes happens that a data table is empty. If it is an input to a data function, this has to be captured also.
Perhaps one could make this an option: "Do not execute DF when one of the inputs is empty".
As there can be multiple inputs to DFs and it might make sense that the DF is executed when an input is empty but others are not, it might be necessary to have an option per input. "Do not execute DF when THIS input is empty".