Open
Conversation
|
|
8c6a963 to
394942d
Compare
This commit adds support for the Substrait `SortRel` relation in the MLIR dialect (substrait-io#116). Key Changes: - **Operations**: Added `substrait.sort` and `substrait.sort_field_compare` operations to `SubstraitOps.td`. - **Enums**: Added `SortFieldComparisonType` to `SubstraitEnums.td` to represent standard sort directions (e.g., `ASC_NULLS_FIRST`, `DESC_NULLS_LAST`). - **Import Logic**: Implemented `importSortRel` in `Import.cpp`. This uses a temporary dummy region to instantiate the sort expression once, which is then cloned using `IRMapping` to populate the comparison block for both the LHS and RHS rows. - **Export Logic**: Implemented `exportOperation` for `SortOp` in `Export.cpp` to generate the corresponding `SortRel` protobuf message. - **Verification**: Added `SortOp::verifyRegions` to ensure the sort region is well-formed (blocks take two arguments and yield `si8`). Supported Features: - All standard sort directions defined in the Substrait specification (`ASC_NULLS_FIRST`, `ASC_NULLS_LAST`, `DESC_NULLS_FIRST`, `DESC_NULLS_LAST`, `CLUSTERED`). - Sorting by arbitrary expressions supported by the dialect (field references, literals, etc.). Limitations: - **Custom Comparison Functions**: `comparison_function_reference` in `SortField` is not yet supported. The import process will emit an error if this field is set. Tests: - Added `test/Target/SubstraitPB/Import/sort.textpb` - Added `test/Target/SubstraitPB/Export/sort.mlir`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit adds support for the Substrait
SortRelrelation in the MLIR dialect.Key Changes:
substrait.sortandsubstrait.sort_field_compareoperations toSubstraitOps.td.SortFieldComparisonTypetoSubstraitEnums.tdto represent standard sort directions (e.g.,ASC_NULLS_FIRST,DESC_NULLS_LAST).importSortRelinImport.cpp. This uses a temporary dummy region to instantiate the sort expression once, which is then cloned usingIRMappingto populate the comparison block for both the LHS and RHS rows.exportOperationforSortOpinExport.cppto generate the correspondingSortRelprotobuf message.SortOp::verifyRegionsto ensure the sort region is well-formed (blocks take two arguments and yieldsi8).Supported Features:
ASC_NULLS_FIRST,ASC_NULLS_LAST,DESC_NULLS_FIRST,DESC_NULLS_LAST,CLUSTERED).Limitations:
comparison_function_referenceinSortFieldis not yet supported. The import process will emit an error if this field is set.Tests:
test/Target/SubstraitPB/Import/sort.textpbtest/Target/SubstraitPB/Export/sort.mlir