G.8. Reading Delta Datasets (delta_scan) #
Before reading Delta datasets, configure the Delta extension.
Required privileges: Superuser or the Postgres Pro AXE administrator.
For more information about access management, refer to Chapter 17.
Execute the following command on the Postgres Pro AXE server:
SELECT * FROM delta_scan('path', optional_parameters);
Where:
path: The path to the Delta dataset that must be read.optional_parameters: The optional parameters, specified in theparameter := valueformat.Available parameters:
delta_file_number: Specifies whether to return thedelta_file_numbercolumn with the index of the physical Parquet file for each row.Possible values:
truefalse
Default value:
false.binary_as_string: Specifies whether to return binary columns as strings.Possible values:
truefalse
Default value:
false.filename: Specifies whether to return thefilenamecolumn with file paths. Since DuckDB v1.3.0, this column is added automatically.Possible values:
truefalse
Default value:
false.file_row_number: Specifies whether to return thefile_row_numbercolumn with row numbers of Parquet files.Possible values:
truefalse
Default value:
false.hive_partitioning: Specifies whether the directory is associated with a partitioned analytical table and whether partition columns are returned.Possible values:
truefalse
Default value: Detected automatically based on the directory structure.
For more information about Hive partitioning, refer to Section 15.2.
hive_types: The data types of partition columns, specified as aSTRUCTvalue.If the
hive_types_autocastparameter is set totrue, theDATE,TIMESTAMP, andBIGINTdata types are detected automatically.Default value:
''.For more information about Hive partitioning, refer to Section 15.2.
hive_types_autocast: Specifies whether to detect theDATE,TIMESTAMP, andBIGINTdata types of partition columns automatically.Possible values:
truefalse
You can specify data types of partition columns manually using the
hive_typesparameter.Default value:
true.union_by_name: Specifies whether columns from different files are aligned by name instead of by position.Possible values:
truefalse
If this parameter is set to
true, memory consumption increases.Default value:
false.schema: The custom schema for reading Parquet files, specified as aMAPvalue.
Postgres Pro AXE will return rows of the Delta dataset.
Example G.10. Reading a Delta Dataset
SELECT * FROM delta_scan('data/delta/dataset');
id | name | age
----+---------+-----
1 | Alice | 30
2 | Bob | 25
3 | Charlie | 35
You can select specific columns by assigning an alias to a procedure, such as r, and using the r[' syntax: column_name']
SELECT r['id'], r['name'] FROM delta_scan('data/delta/dataset') r WHERE r['age'] = 25;
id | name ----+------ 2 | Bob