Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Lance format Lance Java SqlExpressions

From Leeroopedia
Revision as of 15:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Lance_format_Lance_Java_SqlExpressions.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Java_SDK, Dataset_Management
Last Updated 2026-02-08 19:33 GMT

Overview

Description

The SqlExpressions class represents a list of named SQL expressions for computed column generation. Each expression consists of a name (the target column name) and an expression (a SQL expression string that can reference existing columns in the dataset). The evaluated expression becomes the value of the new column.

The class uses an immutable outer container with an inner SqlExpression class that follows the JavaBean pattern (getter/setter). The Builder provides a fluent withExpression(name, expr) method that creates and appends SqlExpression entries incrementally.

Usage

Use SqlExpressions to define computed columns when adding new columns to a Lance dataset. Each expression is evaluated against existing dataset columns to produce new column values. This is commonly used with update or add-column operations.

Code Reference

Source Location

java/src/main/java/org/lance/schema/SqlExpressions.java

Signature

public class SqlExpressions {
    public List<SqlExpression> getSqlExpressions();

    public static class SqlExpression {
        public String getName();
        public void setName(String name);
        public String getExpression();
        public void setExpression(String expression);
    }

    public static class Builder {
        public Builder();
        public Builder withExpression(String name, String expr);
        public SqlExpressions build();
    }
}

Import

import org.lance.schema.SqlExpressions;
import org.lance.schema.SqlExpressions.SqlExpression;

I/O Contract

Builder Inputs
Parameter Type Required Description
name String Yes The name for the new computed column
expr String Yes SQL expression string referencing existing dataset columns
Outputs
Method Return Type Description
getSqlExpressions() List<SqlExpression> The list of named SQL expressions
SqlExpression Properties
Property Type Description
name String Column name for the computed result
expression String SQL expression evaluated against existing columns

Usage Examples

// Define computed columns using SQL expressions
SqlExpressions expressions = new SqlExpressions.Builder()
    .withExpression("full_name", "first_name || ' ' || last_name")
    .withExpression("age_group", "CASE WHEN age < 18 THEN 'minor' ELSE 'adult' END")
    .withExpression("score_normalized", "score / 100.0")
    .build();

// Access individual expressions
for (SqlExpression expr : expressions.getSqlExpressions()) {
    System.out.println(expr.getName() + " = " + expr.getExpression());
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment