Skip to content

CAST any_type AS TEXT #5102

@refset

Description

@refset

Currently (well, after the other changes noted in #4235 are applied), Metabase will error when introspecting fields with types that can't be cast to text, e.g. the xt.txs table:

14:42:53.770 [pgwire-connection--pool-113-thread-12] DEBUG xtdb.pgwire - Interpreting SQL:  SELECT CASE WHEN 50000 < LENGTH(CAST("xt"."txs"."user_metadata" AS TEXT)) THEN NULL ELSE "xt"."txs"."user_metadata" END AS "user_metadata", CASE WHEN 50000 < LENGTH(CAST("xt"."txs"."error" AS TEXT)) THEN NULL ELSE "xt"."txs"."error" END AS "error" FROM "xt"."txs" LIMIT 500
14:42:53.775 [pgwire-connection--pool-113-thread-12] DEBUG xtdb.pgwire - Error preparing statement
xtdb.error.Incorrect: Unsupported cast: '[:struct {}]' -> ':utf8'

But also across any user-defined tables:

14:42:50.405 [pgwire-connection--pool-113-thread-28] DEBUG xtdb.pgwire - Interpreting SQL:  SELECT CASE WHEN 50000 < LENGTH(CAST("public"."test_docs3"."my_set" AS TEXT)) THEN NULL ELSE "public"."test_docs3"."my_set" END AS "my_set" FROM "public"."test_docs3" LIMIT 500
14:42:50.413 [pgwire-connection--pool-113-thread-28] DEBUG xtdb.pgwire - Error preparing statement
xtdb.error.Incorrect: Unsupported cast: '[:set [:union #{[:list [:union #{:utf8 :keyword}]] [:struct {etc :bool}]}]]' -> ':utf8'

The result is that those tables will not be indexed by Metabase (in their entirety) if such a query for a single field in that table fails.

I can't see that there's another general solution here which avoids ensuring that all supported types have a string-based representation, but this would also pave the way for tooling like pg_dump etc. which want to export the database as textual DML (#4676)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    💭 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions