JEXL script
The Cloudera Lakehouse Optimizer Data Hub contains the default ClouderaAdaptive.jexl file that is a policy script. You can use the script as is. Otherwise, you can use the default JEXL file as a template to add or modify the contents, and then upload the file as a new JEXL file.
// A sample jexl-based policy definition to evaluate the need for expire snapshot and generate action argument
#pragma dlm.statistics true
// Stores the list of generated actions
const actions = [...]
// Fetch iceberg stats
let stats = statistics($table);
if ($constants.expireSnapshot.enabled) {
let min = $table['dlm.expireSnapshot.retainLast'] ?? $constants.expireSnapshot.retainLast ?? 2;
let snapshots = stats.numberOfSnapshots;
let snapshotTimestampDelta = stats.snapshotTimestampDelta ?? 3600000;
let deltaDurationThreshold = $table['dlm.expireSnapshot.snapshotsDurationDeltaMax'] ?? $constants.expireSnapshot.snapshotsDurationDeltaMax ?? 0;
if (snapshots > min || snapshotTimestampDelta > deltaDurationThreshold) {
// create an expire snapshot action
actions.add(dlm:expireSnapshots($table, $constants));
}
}
// return the list of actions
actions| Variables | Description |
|---|---|
$table |
Iceberg table object for which the policy is being
evaluated. For
example, |
$constants |
Set of action argument values and defaults. For example,
|
$catalog |
Iceberg catalog object. |
The policy script supports retrieving the values from the table property or the policy
constants. For example, let filesCountDrop
=$table['dlm.rewriteDataFiles.filesCountDrop'] ?? $constants.rewriteDataFiles.filesCountDrop
?? 0.15;.
For more information about modifying the JEXL script contents, see JEXL syntax.
