Skip to content

[Bug] Incorrect compile error message with tests for incremental tables #1989

Open

Description

@kumaS-nu

Problem

When compiling code with test for an incremental table, dataform returns an incorrect error message.

Expected behavior

The compile error should be: Running tests on incremental datasets is not yet supported.

Actual behavior

The compile error is: Dataset xxx could not be found.

Minimal Reproduction

definitions/sample.sqlx


config { type: "incremental", name: "sample" }

SELECT * FROM ${ref("sample-ref")}

definitions/test.js

test("sample-test")
  .database("sample")
  .input("sample-ref", "SELECT 1 AS foo")
  .expect("SELECT 1 AS foo")

definitions/sample-ref.sqlx


config { type: "declaration", schema: "bar", name: "sample-ref" }

Suggested Fix

It seems that changing the following conditions might be enough to fix this.

const dataset = allResolved.length > 0 ? allResolved[0] : undefined;
if (!(dataset && (dataset instanceof Table || dataset instanceof View))) {
this.session.compileError(
new Error(`Dataset ${stringifyResolvable(this.datasetToTest)} could not be found.`),
this.proto.fileName
);
} else if (dataset instanceof IncrementalTable) {
this.session.compileError(
new Error("Running tests on incremental datasets is not yet supported."),
this.proto.fileName
);
} else {

likes

       const dataset = allResolved.length > 0 ? allResolved[0] : undefined;
-      if (!(dataset && (dataset instanceof Table || dataset instanceof View))) {
+      if (!(dataset && (dataset instanceof Table || dataset instanceof View || dataset instanceof IncrementalTable))) {
         this.session.compileError(
           new Error(`Dataset ${stringifyResolvable(this.datasetToTest)} could not be found.`),
           this.proto.fileName
         );
       } else if (dataset instanceof IncrementalTable) {
         this.session.compileError(
           new Error("Running tests on incremental datasets is not yet supported."),
           this.proto.fileName
         );
       } else {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions