)]}'
{
  "commit": "1c3232ce2262523fb4043e7264185b2f8f929b0d",
  "tree": "04485375ee151fcf2c6e039bca5c41671f47783b",
  "parents": [
    "e8a65f2d6f24afa75192fc63aca38011ede88800"
  ],
  "author": {
    "name": "Raz Luvaton",
    "email": "16746759+rluvaton@users.noreply.github.com",
    "time": "Mon Jul 27 16:14:54 2026 +0300"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Mon Jul 27 13:14:54 2026 +0000"
  },
  "message": "`ScalarUdfImpl::strictly_order_preserving`: Allow expression to report whether they keep the same ordering of the input (#23807)\n\n## Which issue does this PR close?\n\n- Closes #23798\n\nRelated to:\n- #16217\n\n## Rationale for this change\n\nTo be able to keep the same sorting order allowing for more\noptimizations\n\nNow comet own `cast` implementation can be recognized as not modifying\nsort order in the same cases that datafusion cast does.\n\n## What changes are included in this PR?\nadded `strictly_order_preserving` property to `ExprProperties` + varius\nother places\nand replaced the hard coded logic for cast (`substitute_cast_ordering`)\nabout keeping input order with more generic approach that now any\nexpression can implement and have the same advantage of sort elimination\n\nalso marked from_unixtime as keeping ordering to show a case of this\noptimization\n\n## Are these changes tested?\nyes\n\n## Are there any user-facing changes?\nyes, breaking change, added `strictly_order_preserving` property to\n`ExprProperties` and to `FFI_ExprProperties`\n\n\nthis property means that given expression `f` and 2 values from the\ninput column `a` and `b` the following variants are kept:\n1. `a.cmp(b) \u003d\u003d f(a).cmp(f(b))`\n2. nulls maps to nulls\n\nExample of satisfying expression: \n`cast(col_a as BIGINT)` where `col_a` is `INT` it is keeping the\nproperties\n\nExample of not satisfying:\n\n`floor` - floor can not\n\n`array_repeat(my_col, 2)` which might look like at first glance as\nkeeping the property as well but in fact it does not.\n\nthe reason is that `array_repeat(null, 2)` will output list of 2 nulls\nwhich breaks the 2nd property that nulls must be kept as nulls\n\n\nhow to migrate:\n\nOption 1 - keeping the old behavior (safest but least performant)\nset `strictly_order_preserving` to false\n\nOption 2 - Using the new optimization that this opens up:\nset `strictly_order_preserving` only if the expression keep both\nvariants",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "9338fcc0bce3531f67d8f8d56cfd2f7b765dad6b",
      "old_mode": 33188,
      "old_path": "datafusion/core/tests/physical_optimizer/enforce_sorting.rs",
      "new_id": "d94253a84aa5fd874c1e75bcfc2a2ed0f8efc922",
      "new_mode": 33188,
      "new_path": "datafusion/core/tests/physical_optimizer/enforce_sorting.rs"
    },
    {
      "type": "modify",
      "old_id": "04da574882d306157057961f262529544a2b5a34",
      "old_mode": 33188,
      "old_path": "datafusion/expr-common/src/sort_properties.rs",
      "new_id": "74d644f79faef3cc4b2fa8e2507bb5100ca5cab0",
      "new_mode": 33188,
      "new_path": "datafusion/expr-common/src/sort_properties.rs"
    },
    {
      "type": "modify",
      "old_id": "4c51ff46f7365b11c1d32dcc7140120732244bd5",
      "old_mode": 33188,
      "old_path": "datafusion/expr/src/udf.rs",
      "new_id": "2de3be4c10fa42232270f0ae2590fc2a56efdff4",
      "new_mode": 33188,
      "new_path": "datafusion/expr/src/udf.rs"
    },
    {
      "type": "modify",
      "old_id": "5b37cc6a2853546469a09655e900b7283c49e396",
      "old_mode": 33188,
      "old_path": "datafusion/ffi/src/expr/expr_properties.rs",
      "new_id": "584f774c7b26e41cb095485d4bc1b00237c673c8",
      "new_mode": 33188,
      "new_path": "datafusion/ffi/src/expr/expr_properties.rs"
    },
    {
      "type": "modify",
      "old_id": "4787c75b610b66c796020e34fa884a21cf730233",
      "old_mode": 33188,
      "old_path": "datafusion/functions/src/datetime/from_unixtime.rs",
      "new_id": "85494f3abff73ca6d709f9eff3b2afb472be3ea2",
      "new_mode": 33188,
      "new_path": "datafusion/functions/src/datetime/from_unixtime.rs"
    },
    {
      "type": "modify",
      "old_id": "52449f9c9e0b9d336ca45fb4657b317c70b594db",
      "old_mode": 33188,
      "old_path": "datafusion/functions/src/math/monotonicity.rs",
      "new_id": "d1174d77b9db167e862b154e58a0f3435c728a3c",
      "new_mode": 33188,
      "new_path": "datafusion/functions/src/math/monotonicity.rs"
    },
    {
      "type": "modify",
      "old_id": "2ce8a8d246fe7febadf5e5f80d7abec3372c043c",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/equivalence/ordering.rs",
      "new_id": "15637d24e8a4b1b94471a4577ce3f103bb128bc4",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/equivalence/ordering.rs"
    },
    {
      "type": "modify",
      "old_id": "17c3898fd9c89a92f4950b9808b6e9cd087dffde",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/equivalence/properties/mod.rs",
      "new_id": "22b3382f506389093d9c591f3078161439a7fc88",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/equivalence/properties/mod.rs"
    },
    {
      "type": "modify",
      "old_id": "89828620a5930af3ea5ecf0591d1ffea2550cd48",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/expressions/binary.rs",
      "new_id": "8b71b3ec409c72770f35192821c244477f3dfae5",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/expressions/binary.rs"
    },
    {
      "type": "modify",
      "old_id": "8be2e187d72f77b3cc787e3773cd8e87dc5101a4",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/expressions/cast.rs",
      "new_id": "dbb91e365af90350da8263284dd39a36f86bded3",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/expressions/cast.rs"
    },
    {
      "type": "modify",
      "old_id": "5fb9a3b2cd29bb78c0f3b08d43338d4213de03f0",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/expressions/literal.rs",
      "new_id": "a7af824230780a0ad00b120eb0890d29442ac2e7",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/expressions/literal.rs"
    },
    {
      "type": "modify",
      "old_id": "9fbf38361c89ca0f599395f0c3627f68e06a181d",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/expressions/negative.rs",
      "new_id": "c894c12784dc553c8b06de6adbcf6cb6d6561fda",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/expressions/negative.rs"
    },
    {
      "type": "modify",
      "old_id": "418d005c971eaafeab830186cfc9ac8b81649622",
      "old_mode": 33188,
      "old_path": "datafusion/physical-expr/src/scalar_function.rs",
      "new_id": "6a5ab219aa8dd86b4d534565bd78e8b9e7efa648",
      "new_mode": 33188,
      "new_path": "datafusion/physical-expr/src/scalar_function.rs"
    },
    {
      "type": "modify",
      "old_id": "978fcc197c0deea771698ebe7fc52a2c1a38604f",
      "old_mode": 33188,
      "old_path": "datafusion/sqllogictest/test_files/order.slt",
      "new_id": "a267ddddddd5464a9ac10a9a8dd69b9929d1987d",
      "new_mode": 33188,
      "new_path": "datafusion/sqllogictest/test_files/order.slt"
    }
  ]
}
