matrixorigin / matrixorigin/matrixone
[Feature Request] MySQL 8.0 Expressions Compatibility: SOUNDS LIKE and ROW constructor
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 311
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 768
Description
## Overview
Based on comprehensive testing against MySQL 8.0 Reference Manual (Section 11.5 Expressions), MatrixOne v3.0 has excellent compatibility (96.2%) with MySQL 8.0 expression syntax. However, **2 expression features** are currently not supported.
## Environment
- **MatrixOne Version**: 8.0.30-MatrixOne-v3.0:5e4210029
- **Reference**: https://dev.mysql.com/doc/refman/8.0/en/expressions.html
---
## Feature 1: SOUNDS LIKE Predicate
### Description
The `SOUNDS LIKE` predicate is used for phonetic (Soundex algorithm) similarity matching between strings. This is commonly used for name matching scenarios where similar-sounding names should match.
### Current Behavior
```sql
SELECT 'hello' SOUNDS LIKE 'halo';
```
**Error:**
```
ERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax;
check the manual that corresponds to your MatrixOne server version for the
right syntax to use. syntax error at line 1 column 26 near " LIKE 'halo'"
```
### Expected Behavior (MySQL 8.0)
```sql
SELECT 'hello' SOUNDS LIKE 'halo';
```
**Result:**
```
+----------------------------+
| 'hello' SOUNDS LIKE 'halo' |
+----------------------------+
| 1 |
+----------------------------+
```
### Workaround
```sql
-- Use REGEXP for pattern matching
SELECT 'hello' REGEXP '^h.*o';
-- Or implement Soundex algorithm in application layer
```
### Impact Assessment
- **Severity**: Low
- **Usage**: Phonetic matching (name matching, fuzzy search)
- **Alternative**: Available via REGEXP or application-layer implementation
---
## Feature 2: ROW Constructor Expression
### Description
The `ROW` constructor creates row values that can be compared. This is useful for multi-column comparisons and tuple comparisons in SQL queries.
### Current Behavior
```sql
SELECT ROW(1, 2) = ROW(1, 2);
```
**Error:**
```
ERROR 1064 (HY000): SQL parser error: You have an error in your SQL syntax;
check the manual that corresponds to your MatrixOne server version for the
right syntax to use. syntax error at line 1 column 10 near " ROW(1, 2) = ROW(1, 2)"
```
### Expected Behavior (MySQL 8.0)
```sql
SELECT ROW(1, 2) = ROW(1, 2);
```
**Result:**
```
+--------------------------+
| ROW(1, 2) = ROW(1, 2) |
+--------------------------+
| 1 |
+--------------------------+
```
### Common Use Cases
#### 1. Multi-column comparison in subqueries
```sql
-- MySQL syntax
SELECT * FROM t1 WHERE (c1, c2) = (SELECT c1, c2 FROM t2 WHERE id = 1);
```
#### 2. Row value IN queries
```sql
-- MySQL syntax
SELECT * FROM t1 WHERE (c1, c2) IN (SELECT c1, c2 FROM t2);
```
#### 3. Composite ordering comparisons
```sql
-- MySQL syntax
SELECT * FROM users WHERE (last_name, first_name) > ('Smith', 'John');
```
### Workarounds
#### For multi-column comparison:
```sql
-- Rewrite using AND
SELECT * FROM t1
WHERE c1 = (SELECT c1 FROM t2 WHERE id = 1)
AND c2 = (SELECT c2 FROM t2 WHERE id = 1);
-- Or use JOIN
SELECT t1.* FROM t1
JOIN t2 ON t1.c1 = t2.c1 AND t1.c2 = t2.c2
WHERE t2.id = 1;
```
#### For row value IN queries:
```sql
-- Rewrite using JOIN
SELECT DISTINCT t1.* FROM t1
JOIN t2 ON t1.c1 = t2.c1 AND t1.c2 = t2.c2;
```
#### For composite ordering:
```sql
-- Rewrite using compound conditions
SELECT * FROM users
WHERE last_name > 'Smith'
OR (last_name = 'Smith' AND first_name > 'John');
```
### Impact Assessment
- **Severity**: Medium
- **Usage**: Multi-column comparisons, complex queries from ORM frameworks
- **Alternative**: Available but requires verbose query rewrites
---
## Summary
| Feature | Priority | Workaround Available | Common Usage |
|---------|----------|---------------------|--------------|
| SOUNDS LIKE | Low | Yes (REGEXP) | Phonetic matching |
| ROW constructor | Medium | Yes (AND/JOIN) | Multi-column comparison |
## Recommendation
While both features have workarounds, supporting them would:
1. Improve MySQL 8.0 compatibility to **98%+**
2. Reduce migration effort from MySQL applications
3. Support ORM frameworks that generate such SQL
The **ROW constructor** is recommended as higher priority due to its more common usage in complex SQL queries and ORM-generated statements.
---
Contributor guide
Assessment
This issue has not been assessed yet.