Skip to content

Metadata ignores declared types of delimited (quoted) column references, e.g. "cyl" + 1 reports OTHER #571

Open

Description

@perNyfelt

Result-set metadata loses declared types when a projection refers to a source column by its delimited (quoted) name. Row values are unaffected; only the declared type is lost. Affected projections report OTHER / java.lang.Object, or fall back to value inference, and set operations then accept incompatible branches.

Reproduced on main (64f4bb4) and on PR #570's branch (14b8150), using the mtcars fixture (lowercase physical names, cyl INTEGER, mpg DOUBLE):

Query Metadata Expected
SELECT cyl + 1 FROM mtcars BIGINT / Long —
SELECT "cyl" + 1 FROM mtcars OTHER / Object (values are Long) BIGINT / Long
SELECT MIN(mpg) OVER () FROM mtcars WHERE cyl = 99 DOUBLE —
SELECT MIN("mpg") OVER () FROM mtcars WHERE cyl = 99 OTHER DOUBLE
SELECT CASE WHEN "cyl" = 1 THEN "cyl" ELSE 1.5 END FROM mtcars WHERE cyl = 99 OTHER DECIMAL
SELECT MIN(m."mpg") FROM mtcars m WHERE cyl = 99 OTHER (also on #570) DOUBLE
SELECT MIN("mpg") FROM mtcars WHERE cyl = 99 UNION ALL SELECT 'a' (#570) accepted, VARCHAR rejected, 42000 (the unquoted form is rejected)

Likely cause (from reading the code, not confirmed by a fix): JParqResultSetMetaData.resolveSourceField looks up column.getColumnName() verbatim, including the surrounding double quotes (fieldBySchemaName(name) or owner + "__" + name). It does not normalize through Identifier, so a delimited reference never matches the physical field. Every declaration-based metadata path uses this resolver: numeric, CASE/COALESCE, window MIN/MAX, and aggregate MIN/MAX from #570.

Expected: a delimited identifier that names a source column resolves to that column's declaration, exactly like the regular identifier does. Metadata should not depend on whether the query quotes its identifiers. Quoting is common in tool-generated SQL.

Related but distinct: #479 (quoted mixed-case physical columns fail to bind at all). Here binding works and only metadata is lost.

Found while reviewing PR #570. This is outside that PR's scope.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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