Disable supports_left_associative_joins_without_parens for MySQL and Redshift#2357
Open
revitalkr wants to merge 1 commit into
Open
Disable supports_left_associative_joins_without_parens for MySQL and Redshift#2357revitalkr wants to merge 1 commit into
supports_left_associative_joins_without_parens for MySQL and Redshift#2357revitalkr wants to merge 1 commit into
Conversation
…ntly applied to Snowflake) to MySQL and Redshift.
iffyio
reviewed
May 28, 2026
| ); | ||
| } | ||
|
|
||
| #[test] |
Contributor
There was a problem hiding this comment.
does this test fail without the changes in this PR? if not it looks like we can skip it entirely, it looks similar to https://github.com/SatoriCyber/datafusion-sqlparser-rs/blob/00e1d917d439ff40e0c6a10829c491b0735b8818/tests/sqlparser_common.rs#L17445-L17465
Author
There was a problem hiding this comment.
yes, it fails without this PR.
These are different cases which behave differently. Natural join behaves different than the other joins because it can't have a condition after it.
iffyio
reviewed
May 29, 2026
Comment on lines
+10675
to
+10677
| fn non_left_associative_dialects() -> TestedDialects { | ||
| all_dialects_where(|d| !d.supports_left_associative_joins_without_parens()) | ||
| } |
Contributor
There was a problem hiding this comment.
can we inline this into the function that uses it?
supports_left_associative_joins_without_parens for MySQL and Redshift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ntly applied to Snowflake) to MySQL and Redshift.
Summary
This PR extends the existing
supports_left_associative_joins_without_parens = falsebehavior (currently applied to Snowflake) to MySQL and Redshift.Problem
The following query is currently accepted only for Snowflake and rejected for other dialects:
SELECT DISTINCT p.product_id
FROM orders AS o
INNER JOIN customers AS c
INNER JOIN products AS p ON p.customer_id = c.customer_id
ON c.order_id = o.order_id;
However, this query executes successfully in both MySQL and Redshift.
Solution
Set
supports_left_associative_joins_without_parens = falsefor MySQL and Redshift, enabling them to accept the same class of queries already supported for Snowflake.Validation
Attached scripts demonstrate that:
Tests
The existing Snowflake test has been moved to the main test suite and is now applied to all dialects where
supports_left_associative_joins_without_parens = false.scripts
-- =========================================================
-- MySQL validation script
-- 1. Acceptance of deferred ON query
-- 2. Behavior consistent with Snowflake parsing mode
-- =========================================================
-- PART A: REAL QUERY
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS products;
CREATE TABLE orders (
order_id INT
);
CREATE TABLE customers (
customer_id INT,
order_id INT
);
CREATE TABLE products (
product_id INT,
customer_id INT
);
INSERT INTO orders VALUES (1), (2), (3);
INSERT INTO customers VALUES
(10,1),
(20,2),
(30,3);
INSERT INTO products VALUES
(100,10),
(200,20),
(300,30);
-- ORIGINAL
SELECT 'PART_A_ORIGINAL' AS src, p.product_id
FROM orders AS o
INNER JOIN customers AS c
INNER JOIN products AS p ON p.customer_id = c.customer_id
ON c.order_id = o.order_id
ORDER BY p.product_id;
-- CANONICAL (Snowflake-style)
SELECT 'PART_A_CANONICAL' AS src, p.product_id
FROM orders AS o
INNER JOIN (
customers AS c
INNER JOIN products AS p ON p.customer_id = c.customer_id
)
ON c.order_id = o.order_id
ORDER BY p.product_id;
-- PART B: WITNESS QUERY
-- Demonstrates observable associativity difference
DROP TABLE IF EXISTS w_orders;
DROP TABLE IF EXISTS w_customers;
DROP TABLE IF EXISTS w_products;
CREATE TABLE w_orders (
order_id INT
);
CREATE TABLE w_customers (
customer_id INT,
order_id INT
);
CREATE TABLE w_products (
product_id INT,
customer_id INT
);
INSERT INTO w_orders VALUES (1), (2);
INSERT INTO w_customers VALUES
(10,1),
(20,2);
INSERT INTO w_products VALUES
(100,10);
-- ORIGINAL
SELECT 'PART_B_ORIGINAL' AS src, o.order_id, c.customer_id, p.product_id
FROM w_orders AS o
LEFT JOIN w_customers AS c
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
ON c.order_id = o.order_id
ORDER BY o.order_id, c.customer_id, p.product_id;
-- CANONICAL
SELECT 'PART_B_CANONICAL' AS src, o.order_id, c.customer_id, p.product_id
FROM w_orders AS o
LEFT JOIN (
w_customers AS c
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
)
ON c.order_id = o.order_id
ORDER BY o.order_id, c.customer_id, p.product_id;
-- ALTERNATIVE (left-deep)
SELECT 'PART_B_LEFT_DEEP' AS src, o.order_id, c.customer_id, p.product_id
FROM (
w_orders AS o
LEFT JOIN w_customers AS c ON c.order_id = o.order_id
)
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
ORDER BY o.order_id, c.customer_id, p.product_id;
-- =========================================================
-- Redshift validation script
-- 1. Acceptance of deferred ON query
-- 2. Behavior consistent with Snowflake parsing mode
-- =========================================================
-- PART A: REAL QUERY
DROP TABLE IF EXISTS orders;
DROP TABLE IF EXISTS customers;
DROP TABLE IF EXISTS products;
CREATE TEMP TABLE orders (
order_id INT
);
CREATE TEMP TABLE customers (
customer_id INT,
order_id INT
);
CREATE TEMP TABLE products (
product_id INT,
customer_id INT
);
INSERT INTO orders VALUES (1), (2), (3);
INSERT INTO customers VALUES
(10,1),
(20,2),
(30,3);
INSERT INTO products VALUES
(100,10),
(200,20),
(300,30);
-- ORIGINAL
SELECT 'PART_A_ORIGINAL' AS src, p.product_id
FROM orders AS o
INNER JOIN customers AS c
INNER JOIN products AS p ON p.customer_id = c.customer_id
ON c.order_id = o.order_id
ORDER BY p.product_id;
-- CANONICAL (Snowflake-style)
SELECT 'PART_A_CANONICAL' AS src, p.product_id
FROM orders AS o
INNER JOIN (
customers AS c
INNER JOIN products AS p ON p.customer_id = c.customer_id
)
ON c.order_id = o.order_id
ORDER BY p.product_id;
-- PART B: WITNESS QUERY
DROP TABLE IF EXISTS w_orders;
DROP TABLE IF EXISTS w_customers;
DROP TABLE IF EXISTS w_products;
CREATE TEMP TABLE w_orders (
order_id INT
);
CREATE TEMP TABLE w_customers (
customer_id INT,
order_id INT
);
CREATE TEMP TABLE w_products (
product_id INT,
customer_id INT
);
INSERT INTO w_orders VALUES (1), (2);
INSERT INTO w_customers VALUES
(10,1),
(20,2);
INSERT INTO w_products VALUES
(100,10);
-- ORIGINAL
SELECT 'PART_B_ORIGINAL' AS src, o.order_id, c.customer_id, p.product_id
FROM w_orders AS o
LEFT JOIN w_customers AS c
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
ON c.order_id = o.order_id
ORDER BY o.order_id, c.customer_id, p.product_id;
-- CANONICAL
SELECT 'PART_B_CANONICAL' AS src, o.order_id, c.customer_id, p.product_id
FROM w_orders AS o
LEFT JOIN (
w_customers AS c
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
)
ON c.order_id = o.order_id
ORDER BY o.order_id, c.customer_id, p.product_id;
-- ALTERNATIVE (left-deep)
SELECT 'PART_B_LEFT_DEEP' AS src, o.order_id, c.customer_id, p.product_id
FROM (
w_orders AS o
LEFT JOIN w_customers AS c ON c.order_id = o.order_id
)
INNER JOIN w_products AS p ON p.customer_id = c.customer_id
ORDER BY o.order_id, c.customer_id, p.product_id;
``