Пример #1
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist={"df_count": {1}, "model_count": {0}}
    error, extra=IncomingEdgeValidityChecker.check_validity(node["id"], requireds_info, edges, checklist)
    final_code=[]
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if(error == ErrorTypes.NO_ERROR):
        if("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {"node_id": node["id"], "input_dfs": [df_name], "shared_function_set": shared_function_set, "additional_local_code": additional_local_code, "errors": errors}
        # Depending on the column that multi_instance_indicator indicates, we will decide to apply whether to multi-instance generation or usual generation
        if(MultiInstanceHandlerUtils.should_generate_multiple_instances(node)):
            gen_code = MultiInstanceHandlerUtils.multi_instance_generation(node, df_name, my_args)
        else:
            gen_code = __single_generation(node, df_name, my_args)

        final_code = CodeGenerationUtils.merge_with_additional_code(gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #2
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist={"df_count": {1}, "model_count": {0}}
    error, extra=IncomingEdgeValidityChecker.check_validity(node["id"], requireds_info, edges, checklist)
    final_code=[]
    shared_function_set = set()
    additional_local_code=[]
    errors=[]
    if(error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args={"node_id": node["id"], "input_dfs": [df_name], "shared_function_set": shared_function_set, "additional_local_code": additional_local_code, "errors": errors}

        updated_function_name = CodeGenerationUtils.handle_parameter(node["parameters"]["udf_function"], my_args)
        gen_code=[]
        gen_code.extend(["udf_"+node["id"]+" = udf("+updated_function_name+", "+node["parameters"]["udf_return_type"]["value"]+"())", os.linesep])

        gen_code.extend(["tuple_list = " + CodeGenerationUtils.handle_parameter(node["parameters"]["udf_input_tuples"], my_args), os.linesep])
        gen_code.extend(["output_list = " + CodeGenerationUtils.handle_parameter(node["parameters"]["udf_outputs"], my_args), os.linesep])
        gen_code.extend(["df_" + node["id"] + "=" + df_name, os.linesep])
        gen_code.extend(["for index in range(len(tuple_list)):", os.linesep])
        gen_code.extend(["\tdf_"+node["id"]+" = df_"+node["id"]+".withColumn(output_list[index], udf_"+node["id"]+"(*tuple_list[index]))", os.linesep, os.linesep])

        final_code = CodeGenerationUtils.merge_with_additional_code(gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #3
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        if (error == ErrorTypes.NO_ERROR):
            my_args = {
                "node_id": node["id"],
                "input_dfs": [df_name],
                "shared_function_set": shared_function_set,
                "additional_local_code": additional_local_code,
                "errors": errors
            }
            gen_code = CodeGenerationUtils.handle_instantination_or_call(
                node["parameters"], 'df_' + node["id"] + '=' + df_name + '.' +
                node["ddfo_name"] + '(', my_args)

            final_code = CodeGenerationUtils.merge_with_additional_code(
                gen_code, additional_local_code)

    return final_code, shared_function_set, error
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist={"df_count": {0}, "model_count": {0}}
    error, extra=IncomingEdgeValidityChecker.check_validity(node["id"], requireds_info, edges, checklist)
    final_code=[]
    shared_function_set = set()
    additional_local_code=[]
    errors=[]
    if(error == ErrorTypes.NO_ERROR):
        error, is_schema_appropriate=DataSourceValidityChecker.check_validity(node)
        if(error == ErrorTypes.NO_ERROR):
            my_args = {"node_id": node["id"], "shared_function_set": shared_function_set, "additional_local_code": additional_local_code, "errors": errors}
            # Must be a valid schema at this point.
            additional_code, param_string = CodeGenerationUtils.handle_parameter(node["parameter"]["schema"], my_args)
            gen_code=[]
            gen_code.extend(additional_code)

            gen_code.append("df_" + node["id"] + ' = spark.readStream.format("kafka").option("kafka.bootstrap.servers", ')
            gen_code.append(CodeGenerationUtils.handle_primitive(node["parameters"]["host"]["value"] + ":" + node["parameters"]["port"]["value"]) + ")")
            gen_code.append('.option("subscribe", ' + CodeGenerationUtils.handle_primitive(node["parameters"]["topic"]["value"] + ")"))
            gen_code.append('.load().select(from_json(col("value").cast("string"), '+ param_string +")")
            # For streams, we will use timestamp as a key while writing to kafka topic in case.
            gen_code.extend(['.alias("value"), "timestamp").select("value.*", "timestamp")', os.linesep])

            final_code = CodeGenerationUtils.merge_with_additional_code(gen_code, additional_local_code)

    return final_code, shared_function_set, error
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        error, extra2 = CVValiditiyChecker.check_validity(
            node["nodes"], node["edges"])

        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {
            "node_id": node["id"],
            "input_dfs": [df_name],
            "shared_function_set": shared_function_set,
            "additional_local_code": additional_local_code,
            "errors": errors
        }
        gen_code = []
        gen_code.extend(
            __generate_code_for_estimator_instantination(
                node["nodes"][extra2["estimator_node_id"]], my_args))
        gen_code.extend(
            __generate_code_for_evaluator_instantination(
                node["nodes"][extra2["evaluator_node_id"]], my_args))
        gen_code.extend(
            __generate_code_for_param_grid(
                node, 'estimator_' + extra2["estimator_node_id"], my_args))
        gen_code.extend(
            __generate_code_for_cv_instantination(node,
                                                  extra2["estimator_node_id"],
                                                  extra2["evaluator_node_id"]))

        gen_code.extend([
            'model_' + node["id"] + "=" + 'cv_' + node["id"] + ".fit(" +
            df_name + ")", os.linesep
        ])
        # Following might not be logical unless you aim to predict on training data for some specific needs.
        gen_code.extend([
            'df_' + node["id"] + "=" + 'model_' + node["id"] + '.transform(' +
            df_name + ')', os.linesep
        ])

        final_code = CodeGenerationUtils.merge_with_additional_code(
            gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #6
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    if (error == ErrorTypes.NO_ERROR):
        error, pipeline_order = PipelineValidityChecker.check_validity(
            node["nodes"], node["edges"])
        if (error == ErrorTypes.NO_ERROR):
            if ("portion" in extra["dfs"][0]):
                df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                    extra["dfs"][0]["portion"]) + "]"
            else:
                df_name = "df_" + extra["dfs"][0]["source_id"]

            my_args = {
                "node_id": node["id"],
                "input_dfs": [df_name],
                "shared_function_set": shared_function_set,
                "additional_local_code": additional_local_code,
                "errors": errors
            }
            gen_code, error = __generate_stages(node["nodes"], pipeline_order,
                                                df_name, my_args)
            if (error == ErrorTypes.NO_ERROR):
                gen_code.append(os.linesep)
                gen_code.extend(
                    __generate_code_for_pipeline_instantination(
                        node, pipeline_order, my_args))

                gen_code.extend([
                    'model_' + node["id"] + "=" + 'pipeline_' + node["id"] +
                    ".fit(" + df_name + ")", os.linesep
                ])
                # Following might not be logical for pipelines with an estimator
                gen_code.extend([
                    'df_' + node["id"] + "=" + 'model_' + node["id"] +
                    '.transform(' + df_name + ')', os.linesep
                ])

                final_code = CodeGenerationUtils.merge_with_additional_code(
                    gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #7
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {
            "node_id": node["id"],
            "input_dfs": [df_name],
            "shared_function_set": shared_function_set,
            "additional_local_code": additional_local_code,
            "errors": errors
        }
        gen_code = []

        shared_function_set.add(SharedFunctionTypes.SELECT_EXPR_HELPERS)
        gen_code.append("df_" + node["id"] + "=" + df_name + ".selectExpr(")

        for expr in node["parameters"]["expressions"]["value"]:
            gen_code.extend([
                'single_select_expr_generator(' +
                CodeGenerationUtils.handle_parameter(expr["input_cols"],
                                                     my_args) +
                ', ' + CodeGenerationUtils.handle_parameter(
                    expr["output_cols"], my_args) +
                ', ' + CodeGenerationUtils.handle_parameter(
                    expr["operation"], my_args) + ')', ', '
            ])

        gen_code.pop()
        gen_code.extend([")", os.linesep])

        final_code = CodeGenerationUtils.merge_with_additional_code(
            gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #8
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {0}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        error, is_schema_appropriate = DataSourceValidityChecker.check_validity(
            node)
        if (error == ErrorTypes.NO_ERROR):
            my_args = {
                "node_id": node["id"],
                "shared_function_set": shared_function_set,
                "additional_local_code": additional_local_code,
                "errors": errors
            }
            if (is_schema_appropriate):
                gen_code = CodeGenerationUtils.handle_instantination_or_call(
                    node["parameters"], "df_" + node["id"] + "=" +
                    "spark.read." + node["file_type"] + "(", my_args)
            else:
                # For safety, but consider it again
                if ("schema" in node["parameters"]):
                    del node["parameters"]["schema"]

                if (node["can_infer_schema"]):
                    node["parameters"]["inferSchema"] = {
                        "value": True,
                        "type": "boolean"
                    }

                gen_code = CodeGenerationUtils.handle_instantination_or_call(
                    node["parameters"],
                    "df_" + node["id"] + "=" + "spark.read.format(" +
                    CodeGenerationUtils.handle_primitive(node["file_type"]) +
                    ").load(", my_args)

                final_code = CodeGenerationUtils.merge_with_additional_code(
                    gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #9
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist={"df_count": {1}, "model_count": {0}}
    error, extra=IncomingEdgeValidityChecker.check_validity(node["id"], requireds_info, edges, checklist)
    final_code=[]
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if(error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {"node_id": node["id"], "input_dfs": [df_name], "shared_function_set": shared_function_set, "additional_local_code": additional_local_code, "errors": errors}

        input_cols = CodeGenerationUtils.handle_parameter(node["parameters"]["input_cols"], my_args)
        output_cols = CodeGenerationUtils.handle_parameter(node["parameters"]["output_cols"], my_args)

        window_size = node["parameters"]["window_size"]["value"]
        partitioning_column = node["parameters"]["partitioning_column"]["value"]
        ordering_column = node["parameters"]["ordering_column"]["value"]
        ordering_direction = node["parameters"]["ordering_direction"]["value"]
        gen_code=[]
        gen_code.extend(["input_cols = " + output_cols, os.linesep])
        gen_code.extend(["output_cols = " + input_cols, os.linesep])
        gen_code.extend(["df_" + node["id"] + "=" + df_name, os.linesep])
        gen_code.extend(["for inC, outC in zip(input_cols, output_cols):", os.linesep])
        gen_code.extend(["\tdf_" + node["id"] + " = df_" + node["id"] + ".withColumn('temp', col(inC))", os.linesep])
        gen_code.extend(["\twSpec = Window.partitionBy('" + partitioning_column + "').orderBy(col('" + ordering_column + "')." + ordering_direction + "())", os.linesep])
        gen_code.extend(["\tfor j in range(" + str(window_size) + "):", os.linesep])
        gen_code.extend(["\t\tlag_values = lag('temp', default=0).over(wSpec)", os.linesep])
        gen_code.extend(["\t\tdf_" + node["id"] + " = df_" + node["id"] + ".withColumn('temp', F.when((col('temp')==1) | (lag_values==None) | (lag_values<1) | (lag_values>=" + str(window_size + 1) + "), col('temp')).otherwise(lag_values+1))", os.linesep])
        gen_code.extend(["\tdf_" + node["id"] + " = df_" + node["id"] + ".withColumn(outC, F.when(col('temp') > 0, 1.0).otherwise(0.0))", os.linesep])

        final_code = CodeGenerationUtils.merge_with_additional_code(gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #10
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {
            "node_id": node["id"],
            "input_dfs": [df_name],
            "shared_function_set": shared_function_set,
            "additional_local_code": additional_local_code,
            "errors": errors
        }

        gen_code = CodeGenerationUtils.handle_instantination_or_call(
            node["parameters"], df_name + ".write.format(" +
            CodeGenerationUtils.handle_primitive(node["file_type"]) +
            ").save(", my_args)

        final_code = CodeGenerationUtils.merge_with_additional_code(
            gen_code, additional_local_code)

        args["additional_info"]["written_tables"].append(
            {"table_path": node["parameters"]["path"]["value"]})

    return final_code, shared_function_set, error
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {0}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        error, is_schema_appropriate = DataSourceValidityChecker.check_validity(
            node)
        if (error == ErrorTypes.NO_ERROR):
            my_args = {
                "node_id": node["id"],
                "shared_function_set": shared_function_set,
                "additional_local_code": additional_local_code,
                "errors": errors
            }
            # Must be a valid schema at this point.
            additional_code, param_string = CodeGenerationUtils.handle_parameter(
                node["parameter"]["schema"], my_args)
            gen_code = []
            gen_code.extend(additional_code)

            gen_code.extend([
                "df_" + node["id"] + ' = spark.readStream.schema(' +
                param_string + ")." + node["file_type"] + "(" +
                CodeGenerationUtils.handle_primitive(
                    node["parameters"]["path"]["value"]) + ")", os.linesep
            ])

            final_code = CodeGenerationUtils.merge_with_additional_code(
                gen_code, additional_local_code)

    return final_code, shared_function_set, error
Пример #12
0
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {
            "node_id": node["id"],
            "input_dfs": [df_name],
            "shared_function_set": shared_function_set,
            "additional_local_code": additional_local_code,
            "errors": errors
        }

        df_name = "df_" + my_args["node_id"]
        gen_code = [df_name + " = " + my_args["input_dfs"][0], os.linesep]

        input_columns = ["["]
        conditions = ["["]
        values = ["["]
        otherwises = ["["]
        output_columns = ["["]
        for exp in node["parameters"]["expressions"]["value"]:
            input_columns.extend([
                CodeGenerationUtils.handle_parameter(exp["input_columns"],
                                                     my_args), ", "
            ])
            conditions.extend([
                CodeGenerationUtils.handle_parameter(exp["condition"],
                                                     my_args), ", "
            ])
            values.extend([
                CodeGenerationUtils.handle_parameter(exp["value"], my_args),
                ", "
            ])
            otherwises.extend([
                CodeGenerationUtils.handle_parameter(exp["otherwise"],
                                                     my_args), ", "
            ])
            output_columns.extend([
                CodeGenerationUtils.handle_parameter(exp["output_columns"],
                                                     my_args), ", "
            ])

        # Check there are at least 1 elememnt in expressions
        input_columns.pop()
        conditions.pop()
        values.pop()
        otherwises.pop()
        output_columns.pop()

        input_columns.extend(["]"])
        conditions.extend(["]"])
        values.extend(["]"])
        otherwises.extend(["]"])
        output_columns.extend(["]"])

        gen_code.extend(
            ["input_columns = " + ''.join(input_columns), os.linesep])
        gen_code.extend(["conditions = " + ''.join(conditions), os.linesep])
        gen_code.extend(["values = " + ''.join(values), os.linesep])
        gen_code.extend(["otherwises = " + ''.join(otherwises), os.linesep])
        gen_code.extend(
            ["output_columns = " + ''.join(output_columns), os.linesep])

        gen_code.extend([
            "for in_cols, cond, val, otw, out_cols in zip(input_columns, conditions, values, otherwises, output_columns):",
            os.linesep
        ])
        gen_code.extend(
            ["\tfor in_col, out_col in zip(in_cols, out_cols):", os.linesep])
        gen_code.extend([
            "\t\tcur_cond = eval(cond.replace('$','" + df_name +
            "[\"'+in_col+'\"]'" + "))", os.linesep
        ])
        gen_code.extend([
            "\t\t" + df_name + " = " + df_name +
            ".withColumn(out_col, F.when(cur_cond, val).otherwise(otw))",
            os.linesep
        ])

        final_code = CodeGenerationUtils.merge_with_additional_code(
            gen_code, additional_local_code)

    return final_code, shared_function_set, error
def generate_code(args):
    node = args["node"]
    requireds_info = args["requireds_info"]
    edges = args["edges"]

    checklist = {"df_count": {1}, "model_count": {0}}
    error, extra = IncomingEdgeValidityChecker.check_validity(
        node["id"], requireds_info, edges, checklist)
    final_code = []
    shared_function_set = set()
    additional_local_code = []
    errors = []
    if (error == ErrorTypes.NO_ERROR):
        if ("portion" in extra["dfs"][0]):
            df_name = "df_" + extra["dfs"][0]["source_id"] + "[" + str(
                extra["dfs"][0]["portion"]) + "]"
        else:
            df_name = "df_" + extra["dfs"][0]["source_id"]

        my_args = {
            "node_id": node["id"],
            "input_dfs": [df_name],
            "shared_function_set": shared_function_set,
            "additional_local_code": additional_local_code,
            "errors": errors
        }
        gen_code = []
        gen_code.extend(["df_" + node["id"] + "=" + df_name, os.linesep])

        between_operation = node["parameters"]["rolling_stats_info"]["value"][
            "between_operation"]["value"]

        first_argument_input_cols = CodeGenerationUtils.handle_parameter(
            node["parameters"]["rolling_stats_info"]["value"]["first_argument"]
            ["value"]["input_cols"], my_args)
        first_argument_operation = node["parameters"]["rolling_stats_info"][
            "value"]["first_argument"]["value"]["operation"]["value"]
        gen_code.extend(
            ["first_cols = " + first_argument_input_cols, os.linesep])

        output_cols = CodeGenerationUtils.handle_parameter(
            node["parameters"]["rolling_stats_info"]["value"]["output_cols"],
            my_args)
        gen_code.extend(["output_cols = " + output_cols, os.linesep])

        partitioning_column = node["parameters"]["rolling_stats_info"][
            "value"]["partitioning_column"]["value"]
        ordering_column = node["parameters"]["rolling_stats_info"]["value"][
            "ordering_column"]["value"]
        ordering_direction = node["parameters"]["rolling_stats_info"]["value"][
            "ordering_direction"]["value"]

        lags = node["parameters"]["rolling_stats_info"]["value"]["lags"]
        lags_str = CodeGenerationUtils.handle_parameter(lags, my_args)

        window_str = "over (partition by " + partitioning_column + " order by " + ordering_column + " " + ordering_direction + " rows " + "'+ str(lag) +'" + " preceding) "

        # if window_size == -1:
        #     window_str = "over (partition by " + partition_column + " order by " + ordering_column + " " + ordering_direction + " rows unbounded preceding) "
        # else:
        #     window_str = "over (partition by " + partition_column + " order by " + ordering_column + " " + ordering_direction + " rows " + str(window_size) + " preceding) "

        if between_operation != 'Identity':
            second_argument_input_cols = CodeGenerationUtils.handle_parameter(
                node["parameters"]["rolling_stats_info"]["value"]
                ["second_argument"]["value"]["input_cols"], my_args)
            second_argument_operation = node["parameters"][
                "rolling_stats_info"]["value"]["second_argument"]["value"][
                    "operation"]["value"]
            gen_code.extend(
                ["second_cols = " + second_argument_input_cols, os.linesep])

            loop_str = "for col_1,col_2,out_col in zip(first_cols, second_cols, output_cols):"
            if first_argument_operation == 'Identity':
                if second_argument_operation == 'Identity':
                    select_str = "df_" + node["id"] + " = df_" + node[
                        "id"] + ".selectExpr('*', col_1 + ' " + between_operation + " '+ col_2 + ' as out_col' + str(lag))"
                else:
                    select_str = "df_" + node["id"] + " = df_" + node[
                        "id"] + ".selectExpr('*', col_1 + ' " + between_operation + " ' + '" + second_argument_operation + "(' + col_2 + ') " + window_str + "as out_col' + str(lag))"
            else:
                if second_argument_operation == 'Identity':
                    select_str = "df_" + node["id"] + " = df_" + node[
                        "id"] + ".selectExpr('*', '" + first_argument_operation + "(' + col_1 + ') " + window_str + between_operation + " ' + col_2 + ' as out_col' + str(lag))"
                else:
                    select_str = "df_" + node["id"] + " = df_" + node[
                        "id"] + ".selectExpr('*', '" + first_argument_operation + "(' + col_1 + ') " + window_str + between_operation + " " + second_argument_operation + "(' + col_2 + ') " + window_str + "as out_col' + str(lag))"
        else:
            loop_str = "for col_1,out_col in zip(first_cols, output_cols):"
            if first_argument_operation == 'Identity':
                select_str = "df_" + node["id"] + " = df_" + node[
                    "id"] + ".selectExpr('*', col_1 + ' as out_col' + str(lag))"
            else:
                select_str = "df_" + node["id"] + " = df_" + node[
                    "id"] + ".selectExpr('*', '" + first_argument_operation + "(' + col_1 + ') " + window_str + "as out_col' + str(lag))"

        gen_code.extend(["lags = " + lags_str, os.linesep])
        gen_code.extend(["for lag in lags:", os.linesep])

        gen_code.extend(["\t", loop_str, os.linesep])
        gen_code.extend(["\t\t" + select_str, os.linesep])

        final_code = CodeGenerationUtils.merge_with_additional_code(
            gen_code, additional_local_code)

    return final_code, shared_function_set, error