jiayuasu opened a new pull request, #3122:
URL: https://github.com/apache/sedona/pull/3122

   ## Did you read the Contributor Guide?
   
   - Yes, I have read the [Contributor 
Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor 
Development Guide](https://sedona.apache.org/latest/community/develop/)
   
   ## Is this PR related to a ticket?
   
   - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #3110
   
   ## What changes were proposed in this PR?
   
   Calling the STAC Python `Client.search()` (or 
`CollectionClient.get_dataframe()` / `get_items()`) with a `datetime` argument 
in `YYYY-mm` form failed with `RuntimeError: Failed to get filtered dataframe` 
wrapping `TypeError: 'NoneType' object is not callable`.
   
   Root cause: `python/sedona/spark/stac/collection_client.py` imported `from 
pyspark.sql.types import dt`. `pyspark.sql.types` exposes no `dt`, so the name 
resolved to `None`, and the `YYYY-mm` branch of `_expand_date` then called 
`dt(...)`, raising the `TypeError`. The old arithmetic also overflowed for 
December (`int(month) + 1` == 13).
   
   This PR:
   
   - Removes the erroneous `from pyspark.sql.types import dt` import.
   - Computes the last day of the month with `calendar.monthrange`, which 
handles December and leap years correctly, and zero-pads the day so the emitted 
timestamp stays valid ISO 8601.
   
   Only the `YYYY-mm` form was affected; `YYYY`, `YYYY-mm-dd`, 
`YYYY-mm-ddTHH:MM:SSZ`, and explicit interval lists already worked.
   
   `_expand_date("2020-05")` now returns `["2020-05-01T00:00:00Z", 
"2020-05-31T23:59:59Z"]` as documented.
   
   ## How was this patch tested?
   
   Added `test_expand_date` in `python/tests/stac/test_collection_client.py` 
covering all supported forms plus the previously broken edge cases: December 
(`2020-12` -> 31), leap-year February (`2020-02` -> 29), and non-leap February 
(`2021-02` -> 28). All 24 tests in the file pass.
   
   ## Did this PR include necessary documentation updates?
   
   - No, this PR does not affect any public API so no need to change the 
documentation.
   
   https://claude.ai/code/session_01CDKt3sXKJ9v4PTmFGBZFUR


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