Skip to content

SNOW-3153913: patching split() in local testing #4086

@serban-dobroiu

Description

@serban-dobroiu

Hi, trying to patch and use split() for testing some dataframe transformations but I'm not sure I'm doing it right:

@patch(split)
def mock_split(column: ColumnEmulator, pattern: ColumnEmulator) -> ColumnEmulator:
    ret_column = ColumnEmulator(data=[split(row, pattern=pattern) for row in column])
    ret_column.sf_type = ColumnType(ArrayType(StringType()), nullable=True)
    return ret_column

When I try to test a transformation function calling split():

def col_to_array(
    df: DataFrame,
    cols: Iterable[str],
    delimiter: str = "|",
    ignore_missing: bool = False,
) -> DataFrame:
....
for _col in cols:
        transformation = when(col(_col).is_not_null(), split(col(_col), lit(delimiter)))
....

it is throwing the following type error:

error_message = "Error executing mocked function 'split'. See error traceback for detailed information."```

Can you please help me understand what is happening here?

thank you!

Metadata

Metadata

Assignees

Labels

status-information_neededAdditional information is required from the reporterstatus-triageIssue is under initial triage

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions