Skip to content

Quote PostgreSQL schema/table identifiers in metadata-derived SQL names#948

Draft
thadguidry with Copilot wants to merge 4 commits into
masterfrom
copilot/fix-trailing-junk-error-in-query
Draft

Quote PostgreSQL schema/table identifiers in metadata-derived SQL names#948
thadguidry with Copilot wants to merge 4 commits into
masterfrom
copilot/fix-trailing-junk-error-in-query

Conversation

Copilot AI commented May 24, 2026

Copy link
Copy Markdown

PostgreSQL queries failed for schemas starting with numeric characters (e.g. 0HEM8B0GQNB5M) because metadata extraction produced unquoted schema.table names. This caused invalid SQL parsing (trailing junk after numeric literal) when those names were used in generated queries.

  • Identifier rendering fix (PostgreSQL metadata path)

    • Updated PostgreSQLDataExclusion to build DbTable.fullName with quoted identifiers for both schema and table.
    • Added identifier escaping for embedded double quotes to keep generated names SQL-safe.
  • Behavioral impact

    • Generated table references now follow PostgreSQL quoted-identifier rules, including numeric-leading schema names and case-sensitive identifiers.
  • Focused regression coverage

    • Added a unit test in PostgreSQLDataExclusionTest validating that schema 0HEM8B0GQNB5M and table t_region produce a fully-qualified name as quoted identifiers.
    • Added a unicode identifier test in PostgreSQLDataExclusionTest validating quoted full-name generation for unicode schema/table names (e.g. "dátá_数据"."dátá").
// Before
fullName = schemaName + "." + metaDataTable.tableName();

// After
fullName = getQuotedName(schemaName) + "." + getQuotedName(metaDataTable.tableName());
// => "0HEM8B0GQNB5M"."t_region"

Copilot AI and others added 2 commits May 24, 2026 07:19
Copilot AI changed the title [WIP] Fix trailing junk error in SQL query Quote PostgreSQL schema/table identifiers in metadata-derived SQL names May 24, 2026
Copilot AI requested a review from thadguidry May 24, 2026 07:22
@thadguidry

Copy link
Copy Markdown
Collaborator

@copilot can you add a new issue so that we ensure we have similar test and handling for table and schema names for mysql and it's convention use of backticks?

In this pr, I'd like you to also add to the test case for unicode in table or schema names. Example:
-- Equivalent to "data"
U&"d\0061t+000061"

Copilot AI commented May 24, 2026

Copy link
Copy Markdown
Author

@copilot can you add a new issue so that we ensure we have similar test and handling for table and schema names for mysql and it's convention use of backticks?

In this pr, I'd like you to also add to...

Added unicode identifier coverage to the PostgreSQL test in commit c78a73c (shouldQuoteUnicodeSchemaAndTableNameInFullName). I’m unable to create a new GitHub issue from this environment because GitHub CLI auth is unavailable here; please open a follow-up issue for MySQL backtick schema/table handling and I can implement it next.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh auth status -h github.com (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@thadguidry

Copy link
Copy Markdown
Collaborator

@kdhrubo are you satisfied on this changes and ready to merge?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERROR: trailing junk after numeric literal at or near "0H" Position: 154

2 participants