Har1sh-k commented on code in PR #66751:
URL: https://github.com/apache/airflow/pull/66751#discussion_r3350447183
##########
providers/apache/hive/src/airflow/providers/apache/hive/operators/hive_stats.py:
##########
@@ -128,13 +146,16 @@ def execute(self, context: Context) -> None:
exprs.update(self.extra_exprs)
exprs_str = ",\n ".join(f"{v} AS {k[0]}__{k[1]}" for k, v in
exprs.items())
- where_clause_ = [f"{k} = '{v}'" for k, v in self.partition.items()]
+ presto = PrestoHook(presto_conn_id=self.presto_conn_id)
+ # PrestoHook overrides DbApiHook's default `%s` placeholder with `?`,
+ # so the WHERE clause is built against the hook's declared placeholder.
+ placeholder = presto.placeholder
+ where_clause_ = [f"{k} = {placeholder}" for k in self.partition.keys()]
where_clause = " AND\n ".join(where_clause_)
sql = f"SELECT {exprs_str} FROM {self.table} WHERE {where_clause};"
- presto = PrestoHook(presto_conn_id=self.presto_conn_id)
self.log.info("Executing SQL check: %s", sql)
- row = presto.get_first(sql)
+ row = presto.get_first(sql, parameters=tuple(self.partition.values()))
Review Comment:
Yeah, keeping the `tuple()`. `self.partition.values()` is a `dict_values`
view, which is iterable but not an indexable sequence, and the params go
straight to the driver's `cursor.execute()` (`_run_command` only converts to
tuple for psycopg). prestodb indexes into positional params, so a bare view can
raise
`TypeError`. `tuple()` makes it a stable snapshot and matches the MySQL
`parameters=(...)` calls right below.
--
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]