-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add validation mode for mapper #59
Add validation mode for mapper #59
Conversation
] | ||
# fmt: on | ||
|
||
def test_matching_mapping_with_casting(self, input_df, matching_mapping): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data types match so this should not trigger any casting, right? maybe test_matching_mapping_without_validation
. Some use _with_validation
suffix and some not. As all except two tests apply validation would remove the suffix as the class name already indicates that it is about validation.
column_to_nullify = "col_d" | ||
mapping_ = deepcopy(matching_mapping) | ||
mapping_.append((column_to_nullify, column_to_nullify, T.StringType())) | ||
mapped_df = Mapper(mapping_, mode="rename_and_validate", missing_column_handling="nullify").transform(input_df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you think about making the mode an enum, like:
mapped_df = Mapper(mapping_, mode="rename_and_validate", missing_column_handling="nullify").transform(input_df) | |
mapped_df = Mapper(mapping_, mode=MapperMode.RENAME_AND_VALIDATE, missing_column_handling="nullify").transform(input_df) |
same as above, no need to implement this now
Adds new mode for the Mapper transformer:
rename_and_validate
:All built-in, custom transformations (except renaming) and casts are disabled. The Mapper only renames the columns and validates that the output data type is the same as the input data type. The transformation will fail if any spooq / custom transformations (except
as_is
) are defined!