Generate a unexpected Actual SQL
See original GitHub issueShardingSphere version: 5.1.0 Database: Mysql
Properties:
spring:
shardingsphere:
datasource:
names: db0
props:
sql-show: true
rules:
sharding:
tables:
book:
actual-data-nodes: db0.book_$->{0..2}
table-strategy:
standard:
sharding-column: id
sharding-algorithm-name: table-inline
key-generate-strategy:
column: id
key-generator-name: snowflake
sharding-algorithms:
table-inline:
type: INLINE
props:
algorithm-expression: book_$->{id % 3}
Logic SQL:
SELECT
UPPER(
LEFT ( bg.class_no, 1 )) class_char,
count(
DISTINCT ( bg.class_no )) class_num,
count( b.id ) book_num,
sum( b.price ) sum_price
FROM
book b
JOIN bibliography bg ON b.bibliography_id = bg.id
WHERE
b.user_id = ?
GROUP BY
class_char
Using logic sql and no sharding result:
classChar | classNum | bookNum | sumPrice |
---|---|---|---|
A | 2 | 3 | 89.10 |
B | 2 | 3 | 121.60 |
D | 2 | 2 | 38.80 |
Z | 1 | 2 | 5.52 |
Actual SQL:
SELECT DISTINCT
UPPER(
LEFT ( bg.class_no, 1 )) class_char,
bg.class_no class_num,
count( b.id ) book_num,
sum( b.price ) sum_price
FROM
book_0 b
JOIN bibliography bg ON b.bibliography_id = bg.id
WHERE
b.user_id = ?
ORDER BY
class_char ASC
unexpected result:
classChar | classNum | bookNum | sumPrice |
---|---|---|---|
A | 2 | 6 | 202.90 |
Z | 1 | 4 | 52.12 |
Maybe it is a bug? I don’t know. 😦 Please give me some help. The sql file: demo1.zip
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Unexpected values (values being added) to column/output ...
Unexpected values (values being added) to column/output generated/formatted incorrectly from SQL ... Above is the table I have. I am asked to:.
Read more >Cannot generate SSPI context when connecting to SQL Server
Start KerberosConfigMgr.exe from the %SystemDrive%:\Program Files\Microsoft\Kerberos Configuration Manager folder. Then, use a domain account ...
Read more >Resolve custom SQL data source exception error in QuickSight
"Your database generated a SQL exception. This can be caused by query timeouts, resource constraints, unexpected DDL alterations before or ...
Read more >Common SQL syntax errors and how to resolve them
In this article, we are going to describe some of the most common SQL syntax errors, and explains how you can resolve these...
Read more >Optimize SQL Queries with CASE Expressions in Unexpected ...
So, I'm writing a series on using Case Expressions in unexpected ways. This is part 2 in the series:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello , this issue has not received a reply for several days. This issue is supposed to be closed.
@cucuzi I will check the rewrite logic.