Move template-field checks out of __init__ in Hive sensors#70334
Merged
Conversation
1fanwang
requested review from
amoghrajesh,
ashb,
bugraoz93,
gopidesupavan,
jason810496,
jscheffl and
potiuk
as code owners
July 23, 2026 21:31
1fanwang
marked this pull request as draft
July 24, 2026 05:47
1fanwang
marked this pull request as ready for review
July 24, 2026 06:23
table/partition (HivePartitionSensor) and partition_names (NamedHivePartitionSensor) are template fields, rendered after __init__ runs. HivePartitionSensor used an imperative default (if not partition: partition = ...) reading the field; NamedHivePartitionSensor raised TypeError in the constructor when partition_names was a str, which rejected a whole-list native template (a str before rendering). Use the sanctioned 'partition or default' idiom, and move the array-type check to poke(), which runs after rendering. related: apache#70296 Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
force-pushed
the
fix-hive-sensors-init
branch
from
July 24, 2026 18:20
ab4caa9 to
d5b77fa
Compare
shahar1
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
table/partition(HivePartitionSensor) andpartition_names(NamedHivePartitionSensor) are template fields, so they are rendered after__init__runs. Two constructors read them:HivePartitionSensordefaultedpartitionwithif not partition: partition = "ds='{{ ds }}'"— an imperative read of the field. Switched to the sanctionedpartition or "ds='{{ ds }}'"idiom (behaviour identical).NamedHivePartitionSensorraisedTypeErrorin__init__whenpartition_nameswas astr. A whole-list native template (partition_names="{{ params.names }}") is astrbefore rendering, so the constructor rejected it outright. Moved the array-type check topoke(), which runs after rendering.related: #70296
Testing Done
validate_operators_init.pyexits 0 for both sensors after the change (RED before, flaggingif not partition:andif isinstance(partition_names, str):).New
test_native_templated_partition_namesdrives the render→poke path with a native-templated list; it fails on the pre-fix source (TypeErrorat 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.Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI following the guidelines