acryl-datahub 1.0.0.4rc6__py3-none-any.whl → 1.0.0.4rc8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of acryl-datahub might be problematic. Click here for more details.

@@ -134,19 +134,41 @@ def get_table_comment(self, connection, table_name: str, schema: str = None, **k
134
134
  ):
135
135
  properties_table = self._get_full_table(f"{table_name}$properties", schema)
136
136
  query = f"SELECT * FROM {properties_table}"
137
- row = connection.execute(sql.text(query)).fetchone()
137
+ rows = connection.execute(sql.text(query)).fetchall()
138
138
 
139
139
  # Generate properties dictionary.
140
140
  properties = {}
141
- if row:
141
+
142
+ if len(rows) == 0:
143
+ # No properties found, return empty dictionary
144
+ return {}
145
+
146
+ # Check if using the old format (key, value columns)
147
+ if (
148
+ connector_name == "iceberg"
149
+ and len(rows[0]) == 2
150
+ and "key" in rows[0]
151
+ and "value" in rows[0]
152
+ ):
153
+ # https://trino.io/docs/current/connector/iceberg.html#properties-table
154
+ for row in rows:
155
+ if row["value"] is not None:
156
+ properties[row["key"]] = row["value"]
157
+ return {"text": properties.get("comment"), "properties": properties}
158
+ elif connector_name == "hive" and len(rows[0]) > 1 and len(rows) == 1:
159
+ # https://trino.io/docs/current/connector/hive.html#properties-table
160
+ row = rows[0]
142
161
  for col_name, col_value in row.items():
143
162
  if col_value is not None:
144
163
  properties[col_name] = col_value
164
+ return {"text": properties.get("comment"), "properties": properties}
145
165
 
146
- return {"text": properties.get("comment"), "properties": properties}
147
- else:
148
- return self.get_table_comment_default(connection, table_name, schema)
149
- except Exception:
166
+ # If we can't get the properties we still fallback to the default
167
+ return self.get_table_comment_default(connection, table_name, schema)
168
+ except Exception as e:
169
+ logging.warning(
170
+ f"Failed to get table comment for {table_name} in {schema}: {e}"
171
+ )
150
172
  return {}
151
173
 
152
174