Golars

High-performance columnar DataFrame library for Go, modeled after Polars.

Overview

Golars is a high-performance DataFrame library for Go, bringing the speed and expressiveness of columnar data processing (modeled after Polars) directly to the Go ecosystem.

It features columnar memory layouts with null bitmaps, an expression-based DSL, lazy query optimization, and broad format I/O support.


Features

  • Columnar Storage: Efficient memory representation with offset-based strings and null bitmaps.
  • Composable Expression DSL: Type-safe column operations across math, string, temporal, cumulative, and rolling namespaces (col("price").Mul(col("qty")).Alias("total")).
  • Lazy Evaluation Engine: Query optimizer with predicate pushdown, projection pushdown, constant folding, and common subexpression elimination.
  • Join & GroupBy: All 7 join types (Inner, Left, Right, Full, Semi, Anti, Cross) and fast hash-based grouping.
  • SQL Query Interface: Register DataFrames as virtual tables and query with standard SQL, including multi-table joins.
  • Broad I/O Formats: CSV, JSON, NDJSON, Apache Parquet (Snappy compression), Excel (.xlsx), and standard database/sql scanning.
  • Modern Go: Built for Go 1.24+ leveraging generics and range-over-func iterators.

Installation

zsh — go get golars
$ go get github.com/msjurset/golars

Example Usage

package main

import (
    "fmt"
    "github.com/msjurset/golars"
)

func main() {
    df, err := golars.ReadCSV("sales.csv")
    if err != nil {
        panic(err)
    }

    result := df.Lazy().
        Filter(golars.Col("region").Eq(golars.Lit("US"))).
        GroupBy("category").
        Agg(golars.Col("revenue").Sum().Alias("total_revenue")).
        Sort("total_revenue", golars.SortDescending).
        Collect()

    fmt.Println(result)
}