R/tpch_raw_oo_12.R

Defines functions tpch_raw_oo_12

# Generated by meta_replay_to_fun_file(), do not edit by hand
tpch_raw_oo_12 <- function(con, experimental) {
  df1 <- lineitem
  "filter"
  rel1 <- duckdb$rel_from_df(con, df1, experimental = experimental)
  "filter"
  rel2 <- duckdb$rel_project(
    rel1,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_orderkey")
        duckdb$expr_set_alias(tmp_expr, "l_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_partkey")
        duckdb$expr_set_alias(tmp_expr, "l_partkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_suppkey")
        duckdb$expr_set_alias(tmp_expr, "l_suppkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linenumber")
        duckdb$expr_set_alias(tmp_expr, "l_linenumber")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_quantity")
        duckdb$expr_set_alias(tmp_expr, "l_quantity")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_extendedprice")
        duckdb$expr_set_alias(tmp_expr, "l_extendedprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_discount")
        duckdb$expr_set_alias(tmp_expr, "l_discount")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_tax")
        duckdb$expr_set_alias(tmp_expr, "l_tax")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_returnflag")
        duckdb$expr_set_alias(tmp_expr, "l_returnflag")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linestatus")
        duckdb$expr_set_alias(tmp_expr, "l_linestatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipdate")
        duckdb$expr_set_alias(tmp_expr, "l_shipdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_commitdate")
        duckdb$expr_set_alias(tmp_expr, "l_commitdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_receiptdate")
        duckdb$expr_set_alias(tmp_expr, "l_receiptdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipinstruct")
        duckdb$expr_set_alias(tmp_expr, "l_shipinstruct")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_comment")
        duckdb$expr_set_alias(tmp_expr, "l_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
        duckdb$expr_set_alias(tmp_expr, "___row_number")
        tmp_expr
      }
    )
  )
  "filter"
  rel3 <- duckdb$rel_filter(
    rel2,
    list(
      duckdb$expr_function(
        "___coalesce",
        list(
          duckdb$expr_function(
            "|",
            list(
              duckdb$expr_function(
                "r_base::==",
                list(
                  duckdb$expr_reference("l_shipmode"),
                  if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                    duckdb$expr_constant("MAIL", experimental = experimental)
                  } else {
                    duckdb$expr_constant("MAIL")
                  }
                )
              ),
              duckdb$expr_function(
                "r_base::==",
                list(
                  duckdb$expr_reference("l_shipmode"),
                  if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                    duckdb$expr_constant("SHIP", experimental = experimental)
                  } else {
                    duckdb$expr_constant("SHIP")
                  }
                )
              )
            )
          ),
          if ("experimental" %in% names(formals(duckdb$expr_constant))) {
            duckdb$expr_constant(FALSE, experimental = experimental)
          } else {
            duckdb$expr_constant(FALSE)
          }
        )
      ),
      duckdb$expr_function(
        "r_base::<",
        list(duckdb$expr_reference("l_commitdate"), duckdb$expr_reference("l_receiptdate"))
      ),
      duckdb$expr_function(
        "r_base::<",
        list(duckdb$expr_reference("l_shipdate"), duckdb$expr_reference("l_commitdate"))
      ),
      duckdb$expr_function(
        "r_base::>=",
        list(
          duckdb$expr_reference("l_receiptdate"),
          if ("experimental" %in% names(formals(duckdb$expr_constant))) {
            duckdb$expr_constant(as.Date("1994-01-01"), experimental = experimental)
          } else {
            duckdb$expr_constant(as.Date("1994-01-01"))
          }
        )
      ),
      duckdb$expr_function(
        "r_base::<",
        list(
          duckdb$expr_reference("l_receiptdate"),
          if ("experimental" %in% names(formals(duckdb$expr_constant))) {
            duckdb$expr_constant(as.Date("1995-01-01"), experimental = experimental)
          } else {
            duckdb$expr_constant(as.Date("1995-01-01"))
          }
        )
      )
    )
  )
  "filter"
  rel4 <- duckdb$rel_order(rel3, list(duckdb$expr_reference("___row_number")))
  "filter"
  rel5 <- duckdb$rel_project(
    rel4,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_orderkey")
        duckdb$expr_set_alias(tmp_expr, "l_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_partkey")
        duckdb$expr_set_alias(tmp_expr, "l_partkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_suppkey")
        duckdb$expr_set_alias(tmp_expr, "l_suppkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linenumber")
        duckdb$expr_set_alias(tmp_expr, "l_linenumber")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_quantity")
        duckdb$expr_set_alias(tmp_expr, "l_quantity")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_extendedprice")
        duckdb$expr_set_alias(tmp_expr, "l_extendedprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_discount")
        duckdb$expr_set_alias(tmp_expr, "l_discount")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_tax")
        duckdb$expr_set_alias(tmp_expr, "l_tax")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_returnflag")
        duckdb$expr_set_alias(tmp_expr, "l_returnflag")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linestatus")
        duckdb$expr_set_alias(tmp_expr, "l_linestatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipdate")
        duckdb$expr_set_alias(tmp_expr, "l_shipdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_commitdate")
        duckdb$expr_set_alias(tmp_expr, "l_commitdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_receiptdate")
        duckdb$expr_set_alias(tmp_expr, "l_receiptdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipinstruct")
        duckdb$expr_set_alias(tmp_expr, "l_shipinstruct")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_comment")
        duckdb$expr_set_alias(tmp_expr, "l_comment")
        tmp_expr
      }
    )
  )
  "inner_join"
  rel6 <- duckdb$rel_set_alias(rel5, "lhs")
  df2 <- orders
  "inner_join"
  rel7 <- duckdb$rel_from_df(con, df2, experimental = experimental)
  "inner_join"
  rel8 <- duckdb$rel_set_alias(rel7, "rhs")
  "inner_join"
  rel9 <- duckdb$rel_project(
    rel6,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_orderkey")
        duckdb$expr_set_alias(tmp_expr, "l_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_partkey")
        duckdb$expr_set_alias(tmp_expr, "l_partkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_suppkey")
        duckdb$expr_set_alias(tmp_expr, "l_suppkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linenumber")
        duckdb$expr_set_alias(tmp_expr, "l_linenumber")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_quantity")
        duckdb$expr_set_alias(tmp_expr, "l_quantity")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_extendedprice")
        duckdb$expr_set_alias(tmp_expr, "l_extendedprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_discount")
        duckdb$expr_set_alias(tmp_expr, "l_discount")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_tax")
        duckdb$expr_set_alias(tmp_expr, "l_tax")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_returnflag")
        duckdb$expr_set_alias(tmp_expr, "l_returnflag")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linestatus")
        duckdb$expr_set_alias(tmp_expr, "l_linestatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipdate")
        duckdb$expr_set_alias(tmp_expr, "l_shipdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_commitdate")
        duckdb$expr_set_alias(tmp_expr, "l_commitdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_receiptdate")
        duckdb$expr_set_alias(tmp_expr, "l_receiptdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipinstruct")
        duckdb$expr_set_alias(tmp_expr, "l_shipinstruct")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_comment")
        duckdb$expr_set_alias(tmp_expr, "l_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
        duckdb$expr_set_alias(tmp_expr, "___row_number_x")
        tmp_expr
      }
    )
  )
  "inner_join"
  rel10 <- duckdb$rel_project(
    rel8,
    list(
      {
        tmp_expr <- duckdb$expr_reference("o_orderkey")
        duckdb$expr_set_alias(tmp_expr, "o_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_custkey")
        duckdb$expr_set_alias(tmp_expr, "o_custkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderstatus")
        duckdb$expr_set_alias(tmp_expr, "o_orderstatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_totalprice")
        duckdb$expr_set_alias(tmp_expr, "o_totalprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderdate")
        duckdb$expr_set_alias(tmp_expr, "o_orderdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderpriority")
        duckdb$expr_set_alias(tmp_expr, "o_orderpriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_clerk")
        duckdb$expr_set_alias(tmp_expr, "o_clerk")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_shippriority")
        duckdb$expr_set_alias(tmp_expr, "o_shippriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_comment")
        duckdb$expr_set_alias(tmp_expr, "o_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
        duckdb$expr_set_alias(tmp_expr, "___row_number_y")
        tmp_expr
      }
    )
  )
  "inner_join"
  rel11 <- duckdb$rel_join(
    rel9,
    rel10,
    list(
      duckdb$expr_function(
        "==",
        list(duckdb$expr_reference("l_orderkey", rel9), duckdb$expr_reference("o_orderkey", rel10))
      )
    ),
    "inner"
  )
  "inner_join"
  rel12 <- duckdb$rel_order(
    rel11,
    list(duckdb$expr_reference("___row_number_x", rel9), duckdb$expr_reference("___row_number_y", rel10))
  )
  "inner_join"
  rel13 <- duckdb$rel_project(
    rel12,
    list(
      {
        tmp_expr <- duckdb$expr_function(
          "___coalesce",
          list(duckdb$expr_reference("l_orderkey", rel9), duckdb$expr_reference("o_orderkey", rel10))
        )
        duckdb$expr_set_alias(tmp_expr, "l_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_partkey")
        duckdb$expr_set_alias(tmp_expr, "l_partkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_suppkey")
        duckdb$expr_set_alias(tmp_expr, "l_suppkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linenumber")
        duckdb$expr_set_alias(tmp_expr, "l_linenumber")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_quantity")
        duckdb$expr_set_alias(tmp_expr, "l_quantity")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_extendedprice")
        duckdb$expr_set_alias(tmp_expr, "l_extendedprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_discount")
        duckdb$expr_set_alias(tmp_expr, "l_discount")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_tax")
        duckdb$expr_set_alias(tmp_expr, "l_tax")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_returnflag")
        duckdb$expr_set_alias(tmp_expr, "l_returnflag")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linestatus")
        duckdb$expr_set_alias(tmp_expr, "l_linestatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipdate")
        duckdb$expr_set_alias(tmp_expr, "l_shipdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_commitdate")
        duckdb$expr_set_alias(tmp_expr, "l_commitdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_receiptdate")
        duckdb$expr_set_alias(tmp_expr, "l_receiptdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipinstruct")
        duckdb$expr_set_alias(tmp_expr, "l_shipinstruct")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_comment")
        duckdb$expr_set_alias(tmp_expr, "l_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_custkey")
        duckdb$expr_set_alias(tmp_expr, "o_custkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderstatus")
        duckdb$expr_set_alias(tmp_expr, "o_orderstatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_totalprice")
        duckdb$expr_set_alias(tmp_expr, "o_totalprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderdate")
        duckdb$expr_set_alias(tmp_expr, "o_orderdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderpriority")
        duckdb$expr_set_alias(tmp_expr, "o_orderpriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_clerk")
        duckdb$expr_set_alias(tmp_expr, "o_clerk")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_shippriority")
        duckdb$expr_set_alias(tmp_expr, "o_shippriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_comment")
        duckdb$expr_set_alias(tmp_expr, "o_comment")
        tmp_expr
      }
    )
  )
  "summarise"
  rel14 <- duckdb$rel_project(
    rel13,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_orderkey")
        duckdb$expr_set_alias(tmp_expr, "l_orderkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_partkey")
        duckdb$expr_set_alias(tmp_expr, "l_partkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_suppkey")
        duckdb$expr_set_alias(tmp_expr, "l_suppkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linenumber")
        duckdb$expr_set_alias(tmp_expr, "l_linenumber")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_quantity")
        duckdb$expr_set_alias(tmp_expr, "l_quantity")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_extendedprice")
        duckdb$expr_set_alias(tmp_expr, "l_extendedprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_discount")
        duckdb$expr_set_alias(tmp_expr, "l_discount")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_tax")
        duckdb$expr_set_alias(tmp_expr, "l_tax")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_returnflag")
        duckdb$expr_set_alias(tmp_expr, "l_returnflag")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_linestatus")
        duckdb$expr_set_alias(tmp_expr, "l_linestatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipdate")
        duckdb$expr_set_alias(tmp_expr, "l_shipdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_commitdate")
        duckdb$expr_set_alias(tmp_expr, "l_commitdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_receiptdate")
        duckdb$expr_set_alias(tmp_expr, "l_receiptdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipinstruct")
        duckdb$expr_set_alias(tmp_expr, "l_shipinstruct")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("l_comment")
        duckdb$expr_set_alias(tmp_expr, "l_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_custkey")
        duckdb$expr_set_alias(tmp_expr, "o_custkey")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderstatus")
        duckdb$expr_set_alias(tmp_expr, "o_orderstatus")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_totalprice")
        duckdb$expr_set_alias(tmp_expr, "o_totalprice")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderdate")
        duckdb$expr_set_alias(tmp_expr, "o_orderdate")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_orderpriority")
        duckdb$expr_set_alias(tmp_expr, "o_orderpriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_clerk")
        duckdb$expr_set_alias(tmp_expr, "o_clerk")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_shippriority")
        duckdb$expr_set_alias(tmp_expr, "o_shippriority")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("o_comment")
        duckdb$expr_set_alias(tmp_expr, "o_comment")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
        duckdb$expr_set_alias(tmp_expr, "___row_number")
        tmp_expr
      }
    )
  )
  "summarise"
  rel15 <- duckdb$rel_aggregate(
    rel14,
    groups = list(duckdb$expr_reference("l_shipmode")),
    aggregates = list(
      {
        tmp_expr <- duckdb$expr_function("min", list(duckdb$expr_reference("___row_number")))
        duckdb$expr_set_alias(tmp_expr, "___row_number")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_function(
          "sum",
          list(
            duckdb$expr_function(
              "if_else",
              list(
                duckdb$expr_function(
                  "|",
                  list(
                    duckdb$expr_function(
                      "r_base::==",
                      list(
                        duckdb$expr_reference("o_orderpriority"),
                        if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                          duckdb$expr_constant("1-URGENT", experimental = experimental)
                        } else {
                          duckdb$expr_constant("1-URGENT")
                        }
                      )
                    ),
                    duckdb$expr_function(
                      "r_base::==",
                      list(
                        duckdb$expr_reference("o_orderpriority"),
                        if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                          duckdb$expr_constant("2-HIGH", experimental = experimental)
                        } else {
                          duckdb$expr_constant("2-HIGH")
                        }
                      )
                    )
                  )
                ),
                if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                  duckdb$expr_constant(1L, experimental = experimental)
                } else {
                  duckdb$expr_constant(1L)
                },
                if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                  duckdb$expr_constant(0L, experimental = experimental)
                } else {
                  duckdb$expr_constant(0L)
                }
              )
            )
          )
        )
        duckdb$expr_set_alias(tmp_expr, "high_line_count")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_function(
          "sum",
          list(
            duckdb$expr_function(
              "if_else",
              list(
                duckdb$expr_function(
                  "&",
                  list(
                    duckdb$expr_function(
                      "r_base::!=",
                      list(
                        duckdb$expr_reference("o_orderpriority"),
                        if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                          duckdb$expr_constant("1-URGENT", experimental = experimental)
                        } else {
                          duckdb$expr_constant("1-URGENT")
                        }
                      )
                    ),
                    duckdb$expr_function(
                      "r_base::!=",
                      list(
                        duckdb$expr_reference("o_orderpriority"),
                        if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                          duckdb$expr_constant("2-HIGH", experimental = experimental)
                        } else {
                          duckdb$expr_constant("2-HIGH")
                        }
                      )
                    )
                  )
                ),
                if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                  duckdb$expr_constant(1L, experimental = experimental)
                } else {
                  duckdb$expr_constant(1L)
                },
                if ("experimental" %in% names(formals(duckdb$expr_constant))) {
                  duckdb$expr_constant(0L, experimental = experimental)
                } else {
                  duckdb$expr_constant(0L)
                }
              )
            )
          )
        )
        duckdb$expr_set_alias(tmp_expr, "low_line_count")
        tmp_expr
      }
    )
  )
  "summarise"
  rel16 <- duckdb$rel_order(rel15, list(duckdb$expr_reference("___row_number")))
  "summarise"
  rel17 <- duckdb$rel_project(
    rel16,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("high_line_count")
        duckdb$expr_set_alias(tmp_expr, "high_line_count")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("low_line_count")
        duckdb$expr_set_alias(tmp_expr, "low_line_count")
        tmp_expr
      }
    )
  )
  "arrange"
  rel18 <- duckdb$rel_project(
    rel17,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("high_line_count")
        duckdb$expr_set_alias(tmp_expr, "high_line_count")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("low_line_count")
        duckdb$expr_set_alias(tmp_expr, "low_line_count")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_window(duckdb$expr_function("row_number", list()), list(), list(), offset_expr = NULL, default_expr = NULL)
        duckdb$expr_set_alias(tmp_expr, "___row_number")
        tmp_expr
      }
    )
  )
  "arrange"
  rel19 <- duckdb$rel_order(
    rel18,
    list(duckdb$expr_reference("l_shipmode"), duckdb$expr_reference("___row_number"))
  )
  "arrange"
  rel20 <- duckdb$rel_project(
    rel19,
    list(
      {
        tmp_expr <- duckdb$expr_reference("l_shipmode")
        duckdb$expr_set_alias(tmp_expr, "l_shipmode")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("high_line_count")
        duckdb$expr_set_alias(tmp_expr, "high_line_count")
        tmp_expr
      },
      {
        tmp_expr <- duckdb$expr_reference("low_line_count")
        duckdb$expr_set_alias(tmp_expr, "low_line_count")
        tmp_expr
      }
    )
  )
  rel20
  duckdb$rel_to_altrep(rel20)
}
duckdblabs/duckplyr documentation built on Nov. 6, 2024, 10 p.m.