Skip to content

Column

Defined in: column.ts:47

A reference to a column expression, typically obtained from col or from methods on a DataFrame such as df.col("name").

Every method on Column returns a new Column that wraps a new expression tree node; the original is never mutated. The combined tree is serialised to a Spark Connect Expression protobuf when the plan is sent to the server.

Build a filter predicate

import { col, lit } from "@spark-connect-js/core";
const predicate = col("age").gte(lit(18)).and(col("country").eq(lit("NL")));
const adults = df.filter(predicate);

Build a sort key

const sorted = df.orderBy(col("score").desc_nulls_last());

Spark source: Column.scala

new Column(expr): Column;

Defined in: column.ts:51

Parameter Type
expr Expression

Column

alias(name): Column;

Defined in: column.ts:116

Rename this column expression. Maps to Catalyst’s Alias(expr, name).

Parameter Type
name string

Column


and(other): Column;

Defined in: column.ts:85

Parameter Type
other ColOrLiteral

Column


as(name): Column;

Defined in: column.ts:120

Parameter Type
name string

Column


asc(): Column;

Defined in: column.ts:134

Mark this column as ascending sort order.

Column


asc_nulls_first(): Column;

Defined in: column.ts:154

Ascending sort, nulls first.

Column


asc_nulls_last(): Column;

Defined in: column.ts:164

Ascending sort, nulls last.

Column


between(lower, upper): Column;

Defined in: column.ts:309

Test whether this column’s value is between lower and upper (inclusive).

Parameter Type
lower ColOrLiteral
upper ColOrLiteral

Column


bitwiseAND(other): Column;

Defined in: column.ts:214

Bitwise AND.

Parameter Type
other ColOrLiteral

Column


bitwiseOR(other): Column;

Defined in: column.ts:223

Bitwise OR.

Parameter Type
other ColOrLiteral

Column


bitwiseXOR(other): Column;

Defined in: column.ts:232

Bitwise XOR.

Parameter Type
other ColOrLiteral

Column


cast(targetType): Column;

Defined in: column.ts:127

Cast this column to the given type string (e.g. “string”, “int”, “double”).

Parameter Type
targetType string

Column


contains(substr): Column;

Defined in: column.ts:361

Test whether this string column contains the given substring.

Parameter Type
substr string

Column


desc(): Column;

Defined in: column.ts:144

Mark this column as descending sort order.

Column


desc_nulls_first(): Column;

Defined in: column.ts:169

Descending sort, nulls first.

Column


desc_nulls_last(): Column;

Defined in: column.ts:179

Descending sort, nulls last.

Column


divide(other): Column;

Defined in: column.ts:107

Parameter Type
other ColOrLiteral

Column


dropFields(...fieldNames): Column;

Defined in: column.ts:285

Drop field(s) from a StructType column.

Parameter Type
fieldNames string[]

Column


endsWith(suffix): Column;

Defined in: column.ts:352

Test whether this string column ends with the given suffix.

Parameter Type
suffix string

Column


eq(other): Column;

Defined in: column.ts:67

Parameter Type
other ColOrLiteral

Column


eqNullSafe(other): Column;

Defined in: column.ts:203

Null-safe equality comparison (returns true when both sides are null).

Parameter Type
other ColOrLiteral

Column


getField(fieldName): Column;

Defined in: column.ts:258

Access a field in a StructType column by name.

Parameter Type
fieldName string

Column


getItem(key): Column;

Defined in: column.ts:267

Access an element in an ArrayType or MapType column by key/index.

Parameter Type
key string | number

Column


gt(other): Column;

Defined in: column.ts:59

Parameter Type
other ColOrLiteral

Column


gte(other): Column;

Defined in: column.ts:75

Parameter Type
other ColOrLiteral

Column


ilike(pattern): Column;

Defined in: column.ts:325

Case-insensitive LIKE pattern match.

Parameter Type
pattern string

Column


isin(...values): Column;

Defined in: column.ts:300

Test whether this column’s value is in the given list.

Parameter Type
values (string | number | bigint | boolean | null)[]

Column


isNaN(): Column;

Defined in: column.ts:196

Test whether this column value is NaN.

Column


isNotNull(): Column;

Defined in: column.ts:191

Test whether this column is not null.

Column


isNull(): Column;

Defined in: column.ts:186

Test whether this column is null.

Column


like(pattern): Column;

Defined in: column.ts:316

SQL LIKE pattern match.

Parameter Type
pattern string

Column


lt(other): Column;

Defined in: column.ts:63

Parameter Type
other ColOrLiteral

Column


lte(other): Column;

Defined in: column.ts:79

Parameter Type
other ColOrLiteral

Column


minus(other): Column;

Defined in: column.ts:99

Parameter Type
other ColOrLiteral

Column


multiply(other): Column;

Defined in: column.ts:103

Parameter Type
other ColOrLiteral

Column


neq(other): Column;

Defined in: column.ts:71

Parameter Type
other ColOrLiteral

Column


or(other): Column;

Defined in: column.ts:89

Parameter Type
other ColOrLiteral

Column


over(windowSpec): Column;

Defined in: column.ts:372

Apply a window specification to this (window function) column.

Parameter Type
windowSpec WindowSpec

Column


plus(other): Column;

Defined in: column.ts:95

Parameter Type
other ColOrLiteral

Column


rlike(pattern): Column;

Defined in: column.ts:334

SQL RLIKE (regex) pattern match.

Parameter Type
pattern string

Column


startsWith(prefix): Column;

Defined in: column.ts:343

Test whether this string column starts with the given prefix.

Parameter Type
prefix string

Column


substr(startPos, length): Column;

Defined in: column.ts:243

Extract a substring (1-based position).

Parameter Type
startPos number
length number

Column


withField(fieldName, col): Column;

Defined in: column.ts:276

Add or replace a field in a StructType column.

Parameter Type
fieldName string
col Column

Column