schizophrenicmaniac opened a new pull request, #41848:
URL: https://github.com/apache/beam/pull/41848

   Fixes #41843
   
   `JdbcIO.readWithPartitions()` only runs `where col >= ? and col < ?` per 
range, so rows where the partition column is NULL were never read. When the 
column was empty or entirely NULL, the inferred min/max came back as NULL. Long 
turned that into the range [0, 1) and read nothing, and DateTime failed with a 
bare `IllegalArgumentException`.
   
   With this change, when the bounds are auto-inferred:
   - the min/max query has `HAVING min(col) IS NOT NULL`, so an empty or 
all-NULL column produces no ranges. This covers custom 
`JdbcReadWithPartitionsHelper`s too.
   - NULL rows are read with one extra `select * from <table> where <col> is 
null` query and flattened with the range reads.
   
   When `withLowerBound`/`withUpperBound` are set, the read already only 
returns rows in [lower, upper], so I left that path as it was: NULL rows aren't 
read there either. I added Javadoc for both bound methods and a note in the 
class docs that describes this. Python `ReadFromJdbc` and the YAML/Managed JDBC 
reads never set bounds, so they pick up the fix without changes.
   
   Added Derby tests for Long and DateTime partition columns covering a mix of 
NULL and non-NULL rows, an all-NULL table, an empty table and explicit bounds. 
The new tests fail on master and pass with this change. Also added a CHANGES.md 
entry.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [ ] Mention the appropriate issue in your description (for example: 
`addresses #123`), if applicable. This will automatically add a link to the 
pull request in the issue. If you would like the issue to automatically close 
on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).


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

Reply via email to