Har1sh-k commented on code in PR #66751:
URL: https://github.com/apache/airflow/pull/66751#discussion_r3350473238
##########
providers/apache/hive/src/airflow/providers/apache/hive/operators/hive_stats.py:
##########
@@ -29,6 +30,13 @@
if TYPE_CHECKING:
from airflow.providers.common.compat.sdk import Context
+# Hive table names may be qualified as `<database>.<table>`; identifiers must
+# be plain word characters so they can be safely interpolated into the Presto
+# query that selects partition stats. Identifiers cannot be bound as parameters
+# in standard SQL.
+_HIVE_TABLE_RE =
re.compile(r"^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)?$")
+_HIVE_COLUMN_RE = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
Review Comment:
Fair point on the dialect quoting, but I don't think it affects the MySQL
side here. The `hive_stats` SELECT/DELETE don't interpolate any user
identifier: `self.table`, `part_json` and `self.dttm` all go in as bound `%s`
values (compared against the `table_name` / `partition_repr` / `dttm` columns),
and the table/column names are fixed literals. The
`insert_rows(table="hive_stats", ...)` fields are hard-coded too, and
common.sql already backtick-escapes them via the MySQL hook's `escape_word`.
The only spot a user identifier actually gets interpolated is the Presto
`SELECT`, so that's where I'll add the `"`-quoting (table + partition keys) and
drop the reject-regex.
--
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]