Skip to content

Commit

Permalink
Add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
feluelle committed Nov 21, 2022
1 parent bd9ca64 commit 4d8e7d5
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions sql-cli/sql_cli/operators/load_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,42 @@


def build_load_file_operator_content(
operator_content: dict[str, Any], operator_file_name: str
operator_content: dict[str, Any],
operator_file_name: str,
) -> dict[str, Any]:
"""
Deserialize the File and Table classes.
:param operator_content: The dictionary of the operator content to be deserialized.
:param operator_file_name: The file name of the operator.
:returns: the operator content deserialized.
"""
input_file_content = operator_content.pop("input_file")
input_file_content["class"] = "File"
input_file_content.setdefault("is_dataframe", False)
input_file_content.setdefault("normalize_config", None)
input_file = deserialize(input_file_content)
operator_content["input_file"] = input_file

operator_content["input_file"] = deserialize(input_file_content)

output_table_content = operator_content.pop("output_table")
output_table_content["class"] = "Table"
output_table_content.setdefault("name", operator_file_name)
output_table_content.setdefault("temp", False)
output_table = deserialize(output_table_content)
operator_content["output_table"] = output_table

operator_content["output_table"] = deserialize(output_table_content)

return operator_content


def get_load_file_instance(yaml_content: dict[str, Any], operator_file_name: str) -> LoadFileOperator:
"""
Instantiate the LoadFileOperator.
:param yaml_content: The content of the load_file yaml.
:param operator_file_name: The file name of the operator.
:returns: an instance of the LoadFileOperator
"""
operator_content: dict[str, Any] = build_load_file_operator_content(yaml_content, operator_file_name)
load_file_operator = LoadFileOperator(**operator_content)
return load_file_operator
return LoadFileOperator(**operator_content)

0 comments on commit 4d8e7d5

Please sign in to comment.