Skip to content

Commit

Permalink
Disable transactions for redshift incremental tables (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewish authored Aug 19, 2020
1 parent 0e661a3 commit 16e1033
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions core/adapters/redshift.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ export class RedshiftAdapter extends Adapter implements IAdapter {
) {
const finalTarget = this.resolveTarget(target);
// Schema name not allowed for temporary tables.
const tempTarget = `"${target.name}_incremental_temp"`;
const tempTarget = `"${target.schema}__${target.name}_incremental_temp"`;
return Tasks.create()
.add(Task.statement(`drop table if exists ${tempTarget};`))
.add(Task.statement(`create temp table ${tempTarget} as select * from (${query});`))
.add(Task.statement(`begin transaction;`))
// TODO: The next two statements should be run in a transaction.
.add(
Task.statement(
`delete from ${finalTarget} using ${tempTarget} where ${uniqueKey
Expand All @@ -161,7 +161,6 @@ export class RedshiftAdapter extends Adapter implements IAdapter {
)
)
.add(Task.statement(`insert into ${finalTarget} select * from ${tempTarget};`))
.add(Task.statement(`end transaction;`))
.add(Task.statement(`drop table ${tempTarget};`));
}
}
2 changes: 1 addition & 1 deletion tests/integration/redshift.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { dataform } from "df/protos/ts";
import { suite, test } from "df/testing";
import { compile, getTableRows, keyBy } from "df/tests/integration/utils";

suite("@dataform/integration/redshift", { parallel: false }, ({ before, after }) => {
suite("@dataform/integration/redshift", { parallel: true }, ({ before, after }) => {
const credentials = dfapi.credentials.read("redshift", "test_credentials/redshift.json");
let dbadapter: dbadapters.IDbAdapter;

Expand Down

0 comments on commit 16e1033

Please sign in to comment.