dongjoon-hyun commented on code in PR #60670:
URL: https://github.com/apache/spark/pull/60670#discussion_r4619829558
##########
AGENTS.md:
##########
@@ -53,8 +58,8 @@ Before the first code edit or running test in a session,
ensure a clean working
- Keep source lines within 100 characters; the linters enforce this for Scala,
Java, and Python.
Avoid non-ASCII characters in code and comments (string literals may contain
them when the
- content requires it). Before committing Scala, Java or Python changes: run
the spot-checks in
- `.agents/code-conventions.md`.
+ content requires it). When changing Scala, Java or Python code: read
Review Comment:
**[1] The license header rule is reachable only from the Scala, Java or
Python pointer.**
`dev/check-license` runs Apache RAT over the whole tree and skips only what
`dev/.rat-excludes` matches, so new `.proto`, `.sh`, `.R`, `.js`, `.css`,
`.yml` and `.properties` files need the header too. An agent that adds one of
those (a proto message, a `dev/` script, a GitHub workflow) never matches "When
changing Scala, Java or Python code", so it never reads
`.agents/code-conventions.md`, and the License test in the Linters job fails.
That is the failure the PR description lists. By the placement rule at the top
of this file ("Keep a rule in `AGENTS.md` ... if an agent could break it
without noticing it is in that situation"), this rule qualifies to stay inline.
A one-line bullet here would cover every file type, for example "Every new file
needs the Apache License header unless `dev/.rat-excludes` matches it; copy it
from a neighboring file of the same type." Adding "or adding a new file" to
this pointer's trigger would also work.
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
Review Comment:
**[3] Files that cannot carry a header need a `dev/.rat-excludes` entry.**
RAT checks every file, not only source files. Test fixtures are the usual
case: `dev/.rat-excludes` lists many of them by name, such as `people.xml`,
`over1k`, `part-00000` and `flights_tiny.txt.1`, because they were added
without a header. The rule says only "source file", so an agent that adds a
fixture, such as an extension-less data file, is not told about this. It either
fails the License test or adds a header that changes the data the test reads.
One more sentence would cover it: "If the file cannot carry a header, such as
test data, add it to `dev/.rat-excludes` instead."
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
+
+Keep public Scala and Java APIs binary compatible; the MiMa check in CI
(`dev/mima`) reports changes that are not. When MiMa flags a change that is
intended, add an exclusion with a `// [SPARK-xxxxx]` comment to the
`vNNexcludes` section of `project/MimaExcludes.scala` for the version the
change first ships in (see `.agents/versioning.md`).
Review Comment:
**[4] The Connect JVM client has its own MiMa check and exclusion list.**
The Linters job also runs `dev/connect-jvm-client-mima-check` (the "Spark
connect jvm client mima check" step in `build_and_test.yml`). It compares the
Connect Scala client jar with the `sql` jar in both directions. A public
`Dataset`, `Column` or `functions` API that is added or changed on one side
only fails it. Its exclusions are in `CheckConnectJvmClientCompatibility.scala`
(`checkMiMaCompatibilityWithSqlModule` and
`checkMiMaCompatibilityWithReversedSqlModule`), not in
`project/MimaExcludes.scala`. Following this rule, an agent adds the filter to
`MimaExcludes.scala`, which has no effect on that check, so CI stays red. Could
the rule name both checks and both files?
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
+ `self.sql_conf` in Python): suites also run in the scheduled Non-ANSI job
+ (`SPARK_ANSI_SQL_MODE=false`), where `spark.sql.ansi.enabled` defaults to
`false`.
+- Never remove a failing test or mock the code under test unless asked;
document why any mock is
+ needed.
Review Comment:
**[11] Nit: where should the reason go, and for which mocks?**
"document why any mock is needed" reads as covering every mock in a touched
suite. Many suites (scheduler, Kubernetes, shuffle) already use Mockito heavily
without such comments, so an agent that edits one of them may add justification
comments to mocks it did not write. Something like "explain each new mock in a
code comment" would say both where and which.
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
+ `self.sql_conf` in Python): suites also run in the scheduled Non-ANSI job
+ (`SPARK_ANSI_SQL_MODE=false`), where `spark.sql.ansi.enabled` defaults to
`false`.
Review Comment:
**[13] A one-line local check would make this rule testable.**
`SPARK_ANSI_SQL_MODE=false build/sbt '<module>/testOnly *MySuite'`
reproduces the Non-ANSI job for one suite in the time of a normal run, and the
`PlanStabilitySuite` doc already uses it. PySpark tests work the same way,
since `pyspark.testing.utils` reads the same variable. Adding "To check, run
the suite with `SPARK_ANSI_SQL_MODE=false`." lets an agent catch an indirect
dependency, such as a cast inside a helper, before pushing rather than after
the scheduled run.
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
Review Comment:
**[2] Executable scripts start with a shebang, not with the header.**
"Every new source file starts with the Apache License header" does not hold
for scripts: 26 tracked `.py` files (for example `dev/agent_docs_lint.py`) and
68 tracked `*.sh`, `bin/` and `sbin/` scripts have `#!/usr/bin/env ...` on line
1 and the header after it. Read literally, the rule puts the header above the
shebang, and `./dev/new_script.py` then no longer runs with the intended
interpreter. Copying from a neighboring file has the opposite risk of adding a
shebang to a plain module. Maybe "Every new file has the Apache License header
at the top, after the shebang line of an executable script; ...".
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
Review Comment:
**[9] The two helpers cover only runtime SQL configs.**
`withSQLConf` throws `cannotModifyValueOfStaticConfigError` for a static SQL
config. For a core config such as `spark.task.cpus`, it sets a SQL conf entry
that the running `SparkContext` never reads, so the pin silently does nothing.
Those configs go in the suite's `SparkConf`, for example `override def
sparkConf` in a `SharedSparkSession` suite. `build_non_ansi.yml` also enables
the `sparkr` job, and an R test has neither helper; `test_sparkSQL.R` reads the
mode with `sparkR.conf` instead. A short "(runtime SQL configs; static and core
configs go in the suite's `sparkConf`)" would avoid the trap.
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
+
+Keep public Scala and Java APIs binary compatible; the MiMa check in CI
(`dev/mima`) reports changes that are not. When MiMa flags a change that is
intended, add an exclusion with a `// [SPARK-xxxxx]` comment to the
`vNNexcludes` section of `project/MimaExcludes.scala` for the version the
change first ships in (see `.agents/versioning.md`).
Review Comment:
**[7] Nit: the version choice is now described in two places.**
The root `AGENTS.md` already sends "new `MimaExcludes` sections" to
`.agents/versioning.md` ("A change that needs a version ..."). This sentence
repeats that routing in different words, so a later fix to one of them, such as
[5], can miss the other. Stopping at "add an exclusion with a `//
[SPARK-xxxxx]` comment to `project/MimaExcludes.scala`" and leaving the section
choice to the existing pointer would keep one source.
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
+
+Keep public Scala and Java APIs binary compatible; the MiMa check in CI
(`dev/mima`) reports changes that are not. When MiMa flags a change that is
intended, add an exclusion with a `// [SPARK-xxxxx]` comment to the
`vNNexcludes` section of `project/MimaExcludes.scala` for the version the
change first ships in (see `.agents/versioning.md`).
Review Comment:
**[6] MiMa also flags removed or renamed `private[spark]` members.**
"Keep public Scala and Java APIs binary compatible" suggests that only
public APIs matter. Scala's `private[spark]` and `private[ml]` compile to
public bytecode. `GenerateMIMAIgnore` ignores only the package-private classes
and members that still exist in the current build, so removing or renaming such
a member of a public class is reported. For example, SPARK-58896 in
`v44excludes` filters the removed "old package-private numLeave accessors". An
agent that renames a `private[spark]` method on a public class does not expect
the MIMA test to fail. Maybe "Keep Scala and Java binary compatibility,
including `private[spark]` members of public classes; ...".
##########
.agents/code-conventions.md:
##########
@@ -12,3 +12,7 @@ Keep source lines within 100 characters — the linters enforce
this for Scala,
{print FILENAME":"FNR": "length" chars"}'
This is only a hint: it approximates the linters' exemptions (imports, URLs)
rather than matching them exactly, so it can over- or under-report. The linters
remain the source of truth.
+
+Every new source file starts with the Apache License header; copy it from a
neighboring file of the same type. The license check in CI
(`dev/check-license`) fails without it.
+
+Keep public Scala and Java APIs binary compatible; the MiMa check in CI
(`dev/mima`) reports changes that are not. When MiMa flags a change that is
intended, add an exclusion with a `// [SPARK-xxxxx]` comment to the
`vNNexcludes` section of `project/MimaExcludes.scala` for the version the
change first ships in (see `.agents/versioning.md`).
Review Comment:
**[5] `versioning.md` would send most of these filters to the master-only
section.**
`.agents/versioning.md` uses the `branch-<N>.x` version unless the change is
master-only, and its master-only list starts with "breaking /
binary-incompatible changes that can't ship in a minor release". A change that
MiMa flags looks exactly like that, so an agent is likely to pick
`v50excludes`. Most existing filters, however, are for changes that ship in
minor releases. For example, `v44excludes` has `ReversedMissingMethodProblem`
filters for new APIs (`Dataset.binBy`, `TableValuedFunction.variant_explode`)
and `DirectMissingMethodProblem` filters for removed internal members
(SPARK-60217, SPARK-58896). Such a PR is backported to `branch-4.x`, where
`excludes` maps 4.5 to `v45excludes` and there is no `v50excludes`. The
backport then either conflicts or lands without the filter, and MiMa fails
there. Maybe say in `versioning.md` that a MiMa filter goes in the
`branch-<N>.x` version's section unless the change itself cannot ship in a
minor release.
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
+ `self.sql_conf` in Python): suites also run in the scheduled Non-ANSI job
Review Comment:
**[12] Other scheduled jobs also change defaults through the environment.**
Three other scheduled builds do the same as the Non-ANSI job:
- `build_uds.yml` sets `PYSPARK_UDS_MODE=true`, the default of
`spark.python.unix.domain.socket.enabled`;
- `build_codegen_jdk.yml` sets `SPARK_CODEGEN_COMPILER=jdk`, read by
`SQLConf`;
- `build_rockdb_as_ui_backend.yml` sets `LIVE_UI_LOCAL_STORE_DIR`, which
`AppStatusStore` uses as the default store path.
A Python worker test that assumes TCP sockets, or a UI test that assumes the
in-memory store, passes in PR CI and fails there later. Naming only ANSI makes
it look like the only case. Maybe "suites also run in scheduled jobs that
change defaults through env vars, such as the Non-ANSI job ...".
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
Review Comment:
**[8] Pinning ANSI on removes the coverage that the Non-ANSI job exists
for.**
For a test whose assertions depend on `spark.sql.ansi.enabled`, the easiest
way to follow this rule is `withSQLConf(SQLConf.ANSI_ENABLED.key -> "true")`.
The scheduled job then passes, but the non-ANSI behavior of that test is no
longer checked anywhere. Existing suites mostly branch on the mode instead:
- about 40 `conf.ansiEnabled` checks in `sql/core` tests, such as
`ColumnExpressionSuite` and `SQLQuerySuite`;
- `is_ansi_mode_test` and `ansi_mode_not_supported_message` in the pandas
API on Spark tests, whose `PandasOnSparkTestCase.setUp` and `tearDown` even
assert that the session mode matches `SPARK_ANSI_SQL_MODE`;
- `ansiEnabled` in `test_sparkSQL.R`;
- per-mode golden files in `PlanStabilitySuite`.
Maybe "pin the configs its assertions depend on, or, when the result differs
by mode and both matter, assert per mode (`conf.ansiEnabled`,
`is_ansi_mode_test`)".
##########
AGENTS.md:
##########
@@ -42,6 +42,11 @@ Before the first code edit or running test in a session,
ensure a clean working
read `.agents/build-and-test.md`. For setup and local troubleshooting:
`docs/building-spark.md`.
- Before writing a new Scala or Python test suite: read
`.agents/test-base-classes.md` and pick
the lowest base class that provides what the test actually needs.
+- When writing or changing a test, pin the configs its assertions depend on
(`withSQLConf`, or
+ `self.sql_conf` in Python): suites also run in the scheduled Non-ANSI job
+ (`SPARK_ANSI_SQL_MODE=false`), where `spark.sql.ansi.enabled` defaults to
`false`.
+- Never remove a failing test or mock the code under test unless asked;
document why any mock is
Review Comment:
**[10] Skipping or weakening a failing test has the same effect as removing
it.**
The rule forbids removing a failing test or mocking the code under test, but
not the other ways to turn CI green without a fix: changing `test` to `ignore`,
adding `assume(false)` or `@unittest.skip`, or changing the expected value or
golden output to whatever the code now produces. Each of these hides the
failure the same way. Maybe "Never remove, skip or weaken a failing test, or
mock the code under test, unless asked".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]