Skip to content

PgDatabaseMetaData.getColumns sets the columnSize for VARCHAR to -4 #1

@awal11

Description

@awal11

I am trying to use the driver together with PrestoDB. Presto needs to analyze the metadata returned by ML jdbc driver and I encountered few issues, this would be the first of them.

The metadata for VARCHAR set the columnSize to value -4 - I think this is happening because:

  1. PgDatabaseMetaData line 1815: always returns 0 as attypemod
  2. PgDatabaseMetaData line 1837: uses this value as typeMod
  3. PgDatabaseMetaData line 1854: uses typeMod (set to 0) to determine length of this varchar using class TypeInfoCache
  4. TypeInfoCache line 623: is probably left unmodified from Postgres, not expecting 0, returns 0-4=-4 instead of a real value or _unknownLength that would probably behave better.
  5. Presto fails with some assertions when analyzing the query results, it does not know what to do with VARCHAR of length -4

To address this issue I would suggest either

  1. set the columnSize to real length of varchar, but I assume it is not possible with ODBC views in ML?
  2. set the columnSize to _unknownLength for varchars

I can create a pull request for the latter case for PgDatabaseMetaData class if you support this solution

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions