bytebase / bytebase/omni

MariaDB: Parser fails on valid SQL with parenthesized JOIN expressions in FROM clause

Open
#423 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
15
Forks
7
Avg merge
13h 2m
Merged PRs (30d)
23

Description

Summary

The MariaDB dialect parser fails to parse a valid MariaDB query when joined table expressions are wrapped in parentheses in the FROM clause.

MariaDB accepts this syntax, and it is commonly generated by tools such as SHOW CREATE VIEW, ORMs, or query builders.

Reproduction
SELECT
	`o`.`id` AS `order_id`,
	`c`.`name` AS `customer_name`,
	sum(`oi`.`amount`) AS `total_amount`
FROM
	(((`orders` `o`
JOIN `customers` `c` ON
	((`o`.`customer_id` = `c`.`id`))))
LEFT JOIN `order_items` `oi` ON
	((`o`.`id` = `oi`.`order_id`)))
GROUP BY
	`o`.`id`,
	`c`.`name`

parser failed error

expected SELECT, TABLE, VALUES, or '(' (line 1, column 108)
related text: SELECT `o`.`id` AS `order_id`, `c`.`name` AS `customer_name`, sum(`oi`.`amount`) AS `total_amount` FROM (((`orders` `o` JOIN `customers` `c` ON((`o`.`customer_id` = `c`.`id`)))) LEFT JOIN `order_items...

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the MariaDB dialect parser and use the parenthesized JOIN query in the issue as the first reproduction. Add a regression test for this exact valid SQL, then run the parser test suite; done means the query parses successfully without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mariadb, sql
Domain
compilers, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.