Skip to contents

Execute SQL query

Usage

polarssql_query(sql, conn = polarssql_default_connection())

Arguments

sql

A SQL string.

conn

A polarssql connection, created by polarssql(). Use the default built-in connection by default.

Examples

polarssql_register(mtcars = mtcars)

query <- "SELECT * FROM mtcars LIMIT 5"

# Returns a polars LazyFrame
polarssql_query(query)
#> polars LazyFrame
#>  $describe_optimized_plan() : Show the optimized query plan.
#> 
#> Naive plan:
#> SLICE[offset: 0, len: 5]
#>    SELECT [col("mpg"), col("cyl"), col("disp"), col("hp"), col("drat"), col("wt"), col("qsec"), col("vs"), col("am"), col("gear"), col("carb")] FROM
#>     DF ["mpg", "cyl", "disp", "hp"]; PROJECT */11 COLUMNS; SELECTION: None

# Clean up
polarssql_unregister("mtcars")