Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for action configs table assertions and hermeticity, add action configs fields tests #1762

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/actions/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export class Operation extends ActionBuilder<dataform.Operation> {
disabled: config.disabled,
hasOutput: config.hasOutput,
description: config.description,
dependOnDependencyAssertions: config.dependOnDependencyAssertions
dependOnDependencyAssertions: config.dependOnDependencyAssertions,
hermetic: config.hermetic === true ? true : undefined
});

this.queries(nativeRequire(config.filename).query);
Expand Down
37 changes: 34 additions & 3 deletions core/actions/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,9 @@ export class Table extends ActionBuilder<dataform.Table> {
disabled: config.disabled,
description: config.description,
bigquery: bigqueryOptions,
dependOnDependencyAssertions: config.dependOnDependencyAssertions
dependOnDependencyAssertions: config.dependOnDependencyAssertions,
hermetic: config.hermetic === true ? true : undefined,
assertions: this.legacyMapConfigAssertions(config.assertions)
});
}
if (tableType === "view") {
Expand Down Expand Up @@ -382,7 +384,9 @@ export class Table extends ActionBuilder<dataform.Table> {
tags: config.tags,
description: config.description,
bigquery: bigqueryOptions,
dependOnDependencyAssertions: config.dependOnDependencyAssertions
dependOnDependencyAssertions: config.dependOnDependencyAssertions,
hermetic: config.hermetic === true ? true : undefined,
assertions: this.legacyMapConfigAssertions(config.assertions)
});
}
if (tableType === "incremental") {
Expand Down Expand Up @@ -435,7 +439,9 @@ export class Table extends ActionBuilder<dataform.Table> {
tags: config.tags,
description: config.description,
bigquery: bigqueryOptions,
dependOnDependencyAssertions: config.dependOnDependencyAssertions
dependOnDependencyAssertions: config.dependOnDependencyAssertions,
hermetic: config.hermetic === true ? true : undefined,
assertions: this.legacyMapConfigAssertions(config.assertions)
});
}
this.query(nativeRequire(tableTypeConfig.filename).query);
Expand Down Expand Up @@ -635,6 +641,7 @@ export class Table extends ActionBuilder<dataform.Table> {
return this;
}

// TODO(ekrekr): update session JS assertions to action construtors instead.
public assertions(assertions: ITableAssertions) {
checkExcessProperties(
(e: Error) => this.session.compileError(e),
Expand Down Expand Up @@ -762,6 +769,30 @@ export class Table extends ActionBuilder<dataform.Table> {
});
return protoOps;
}

private legacyMapConfigAssertions(
configAssertions: dataform.ActionConfig.ITableAssertionsConfig
): ITableAssertions | undefined {
let legacyAssertions: ITableAssertions | undefined;
if (configAssertions) {
legacyAssertions = {};
if (configAssertions.uniqueKey?.length > 0) {
legacyAssertions.uniqueKey = configAssertions.uniqueKey;
}
if (configAssertions.uniqueKeys) {
legacyAssertions.uniqueKeys = configAssertions.uniqueKeys.map(
uniqueKeys => uniqueKeys?.uniqueKey
);
}
if (configAssertions.nonNull?.length > 0) {
legacyAssertions.nonNull = configAssertions.nonNull;
}
if (configAssertions.rowConditions?.length > 0) {
legacyAssertions.rowConditions = configAssertions.rowConditions;
}
}
return legacyAssertions;
}
}

/**
Expand Down
Loading
Loading