ericm-db opened a new pull request, #60265:
URL: https://github.com/apache/spark/pull/60265

   ### What changes were proposed in this pull request?
   
   This is one of four PRs that let `DataStreamReader.name()` and SQL 
`IDENTIFIED BY` turn on streaming source evolution for a query without the 
internal config `spark.sql.streaming.queryEvolution.enableSourceEvolution`. 
They are meant to land together, in order:
   
   1. SPARK-61309: check source names against the checkpoint before creating 
sources (#60263)
   2. SPARK-61310: decide source evolution once per query run (#60264)
   3. SPARK-61311: enable source evolution for queries that name a source (this 
PR)
   4. SPARK-61312: docs
   
   This PR is stacked on #60264; only its last commit is new.
   
   Naming a streaming source with `DataStreamReader.name()` or SQL `IDENTIFIED 
BY` now enables source evolution for the query that reads it:
   
   - `NameStreamingSources` propagates names when the config is on or a source 
in the plan has a user-provided name, and then requires every source to be 
named. Flow-assigned names alone still need the config.
   - `MicroBatchExecution` decides a new query's source tracking the same way. 
A new query with a named source starts on offset log v2 and records the 
decision in its offset metadata, and a restart keeps the recorded tracking. 
Other queries in the session are unaffected.
   - The config alone no longer rejects a positional offset log v1 checkpoint. 
Like a v2 checkpoint, it keeps tracking its sources by position.
   
   The config stays, with a narrower meaning: it forces source evolution for 
every streaming query in the session.
   
   Error messages no longer tell users to set the config to name sources:
   - `CANNOT_ENABLE_ON_EXISTING_CHECKPOINT` covers v1 and v2 positional 
checkpoints and drops the `existingVersion` parameter.
   - `UNNAMED_STREAMING_SOURCES_WITH_ENFORCEMENT` applies when any source is 
named or the config is on.
   - `SOURCE_NAMING_NOT_SUPPORTED` now covers flow-assigned names only.
   
   ### Why are the changes needed?
   
   `DataStreamReader.name()` and `IDENTIFIED BY` are public, but they fail with 
`SOURCE_NAMING_NOT_SUPPORTED` unless the internal config is set. Naming a 
source already opts in more explicitly than a session config, and some 
deployments do not let users set internal configs.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, compared to Spark 4.2:
   
   - `.name()`, or `IDENTIFIED BY` on a non-catalog source, without the config: 
`SOURCE_NAMING_NOT_SUPPORTED` becomes a query that runs with source evolution.
   - A new `IDENTIFIED BY` or `readStream.name().table()` query on a catalog 
table without the config: it ran by position with the source metadata in 
`sources/<name>`; it now runs with source evolution. Existing checkpoints of 
such queries keep running by position (see SPARK-61309).
   - The config on, restarting a positional v1 checkpoint whose sources skip 
`NamedStreamingRelation` (for example a memory stream): 
`CANNOT_ENABLE_ON_EXISTING_CHECKPOINT` becomes a run that keeps positional 
tracking.
   - The error messages listed above are reworded.
   
   ### How was this patch tested?
   
   - `NameStreamingSourcesSuite`: a user-provided name enables naming without 
the config and requires every source to be named, also when the named source 
already carries its name.
   - `StreamingSourceEvolutionSuite`: without the config:
     - a new query with `.name()` runs on offset log v2 and records the mode;
     - a restart keeps it, and a restart without names is rejected;
     - an unnamed query in the same session stays positional;
     - a named plus an unnamed source is rejected;
     - SQL `IDENTIFIED BY` works, and a mixed SQL query is rejected.
   - `OffsetSeqLogSuite`: the v1 test that expected 
`CANNOT_ENABLE_ON_EXISTING_CHECKPOINT` now checks that the checkpoint keeps 
positional tracking.
   
   ```
   build/sbt 'core/testOnly *SparkThrowableSuite'
   build/sbt 'catalyst/testOnly *NameStreamingSourcesSuite 
*NamedStreamingRelationSuite *StreamRelationParserSuite'
   build/sbt 'sql/testOnly *StreamingSourceEvolutionSuite *OffsetSeqLogSuite 
*CommitLogSuite *StreamRelationSuite *StreamingSourceIdentifyingNameSuite 
*ChangelogEndToEndSuite'
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   This pull request and its description were written by Isaac.
   


-- 
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]

Reply via email to