How to use the @dataform/core/adapters.create function in @dataform/core

To help you get started, we’ve selected a few @dataform/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dataform-co / dataform / tests / integration / redshift.spec.ts View on Github external
it("run", async () => {
    const credentials = dfapi.credentials.read("redshift", "df/test_credentials/redshift.json");

    const compiledGraph = await dfapi.compile({
      projectDir: "df/tests/integration/redshift_project"
    });

    expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
    expect(compiledGraph.graphErrors.validationErrors).to.eql([]);

    const dbadapter = dbadapters.create(credentials, "redshift");
    const adapter = adapters.create(compiledGraph.projectConfig);

    // Redshift transactions are giving us headaches here. Drop tables sequentially.
    const dropFunctions = [].concat(
      compiledGraph.tables.map(table => () =>
        dbadapter.execute(adapter.dropIfExists(table.target, adapter.baseTableType(table.type)))
      ),
      compiledGraph.assertions.map(assertion => () =>
        dbadapter.execute(adapter.dropIfExists(assertion.target, "view"))
      )
    );
    await dropFunctions.reduce((promiseChain, fn) => promiseChain.then(fn), Promise.resolve());

    // Run the tests.
    const testResults = await dfapi.test(credentials, "redshift", compiledGraph.tests);
    expect(testResults).to.eql([
      { name: "successful", successful: true },
github dataform-co / dataform / tests / integration / sqldatawarehouse.spec.ts View on Github external
it("run", async () => {
    const credentials = dfapi.credentials.read(
      "sqldatawarehouse",
      "df/test_credentials/sqldatawarehouse.json"
    );

    const compiledGraph = await dfapi.compile({
      projectDir: "df/tests/integration/sqldatawarehouse_project"
    });

    expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
    expect(compiledGraph.graphErrors.validationErrors).to.eql([]);

    const dbadapter = dbadapters.create(credentials, "sqldatawarehouse");
    const adapter = adapters.create(compiledGraph.projectConfig);

    // Drop all the tables before we do anything.
    await dropAllTables(compiledGraph, adapter, dbadapter);

    // Run the tests.
    const testResults = await dfapi.test(credentials, "sqldatawarehouse", compiledGraph.tests);
    expect(testResults).to.eql([
      { name: "successful", successful: true },
      {
        name: "expected more rows than got",
        successful: false,
        messages: ["Expected 3 rows, but saw 2 rows."]
      },
      {
        name: "expected fewer columns than got",
        successful: false,
github dataform-co / dataform / tests / integration / snowflake.spec.ts View on Github external
it("run", async () => {
    const compiledGraph = await dfapi.compile({
      projectDir: "df/tests/integration/snowflake_project"
    });

    expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
    expect(compiledGraph.graphErrors.validationErrors).to.eql([]);

    const adapter = adapters.create(compiledGraph.projectConfig, compiledGraph.dataformCoreVersion);

    // Drop all the tables before we do anything.
    await dropAllTables(compiledGraph, adapter, dbadapter);

    // Run the tests.
    const testResults = await dfapi.test(credentials, "snowflake", compiledGraph.tests);
    expect(testResults).to.eql([
      { name: "successful", successful: true },
      {
        name: "expected more rows than got",
        successful: false,
        messages: ["Expected 3 rows, but saw 2 rows."]
      },
      {
        name: "expected fewer columns than got",
        successful: false,
github dataform-co / dataform / tests / integration / bigquery.spec.ts View on Github external
it("run", async () => {
    const compiledGraph = await dfapi.compile({
      projectDir: "df/tests/integration/bigquery_project"
    });

    expect(compiledGraph.graphErrors.compilationErrors).to.eql([]);
    expect(compiledGraph.graphErrors.validationErrors).to.eql([]);

    const adapter = adapters.create(compiledGraph.projectConfig, compiledGraph.dataformCoreVersion);

    // Drop all the tables before we do anything.
    await dropAllTables(compiledGraph, adapter, dbadapter);

    // Run the tests.
    const testResults = await dfapi.test(credentials, "bigquery", compiledGraph.tests);
    expect(testResults).to.eql([
      { name: "successful", successful: true },
      {
        name: "expected more rows than got",
        successful: false,
        messages: ["Expected 3 rows, but saw 2 rows."]
      },
      {
        name: "expected fewer columns than got",
        successful: false,
github dataform-co / dataform / tests / integration / utils.ts View on Github external
export function getTestConfig(warehouse: string): ITestConfig {
  const profilePath = `df/test_profiles/${warehouse}.json`;
  const profile = fs.existsSync(profilePath)
    ? JSON.parse(fs.readFileSync(profilePath, "utf8"))
    : null;
  const projectDir = `df/examples/${warehouse}`;
  const projectConf = JSON.parse(fs.readFileSync(path.join(projectDir, "./dataform.json"), "utf8"));
  const adapter = create({ ...projectConf, gcloudProjectId: null });

  return {
    warehouse,
    profile,
    projectDir,
    projectConf,
    defaultSchema: projectConf.defaultSchema,
    assertionSchema: projectConf.assertionSchema,
    adapter
  };
}
github dataform-co / dataform / core / session.ts View on Github external
public adapter(): adapters.IAdapter {
    return adapters.create(this.config);
  }
github dataform-co / dataform / core / session.ts View on Github external
public adapter(): adapters.IAdapter {
    return adapters.create(this.config, dataformCoreVersion);
  }