bito-code-review[bot] commented on code in PR #34763:
URL: https://github.com/apache/superset/pull/34763#discussion_r2320073188


##########
superset/commands/database/uploaders/csv_reader.py:
##########
@@ -123,6 +123,96 @@ def _select_optimal_engine() -> str:
             )
             return "c"
 
+    @staticmethod
+    def _find_invalid_values_numeric(df: pd.DataFrame, column: str) -> 
pd.Series:
+        """Find invalid values for numeric type conversion."""
+        converted = pd.to_numeric(df[column], errors="coerce")
+        return converted.isna() & df[column].notna()
+
+    @staticmethod
+    def _find_invalid_values_non_numeric(
+        df: pd.DataFrame, column: str, dtype: str
+    ) -> pd.Series:
+        """Find invalid values for non-numeric type conversion."""
+        invalid_mask = pd.Series([False] * len(df), index=df.index)
+        for idx, value in df[column].items():
+            if pd.notna(value):
+                try:
+                    pd.Series([value]).astype(dtype)
+                except (ValueError, TypeError):
+                    invalid_mask[idx] = True
+                    break

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Incomplete invalid value detection logic</b></div>
   <div id="fix">
   
   The `break` statement causes the method to stop after finding the first 
invalid value, preventing comprehensive error reporting. Remove the `break` to 
identify all invalid values in the column for better error diagnostics.
   </div>
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```suggestion
                       pd.Series([value]).astype(dtype)
                   except (ValueError, TypeError):
                       invalid_mask[idx] = True
   ```
   
   </div>
   </details>
   </div>
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/34763#issuecomment-3250604989>#6ecc7f</a></i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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: notifications-unsubscr...@superset.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to