uranusjr commented on code in PR #31567:
URL: https://github.com/apache/airflow/pull/31567#discussion_r1209723688


##########
airflow/providers/amazon/aws/hooks/redshift_sql.py:
##########
@@ -104,7 +104,11 @@ def get_iam_token(self, conn: Connection) -> tuple[str, 
str, int]:
         port = conn.port or 5439
         # Pull the custer-identifier from the beginning of the Redshift URL
         # ex. my-cluster.ccdre4hpd39h.us-east-1.redshift.amazonaws.com returns 
my-cluster
-        cluster_identifier = conn.extra_dejson.get("cluster_identifier", 
conn.host.split(".")[0])
+        cluster_identifier = conn.extra_dejson.get("cluster_identifier", None)
+        if conn.host and not cluster_identifier:
+            cluster_identifier = conn.host.split(".")[0]

Review Comment:
   I swapped `cluster_identifier` and `conn.host` in the suggestion above. If 
`cluster_identifier` is set, `not cluster_identifier` would be false, and 
`conn.host` will not be read. This makes more sense, since we only want to read 
that value when `cluster_identifier` is not set. In your current code, 
`conn.host` will be read unnecessarily even if `cluster_identifier` is set.



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