For the complete documentation index, see llms.txt. This page is also available as Markdown.

Supported APIs and compatibility notes

The PySpark DataFrame operations, SQL functions, and read/write formats supported by the e6data compatibility layer, with end-to-end code samples.

This page lists the DataFrame operations, SQL functions, and file formats supported by e6-spark-compat, followed by end-to-end code samples. For setup, see PySpark compatibility.

DataFrame operations

Transformations are lazy - they build a query plan without executing. Execution is triggered only when an action is called.

Transformations

Method
Description

select(*cols)

Select columns / expressions

selectExpr(*exprs)

Select using SQL expressions

filter(condition) / where()

Filter rows

join(other, on, how)

Join DataFrames

crossJoin(other)

Cross join

groupBy(*cols)

Group for aggregation

orderBy(*cols) / sort()

Sort rows

limit(n)

Limit to first n rows

distinct()

Remove duplicate rows

union(other)

Union (all)

unionByName(other)

Union matching by name

intersect(other)

Set intersection

exceptAll(other)

Set difference

withColumn(name, col)

Add / replace a column

withColumnRenamed(old, new)

Rename a column

drop(*cols)

Drop columns

cache() / persist()

Cache hint (pass-through)

coalesce(n)

Repartition hint

Supported join types: inner, left, right, full, cross, left_semi, left_anti.

Actions

Actions trigger query execution on e6data and return results.

Method
Description

collect()

Return all rows as a list of Rows

count()

Return the total row count

show(n)

Print the first n rows (default 20)

first()

Return the first row

head(n)

Return the first n rows

take(n)

Return the first n rows as a list

toPandas()

Convert results to a Pandas DataFrame

explain()

Print the generated SQL query

describe(*cols)

Compute summary statistics

Temporary views

Read formats

Format
Method

Parquet

spark.read.parquet(path)

ORC

spark.read.orc(path)

CSV

spark.read.csv(path)

JSON

spark.read.json(path)

GeoParquet

spark.read.format("geoparquet").load(path)

GeoJSON

spark.read.format("geojson").load(path)

Delta

spark.read.format("delta").load(path)

Text

spark.read.text(path)

Write modes

Use df.write to save results - .parquet(), .csv(), .partitionBy(...), .insertInto("table"), or .saveAsTable("table").

Mode
Behavior

error

Throw an error if data already exists (default)

append

Append to existing data

overwrite

Overwrite existing data

ignore

Silently skip if data already exists

SQL functions

All functions are imported from e6_spark_compat.sql.functions.

Column references and literals

Function
Description

col(name)

Reference a column

lit(value)

Create a literal value

expr(sql)

Raw SQL expression

String functions

upper, lower, trim, ltrim, rtrim, length, substring(col, pos, len), concat(*cols), concat_ws(sep, *cols), split(col, pattern), regexp_extract(col, pattern, idx), regexp_replace(col, pattern, rep), translate, lpad, rpad, repeat, reverse, format_string, format_number.

Math functions

abs, round(col, scale), floor, ceil, sqrt, pow(col, exp), log, log10, exp, sin, cos, tan, asin, acos, atan, atan2, greatest(*cols), least(*cols).

Aggregate functions

count, countDistinct(*cols), sum, avg, min, max, first, last, collect_list, collect_set, stddev, variance, approx_percentile(col, pct).

Date and time functions

Function
Description

current_date() / current_timestamp()

Current date / timestamp

year, month, day / dayofmonth, hour, minute, second

Extract date parts

date_add(col, days) / date_sub(col, days)

Add / subtract days

datediff(end, start)

Difference in days

to_date(col, fmt) / to_timestamp(col, fmt)

Convert to date / timestamp

from_unixtime(col, fmt) / unix_timestamp(col, fmt)

Unix-timestamp conversions

Conditional functions

when(condition, value) (chainable with .when(...) / .otherwise(...)), coalesce(*cols), isnull, isnan, if_(condition, true, false).

JSON, array, and other functions

to_json, from_json(col, schema), get_json_object(col, path); explode(col); broadcast(df), cast(col, type).

Window functions are supported via the full Window specification API (partitionBy, orderBy, rowsBetween, rangeBetween) with row_number, rank, lag, lead, and aggregates over a window.

Code samples

Basic analytics pipeline

Window functions: rankings and running totals

Multi-table join

CASE WHEN logic

Spatial analysis: points in polygons

SQL via temp views, and export to Pandas

Writing results

See also

Last updated

Was this helpful?