Skip to main content

ORC

The ORC (Optimized Row Columnar) file type:

  • Is a columnar file format designed for Spark and Hadoop workloads.
  • Offers high compression ratios, which helps reduce storage costs.
  • Optimizes for large streaming reads, but with integrated support for finding required rows quickly.
  • Is type-aware, which means it can choose an encoding for the type and builds an internal index while you write to the file.

Parameters

ParameterTabDescription
LocationLocationFile path to read from or write to the ORC file.
SchemaPropertiesSchema to apply on the loaded data.
In the Source gem, you can define or edit the schema visually or in JSON code.
In the Target gem, you can view the schema visually or as JSON code.

Source

The Source gem reads data from ORC files and allows you to optionally specify the following additional properties.

Source properties

Property nameDescriptionDefault
DescriptionDescription of your dataset.None
Use user-defined schemaWhether to use the schema you define.false
Recursive File LookupWhether to recursively load files and disable partition inferring. If the data source explicitly specifies the partitionSpec when therecursiveFileLookup is true, the Source gem throws an exception.false

Example

ORC source example

Generated Code

tip

To see the generated source code of your project, switch to the Code view in the project header.

def read_orc(spark: SparkSession) -> DataFrame:
return spark.read\
.format("orc")\
.load("dbfs:/FileStore/Users/orc/test.orc")

Target

The Target gem writes data to ORC files and allows you to optionally specify the following additional properties.

Target properties

Property nameDescriptionDefault
DescriptionDescription of your dataset.None
Write ModeHow to handle existing data. For a list of the possible values, see Supported write modes.error
Partition ColumnsList of columns to partition the ORC files by.None
Compression CodecCompression codec when writing to the ORC file.
The ORC file supports the following codecs: none, snappy, zlib, and lzo.
snappy

Supported write modes

Write modeDescription
errorIf the data already exists, throw an exception.
overwriteIf the data already exists, overwrite the data with the contents of the DataFrame.
appendIf the data already exists, append the contents of the DataFrame.
ignoreIf the data already exists, do nothing with the contents of the DataFrame.
This is similar to the CREATE TABLE IF NOT EXISTS clause in SQL.

Example

ORC target example

Generated Code

tip

To see the generated source code of your project, switch to the Code view in the project header.

def write_orc(spark: SparkSession, in0: DataFrame):
in0.write\
.format("orc")\
.mode("overwrite")\
.save("dbfs:/data/test_output.orc")