Previously, the code threw the error saying it could not identify the index in the function code, but this error is actually predictable. Anytime we can't find the index we want to tell the user know that that is the problem and let them know to use index-by to clarify the confusion.
The API for the indexing tools seemed unnecessarily complex.
Proposed Solution
This PR adds a new function get-index-column-or-error that in many cases may be all that we need to import for an index-aware function. This function will return the index column, or if it cannot figure out which one is the time index, it will throw a standard error that asks the user to use index-by to specify the index.
I also added a sibling fn get-index-column-name-or-error, that may be useful when we only need to know the index column name.
@rsiddharthan Thank you for taking a look at this! 🙏 There's a follow-on PR that changes the API for adjust-interval a bit, and bringing it inline with what we have in slice and rolling-window.
Goal / Problem
Two different problems here:
index-by
to clarify the confusion.Proposed Solution
This PR adds a new function
get-index-column-or-error
that in many cases may be all that we need to import for an index-aware function. This function will return the index column, or if it cannot figure out which one is the time index, it will throw a standard error that asks the user to useindex-by
to specify the index.I also added a sibling fn
get-index-column-name-or-error
, that may be useful when we only need to know the index column name.