cube-js/cube · error

Unable to detect type for field "${f.name}" with dataTypeID:

Error message

Unable to detect type for field "${f.name}" with dataTypeID: ${f.dataTypeID}

What it means

QuestDriver.mapFields converts PostgreSQL wire-protocol field type OIDs (dataTypeID) to QuestDB types using the NativeTypeToQuestType map. When a result column's OID is not in the map, the driver cannot determine the column type and throws during downloadQueryResults.

Source

Thrown at packages/cubejs-questdb-driver/src/QuestDriver.ts:134

  private getInitialConfiguration(): Partial<QuestDriverConfiguration> {
    return {
      readOnly: true,
    };
  }

  public async testConnection(): Promise<void> {
    await this.pool.query('SELECT $1 AS number', ['1']);
  }

  private mapFields(fields: FieldDef[]) {
    return fields.map((f) => {
      let questType;
      if (f.dataTypeID in NativeTypeToQuestType) {
        questType = NativeTypeToQuestType[f.dataTypeID].toLowerCase();
      }
      if (!questType) {
        throw new Error(
          `Unable to detect type for field "${f.name}" with dataTypeID: ${f.dataTypeID}`
        );
      }

      return ({
        name: f.name,
        type: this.toGenericType(questType)
      });
    });
  }

  public async query<R = unknown>(query: string, values: unknown[], _options?: QueryOptions): Promise<R[]> {
    const result = await this.queryResponse(query, values);
    return result.rows;
  }

  private async queryResponse(query: string, values: unknown[]) {
    const conn = await this.pool.connect();

View on GitHub (pinned to 7d981676b3)

Solutions

  1. Change the source column to a supported type (int, float, string, timestamp, boolean) or cast it in the query (e.g. `SELECT col::text`)
  2. Add the missing dataTypeID mapping to NativeTypeToQuestType in QuestDriver.ts
  3. Update the questdb-driver package, as newer versions add OID mappings

Example fix

// before
SELECT * FROM events; -- extra: jsonb column
// after
SELECT id, ts, extra::text AS extra FROM events;
Defensive patterns

Strategy: type-guard

Validate before calling

const supported = new Set(Object.values(NativeTypeToQuestType)); // cast unmapped columns in SQL before download

Type guard

function isMappedField(f) { return f.dataTypeID in NativeTypeToQuestType; }

Try / catch

try { await driver.downloadQueryResults(query, values); } catch (e) { if (e.message.includes('Unable to detect type for field')) { /* cast column to text and retry */ } throw e; }

Prevention

When it happens

Trigger: downloadQueryResults returning a column whose dataTypeID has no mapping — e.g. exotic PostgreSQL types (jsonb, arrays, uuid, custom enum/domain types) in tables being introspected or uploaded.

Common situations: Schema introspection over a table with non-standard column types; version drift where a driver release lacks the OID mapping for a newer type; using a Postgres view with computed columns of unmapped types.

Related errors


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