We should support specifying sorted_by argument when calling rewrite_ data_files procedure. It's especially useful when the table itself is not defined as a sorted table, or its sorting property is somewhat insufficient. This significantly optimizes scanning performance by allowing more irrelevant data files to be filtered out.
Expected Behavior or Use Case
The specified sorting definition must be compatible with the table's own sorting property, if one exists.
Presto Component, Service, or Connector
Procedure, Iceberg
Possible Implementation
Use the same syntax that is used to specify the sorting property when creating a table.