michael-s-molina commented on code in PR #34763:
URL: https://github.com/apache/superset/pull/34763#discussion_r2322265257
##########
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:
@luizotavio32 Would be possible to show multiple errors to improve the user
experience? I would like to avoid a scenario where the user needs to try to
upload the file multiple times because there are multiple errors.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]