Class: Column

eclairjs/sql.Column

A column in a DataFrame.

Constructor

new Column(column)

Parameters:
Name Type Description
column string name of the column
Source:

Methods

alias(alias) → {module:eclairjs/sql.Column}

Gives the column an alias. Same as as.
Parameters:
Name Type Description
alias string
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
// Renames colA to colB in select output.
df.select(df.col("colA").alias("colB"))

and(other) → {module:eclairjs/sql.Column}

Boolean AND.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("inSchool").and(people.col("isEmployed")));

as(aliases,, metadataopt) → {module:eclairjs/sql.Column}

Gives the column an alias.
Parameters:
Name Type Attributes Description
aliases, string | Array.<string> if array of strings assigns the given aliases to the results of a table generating function.
metadata module:eclairjs/sql/types.Metadata <optional>
not valid with string array
Source:
Returns:
Type
module:eclairjs/sql.Column

asc() → {module:eclairjs/sql.Column}

Returns an ordering used in sorting.
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.sort(df.col("age").asc());

between(lowerBound, upperBound) → {module:eclairjs/sql.Column}

True if the current column is between the lower bound and upper bound, inclusive.
Parameters:
Name Type Description
lowerBound object
upperBound object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
var col = new Column("age");
var testCol = col.between(10, 29);
var results = peopleDataFrame.select(testCol);

bitwiseAND(other) → {module:eclairjs/sql.Column}

Compute bitwise AND of this expression with another expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.select(df.col("colA").bitwiseAND(df.col("colB")));

bitwiseOR(other) → {module:eclairjs/sql.Column}

Compute bitwise OR of this expression with another expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.select(df.col("colA").bitwiseOR(df.col("colB")));

bitwiseXOR(other) → {module:eclairjs/sql.Column}

Compute bitwise XOR of this expression with another expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.select(df.col("colA").bitwiseXOR(df.col("colB")));

cast(to) → {module:eclairjs/sql.Column}

Casts the column to a different data type.
Parameters:
Name Type Description
to DataType | string If string supported types are: `string`, `boolean`, `int`, `float`, `double`, `date`, `timestamp`.
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
// Casts colA to IntegerType.
  df.select(df("colA").cast(DataTypes.IntegerType))

  // equivalent to
  df.select(df.col("colA").cast("int"))

contains(other) → {module:eclairjs/sql.Column}

Contains the other element.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column

desc() → {module:eclairjs/sql.Column}

Returns an ordering used in sorting.
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.sort(df.col("age").desc());

divide(other) → {module:eclairjs/sql.Column}

Division this expression by another expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("height").divide(people.col("weight")) );

endsWith(other,) → {module:eclairjs/sql.Column}

String ends with. with another string literal
Parameters:
Name Type Description
other, string | Column if string ends with another string literal.
Source:
Returns:
Type
module:eclairjs/sql.Column

eqNullSafe(other) → {module:eclairjs/sql.Column}

Equality test that is safe for null values.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column

equals(that) → {boolean}

Equality test
Parameters:
Name Type Description
that object
Source:
Returns:
Type
boolean

equalTo(other) → {module:eclairjs/sql.Column}

Equality test
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column

explain() → {Promise.<Void>}

Prints the expression to the console for debugging purpose.
Source:
Returns:
A Promise that resolves to nothing.
Type
Promise.<Void>

geq(other) → {module:eclairjs/sql.Column}

Greater than or equal to an expression.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("age").geq(21) )

getField(fieldName) → {module:eclairjs/sql.Column}

An expression that gets a field by name in a StructType.
Parameters:
Name Type Description
fieldName string
Source:
Returns:
Type
module:eclairjs/sql.Column

getItem(key) → {module:eclairjs/sql.Column}

An expression that gets an item at position `ordinal` out of an array, or gets a value by key `key` in a MapType.
Parameters:
Name Type Description
key object
Source:
Returns:
Type
module:eclairjs/sql.Column

gt(other) → {module:eclairjs/sql.Column}

Greater than.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("age").gt(21) );

hashCode() → {Promise.<Integer>}

Source:
Returns:
A Promise that resolves to the hashcode.
Type
Promise.<Integer>

in(list) → {module:eclairjs/sql.Column}

A boolean expression that is evaluated to true if the value of this expression is contained by the evaluated values of the arguments.
Parameters:
Name Type Description
list array
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
var col = peopleDataFrame.col("age");
var testCol = col.in([20, 19]);
var results = peopleDataFrame.select(testCol);

isin(list) → {module:eclairjs/sql.Column}

A boolean expression that is evaluated to true if the value of this expression is contained by the evaluated values of the arguments.
Parameters:
Name Type Description
list array
Source:
Returns:
Type
module:eclairjs/sql.Column

isNaN() → {module:eclairjs/sql.Column}

True if the current expression is NaN.
Source:
Returns:
Type
module:eclairjs/sql.Column

isNotNull() → {module:eclairjs/sql.Column}

True if the current expression is NOT null.
Source:
Returns:
Type
module:eclairjs/sql.Column

isNull() → {module:eclairjs/sql.Column}

True if the current expression is null.
Source:
Returns:
Type
module:eclairjs/sql.Column

leq(other) → {module:eclairjs/sql.Column}

Less than or equal to.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("age").leq(21) );

like(literal) → {module:eclairjs/sql.Column}

SQL like expression.
Parameters:
Name Type Description
literal string
Source:
Returns:
Type
module:eclairjs/sql.Column

lt(other) → {module:eclairjs/sql.Column}

Less than.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("age").lt(21) );

minus(other) → {module:eclairjs/sql.Column}

Subtraction. Subtract the other expression from this expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("height").minus(people.col("weight")) );

mod(other) → {module:eclairjs/sql.Column}

Modulo (a.k.a. remainder) expression.
Parameters:
Name Type Description
other object
Source:
Returns:
Type
module:eclairjs/sql.Column

multiply(other) → {module:eclairjs/sql.Column}

Multiplication of this expression and another expression.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select( people.col("height").multiply(people.col("weight")) );

notEqual(other) → {module:eclairjs/sql.Column}

Inequality test.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
df.filter( df.col("colA").notEqual(df.col("colB")) );

or(other) → {module:eclairjs/sql.Column}

Boolean OR.
Parameters:
Name Type Description
other module:eclairjs/sql.Column
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.filter( people.col("inSchool").or(people.col("isEmployed")) );

otherwise(value) → {module:eclairjs/sql.Column}

Evaluates a list of conditions and returns one of multiple possible result expressions. If otherwise is not defined at the end, null is returned for unmatched conditions.
Parameters:
Name Type Description
value object
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select(functions.when(people.col("gender").equalTo("male"), 0)
    .when(people.col("gender").equalTo("female"), 1)
    .otherwise(2))

plus(other) → {module:eclairjs/sql.Column}

Sum of this expression and another expression.
Parameters:
Name Type Description
other object
Since:
  • EclairJS 0.7 Spark 1.3.0
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
// Scala: The following selects the sum of a person's height and weight.
  people.select( people("height") + people("weight") )

  // Java:
  people.select( people("height").plus(people("weight")) );

when() → {module:eclairjs/sql.Column}

Evaluates a list of conditions and returns one of multiple possible result expressions. If otherwise is not defined at the end, null is returned for unmatched conditions.
Source:
Returns:
Type
module:eclairjs/sql.Column
Example
people.select(functions.when(people.col("gender").equalTo("male"), 0)
    .when(people.col("gender").equalTo("female"), 1)
    .otherwise(2))