Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL syntax exception occurs when execute SELECT EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40'); #33452

Open
lcfliuxi opened this issue Oct 29, 2024 · 6 comments

Comments

@lcfliuxi
Copy link

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

5.5.0

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

ShardingSphere-JDBC

Expected behavior

Execute SELECT COUNT(*) AS total FROM dwd_urls_search WHERE id > 0 AND EXTRACT(ISOYEAR FROM create_time) = 2024 AND EXTRACT(WEEK FROM create_time) = 27; successfully for PostgreSQL.
Execute SELECT EXTRACT(QUARTER TIMESTAMP '2001-02-16 20:38:40'); successfully for PostgreSQL.

Actual behavior

Caused by: org.apache.shardingsphere.infra.exception.dialect.exception.syntax.sql.DialectSQLParsingException: You have an error in your SQL syntax: no viable alternative at input 'SELECTCOUNT(*)AStotalFROMdwd_urls_searchWHEREid>0ANDEXTRACT(ISOYEARFROMcreate_time)=2024ANDEXTRACT(WEEK'
at org.apache.shardingsphere.infra.parser.ShardingSphereSQLParserEngine.parse(ShardingSphereSQLParserEngine.java:60)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.(ShardingSpherePreparedStatement.java:206)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.(ShardingSpherePreparedStatement.java:172)
at org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.prepareStatement(ShardingSphereConnection.java:94)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.ConnectionLogger.invoke(ConnectionLogger.java:55)
at com.sun.proxy.$Proxy94.prepareStatement(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.instantiateStatement(PreparedStatementHandler.java:86)
at org.apache.ibatis.executor.statement.BaseStatementHandler.prepare(BaseStatementHandler.java:88)
... 178 more

Reason analyze (If you can)

This issue is similar to issue16851

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

Example codes for reproduce this issue (such as a github link).

@lcfliuxi
Copy link
Author

Is anyone looking into this issue?

@strongduanmu
Copy link
Member

Hi @lcfliuxi, can you try the latest 5.5.1?

@lcfliuxi
Copy link
Author

lcfliuxi commented Nov 1, 2024

Ok, i will try it @strongduanmu

@lcfliuxi
Copy link
Author

lcfliuxi commented Nov 1, 2024

Hi @strongduanmu, I tested it in version 5.5.1, and the issue still exists.
image

@strongduanmu
Copy link
Member

Can you sumbit a pr to fix this issue?

@lcfliuxi
Copy link
Author

lcfliuxi commented Nov 1, 2024

Sorry, I’m not sure how to fix this issue. Could you provide more details or guidance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants