Skip to content

[DBMON-6299] Fix table name metadata extraction#91

Merged
eric-weaver merged 1 commit intomainfrom
eric.weaver/DBMON-6299
Mar 19, 2026
Merged

[DBMON-6299] Fix table name metadata extraction#91
eric-weaver merged 1 commit intomainfrom
eric.weaver/DBMON-6299

Conversation

@eric-weaver
Copy link
Contributor

Fixes an issue where we're missing metadata extraction of tables when table aliases are used.

SELECT events.target_id, events.created_at, source_tickets.title FROM events, tickets AS source_tickets WHERE events.org_id = 123 AND source_tickets.status = 'open' LIMIT 100 | bin/sqllexer -with-metadata
{
  "sql": "SELECT events.target_id, events.created_at, source_tickets.title FROM events, tickets WHERE events.org_id = ? AND source_tickets.status = ? LIMIT ?",
  "metadata": {
    "size": 12,
    "tables": [
      "events"
    ],
    "comments": [],
    "commands": [
      "SELECT"
    ],
    "procedures": []
  }
}

After the fix

echo "SELECT events.target_id, events.created_at, source_tickets.title FROM events, tickets AS source_tickets WHERE events.org_id = 123 AND source_tickets.status = 'open' LIMIT 100" | bin/sqllexer -with-metadata
{
  "sql": "SELECT events.target_id, events.created_at, source_tickets.title FROM events, tickets WHERE events.org_id = ? AND source_tickets.status = ? LIMIT ?",
  "metadata": {
    "size": 19,
    "tables": [
      "events",
      "tickets"
    ],
    "comments": [],
    "commands": [
      "SELECT"
    ],
    "procedures": []
  }
}

@eric-weaver eric-weaver requested a review from a team as a code owner March 19, 2026 16:00
"INTO",
"IS",
"KEY",
"LATERAL",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the LATERAL keyword do with the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fixes test failures for lateral-join

@eric-weaver eric-weaver merged commit 887d3fd into main Mar 19, 2026
7 checks passed
@eric-weaver eric-weaver deleted the eric.weaver/DBMON-6299 branch March 19, 2026 16:56
gh-worker-dd-mergequeue-cf854d bot pushed a commit to DataDog/datadog-agent that referenced this pull request Mar 19, 2026
### What does this PR do?
Updates go-sqllexer to v0.2.1

### Motivation
The notable change in the version bump is DataDog/go-sqllexer#91 which fixes table name metadata extraction from queries normalized and obfuscated within DBM integrations

### Describe how you validated your changes

### Additional Notes


Co-authored-by: eric.weaver <eric.weaver@datadoghq.com>
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.

2 participants