Skip to content

Column

Defined in: column.ts:28

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.

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);
const sorted = df.orderBy(col("score").desc_nulls_last());

Spark source: Column.scala

new Column(expr): Column;

Defined in: column.ts:32

ParameterType
exprExpression

Column

alias(name): Column;

Defined in: column.ts:96

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

ParameterType
namestring

Column


and(other): Column;

Defined in: column.ts:65

ParameterType
otherColumn

Column


as(name): Column;

Defined in: column.ts:100

ParameterType
namestring

Column


asc(): Column;

Defined in: column.ts:114

Mark this column as ascending sort order.

Column


asc_nulls_first(): Column;

Defined in: column.ts:134

Ascending sort, nulls first.

Column


asc_nulls_last(): Column;

Defined in: column.ts:144

Ascending sort, nulls last.

Column


between(lower, upper): Column;

Defined in: column.ts:289

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

ParameterType
lowerColumn
upperColumn

Column


bitwiseAND(other): Column;

Defined in: column.ts:194

Bitwise AND.

ParameterType
otherColumn

Column


bitwiseOR(other): Column;

Defined in: column.ts:203

Bitwise OR.

ParameterType
otherColumn

Column


bitwiseXOR(other): Column;

Defined in: column.ts:212

Bitwise XOR.

ParameterType
otherColumn

Column


cast(targetType): Column;

Defined in: column.ts:107

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

ParameterType
targetTypestring

Column


contains(substr): Column;

Defined in: column.ts:341

Test whether this string column contains the given substring.

ParameterType
substrstring

Column


desc(): Column;

Defined in: column.ts:124

Mark this column as descending sort order.

Column


desc_nulls_first(): Column;

Defined in: column.ts:149

Descending sort, nulls first.

Column


desc_nulls_last(): Column;

Defined in: column.ts:159

Descending sort, nulls last.

Column


divide(other): Column;

Defined in: column.ts:87

ParameterType
otherColumn

Column


dropFields(...fieldNames): Column;

Defined in: column.ts:265

Drop field(s) from a StructType column.

ParameterType
fieldNamesstring[]

Column


endsWith(suffix): Column;

Defined in: column.ts:332

Test whether this string column ends with the given suffix.

ParameterType
suffixstring

Column


eq(other): Column;

Defined in: column.ts:47

ParameterType
otherColumn

Column


eqNullSafe(other): Column;

Defined in: column.ts:183

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

ParameterType
otherColumn

Column


getField(fieldName): Column;

Defined in: column.ts:238

Access a field in a StructType column by name.

ParameterType
fieldNamestring

Column


getItem(key): Column;

Defined in: column.ts:247

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

ParameterType
keystring | number

Column


gt(other): Column;

Defined in: column.ts:39

ParameterType
otherColumn

Column


gte(other): Column;

Defined in: column.ts:55

ParameterType
otherColumn

Column


ilike(pattern): Column;

Defined in: column.ts:305

Case-insensitive LIKE pattern match.

ParameterType
patternstring

Column


isin(...values): Column;

Defined in: column.ts:280

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

ParameterType
values(string | number | bigint | boolean | null)[]

Column


isNaN(): Column;

Defined in: column.ts:176

Test whether this column value is NaN.

Column


isNotNull(): Column;

Defined in: column.ts:171

Test whether this column is not null.

Column


isNull(): Column;

Defined in: column.ts:166

Test whether this column is null.

Column


like(pattern): Column;

Defined in: column.ts:296

SQL LIKE pattern match.

ParameterType
patternstring

Column


lt(other): Column;

Defined in: column.ts:43

ParameterType
otherColumn

Column


lte(other): Column;

Defined in: column.ts:59

ParameterType
otherColumn

Column


minus(other): Column;

Defined in: column.ts:79

ParameterType
otherColumn

Column


multiply(other): Column;

Defined in: column.ts:83

ParameterType
otherColumn

Column


neq(other): Column;

Defined in: column.ts:51

ParameterType
otherColumn

Column


or(other): Column;

Defined in: column.ts:69

ParameterType
otherColumn

Column


over(windowSpec): Column;

Defined in: column.ts:352

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

ParameterType
windowSpecWindowSpec

Column


plus(other): Column;

Defined in: column.ts:75

ParameterType
otherColumn

Column


rlike(pattern): Column;

Defined in: column.ts:314

SQL RLIKE (regex) pattern match.

ParameterType
patternstring

Column


startsWith(prefix): Column;

Defined in: column.ts:323

Test whether this string column starts with the given prefix.

ParameterType
prefixstring

Column


substr(startPos, length): Column;

Defined in: column.ts:223

Extract a substring (1-based position).

ParameterType
startPosnumber
lengthnumber

Column


withField(fieldName, col): Column;

Defined in: column.ts:256

Add or replace a field in a StructType column.

ParameterType
fieldNamestring
colColumn

Column