cube-js/cube · error

Missing `COPY INTO` query result.

Error message

Missing `COPY INTO` query result.

What it means

Guard in unloadWithSql after executing the COPY INTO statement: Snowflake returned no result rows (or an empty result) for the unload, so the driver cannot read the exported row count from the UnloadResponse.

Source

Thrown at packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts:613

    if (!options.query) {
      throw new Error('Unload query is missed.');
    } else {
      const types = await this.queryColumnTypes(options.query.sql, options.query.params);
      const connection = await this.getConnection();
      const bucketUrl = this.buildBucketUrl(tableName);

      const unloadSql = `
        COPY INTO '${bucketUrl}'
        FROM (${options.query.sql})
        ${this.exportOptionsClause(options)}`;
      const result = await this.execute<UnloadResponse[]>(
        connection,
        unloadSql,
        options.query.params,
        false,
      );
      if (!result) {
        throw new Error('Missing `COPY INTO` query result.');
      }
      return { types, exportedCount: parseInt(result[0].rows_unloaded, 10) };
    }
  }

  /**
   * Returns an array of queried fields meta info.
   */
  public queryColumnTypes(sql: string, params: unknown[]): CancelablePromise<TableStructure> {
    return this.executeCancelable<TableStructure>(
      this.getConnection(),
      {
        sqlText: `${sql} LIMIT 0`,
        binds: <string[] | undefined>params,
        fetchAsString: FETCH_AS_STRING,
      },
      (stmt) => this.getTypes(stmt),
    );

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Re-run the pre-aggregation build to retry the COPY INTO unload
  2. Check Snowflake's query history for the COPY INTO statement to see whether it failed or exported zero rows
  3. Verify the export bucket credentials and permissions are valid so the unload can actually write files
  4. Upgrade the Snowflake driver in case of a client-library result-parsing bug
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at packages/cubejs-snowflake-driver/src/SnowflakeDriver.ts:613 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02). Data as JSON: /api/errors/dcef0ff914d45afb. Report an issue: GitHub.