luizotavio32 commented on code in PR #34763: URL: https://github.com/apache/superset/pull/34763#discussion_r2322799626
########## 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: It's possible. In this case I would suggest not to show the exact line and value that has a typing error, only something like `"There are xx non int values on column yy" `. What do you think? -- 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