Method: Polars::SQLContext#register

Defined in:
lib/polars/sql_context.rb

#register(name, frame) ⇒ SQLContext

Register a single frame as a table, using the given name.

Examples:

df = Polars::DataFrame.new({"hello" => ["world"]})
ctx = Polars::SQLContext.new
ctx.register("frame_data", df).execute("SELECT * FROM frame_data").collect
# =>
# shape: (1, 1)
# ┌───────┐
# │ hello │
# │ ---   │
# │ str   │
# ╞═══════╡
# │ world │
# └───────┘

Parameters:

  • name (String)

    Name of the table.

  • frame (Object)

    eager/lazy frame to associate with this table name.

Returns:



123
124
125
126
127
128
129
# File 'lib/polars/sql_context.rb', line 123

def register(name, frame)
  if frame.is_a?(DataFrame)
    frame = frame.lazy
  end
  _ctxt.register(name.to_s, frame._ldf)
  self
end