|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +from pathlib import Path |
| 19 | + |
| 20 | +PARITY_GROUPS = [ |
| 21 | + ( |
| 22 | + "MergeRows serializer", |
| 23 | + [ |
| 24 | + Path("spark/src/main/spark-3.5/org/apache/comet/serde/operator/CometMergeRows.scala"), |
| 25 | + Path("spark/src/main/spark-4.0/org/apache/comet/serde/operator/CometMergeRows.scala"), |
| 26 | + ], |
| 27 | + "Spark 3.5 and 4.0 intentionally share the same MergeRows serialization contract.", |
| 28 | + ), |
| 29 | + ( |
| 30 | + "MergeRows registration shim", |
| 31 | + [ |
| 32 | + Path("spark/src/main/spark-3.5/org/apache/comet/shims/ShimCometMergeRows.scala"), |
| 33 | + Path("spark/src/main/spark-4.0/org/apache/comet/shims/ShimCometMergeRows.scala"), |
| 34 | + ], |
| 35 | + "Spark 3.5 and 4.0 intentionally register MergeRows through identical shims.", |
| 36 | + ), |
| 37 | + ( |
| 38 | + "MergeRows metrics shim without semantic counters", |
| 39 | + [ |
| 40 | + Path("spark/src/main/spark-3.x/org/apache/comet/shims/MergeRowsMetricsShim.scala"), |
| 41 | + Path("spark/src/main/spark-4.0/org/apache/comet/shims/MergeRowsMetricsShim.scala"), |
| 42 | + ], |
| 43 | + "Spark 3.x and 4.0 do not publish semantic MergeRows counters.", |
| 44 | + ), |
| 45 | +] |
| 46 | + |
| 47 | + |
| 48 | +def main() -> int: |
| 49 | + failed = False |
| 50 | + for name, paths, reason in PARITY_GROUPS: |
| 51 | + reference = paths[0].read_bytes() |
| 52 | + for path in paths[1:]: |
| 53 | + if path.read_bytes() != reference: |
| 54 | + failed = True |
| 55 | + print(f"{name} files must remain byte-identical.") |
| 56 | + print(f"Reason: {reason}") |
| 57 | + print(f"Reference: {paths[0]}") |
| 58 | + print(f"Different: {path}") |
| 59 | + if failed: |
| 60 | + return 1 |
| 61 | + |
| 62 | + print("Versioned source parity checks passed.") |
| 63 | + return 0 |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + raise SystemExit(main()) |
0 commit comments