Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pertains to issue #7354.
I noticed that cube() can lead to errors when .SDcols is supplied as an evaluative or callable expression (for example - helpers like patterns() or measure()), since it may be forwarded unevaluated and used before being resolved.
To address this, I updated cube() to handle .SDcols using non-standard evaluation in the following way:
the argument is captured with substitute(), if it is callable then it is resolved via eval_with_cols() prior to being passed to groupingsets().
While testing this change, I encountered cases where applying numeric aggregations through j resulted in errors when non-numeric columns were present in .SD. To address this, j is captured as an expression to check if it references .SD, if it does then .SD is restricted to numeric values thereby avoiding unintended application of numeric aggregations to non-numeric data.
During development, I’m seeing three existing test failures (1378.2, 1378.3, 1750.34). I haven’t added new unit tests yet. I’m happy to add targeted tests if there are specific cases that need to be covered, and would appreciate guidance on whether additional test coverage is expected here. I’d also welcome any help on how best to approach the currently failing tests.