1fanwang opened a new pull request, #70334:
URL: https://github.com/apache/airflow/pull/70334

   `table`/`partition` (HivePartitionSensor) and `partition_names` 
(NamedHivePartitionSensor) are template fields, so they are rendered after 
`__init__` runs. Two constructors read them:
   
   - `HivePartitionSensor` defaulted `partition` with `if not partition: 
partition = "ds='{{ ds }}'"` — an imperative read of the field. Switched to the 
sanctioned `partition or "ds='{{ ds }}'"` idiom (behaviour identical).
   - `NamedHivePartitionSensor` raised `TypeError` in `__init__` when 
`partition_names` was a `str`. A whole-list native template 
(`partition_names="{{ params.names }}"`) is a `str` before rendering, so the 
constructor rejected it outright. Moved the array-type check to `poke()`, which 
runs after rendering.
   
   related: #70296
   
   cc @shahar1
   
   <details><summary>Testing Done</summary>
   
   `validate_operators_init.py` exits 0 for both sensors after the change (RED 
before, flagging `if not partition:` and `if isinstance(partition_names, 
str):`).
   
   New `test_native_templated_partition_names` drives the render→poke path with 
a native-templated list; it fails on the pre-fix source (`TypeError` at 
construction) and passes after. `test_named_hive_partition.py`: 6 passed, 4 
skipped (need a live metastore). HivePartitionSensor's change is a 
behaviour-preserving refactor, covered by the existing suite.
   
   </details>
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: GitHub Copilot CLI following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


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