Skip to content

ERROR: bad lexical cast: source type value could not be interpreted as target #138

Open
@paoliniluis

Description

@paoliniluis

Hi, we're from Metabase and a customer of us is getting:

Error executing query: ERROR: bad lexical cast: source type value could not be interpreted as target"

when running the following query

SELECT
  c.column_name AS name,
  c.data_type AS "database-type",
  c.ordinal_position - 1 AS "database-position",
  c.table_schema AS "table-schema",
  c.table_name AS "table-name",
  pk.column_name IS NOT NULL AS "pk?",
  CASE
    WHEN c.remarks <> '' THEN c.remarks
    ELSE NULL
  END AS "field-comment"
FROM
  svv_columns AS c
  LEFT JOIN (
    SELECT
      tc.table_schema,
      tc.table_name,
      kc.column_name
    FROM
      information_schema.table_constraints AS tc
      INNER JOIN information_schema.key_column_usage AS kc
        ON tc.constraint_name = kc.constraint_name
        AND tc.table_schema = kc.table_schema
        AND tc.table_name = kc.table_name
    WHERE
      tc.constraint_type = 'PRIMARY KEY'
  ) AS pk
    ON c.table_schema = pk.table_schema
    AND c.table_name = pk.table_name
    AND c.column_name = pk.column_name
WHERE
  c.table_schema !~ '^information_schema|catalog_history|pg_'
  AND c.table_schema IN (
<schemas here>
  )
ORDER BY
  "table-schema" ASC,
  "table-name" ASC,
  "database-position" ASC;

The schemas parameter is a set of schemas, and there's only one schema that is causing this (every schema is a federated postgres)

The customer also run the query in PyCharm and works, that's why we think this is an issue with the driver

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