terrymanu commented on issue #32269:
URL:
https://github.com/apache/shardingsphere/issues/32269#issuecomment-3670466377
Understanding
- On Proxy 5.5.0, executing CREATE SHARDING TABLE RULE reports “no viable
alternative at input 'CREATESHARDING' near 'SHARDING'”. In the sample SQL,
PROPERTIES is placed outside TYPE, the algorithm NAME is set to name, and a
comment noted the misspelling
KEY_GENERATE_SYRATEGY.
Root Cause
- DistSQL requires PROPERTIES to be inside TYPE(...), and NAME= must be a
valid algorithm name (built-ins like hash_mod, inline, or a defined custom
name), not a column name or unquoted identifier.
- KEY_GENERATE_STRATEGY was misspelled as KEY_GENERATE_SYRATEGY, which
also triggers a parse failure.
- The error is not because name is a keyword; the SQL simply does not
follow DistSQL syntax.
Analysis
- Official syntax doc:
https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-proxy/distsql/syntax/rdl/rule-definition/sharding/create-sharding-table-rule/
- A compliant auto-sharding example (with PROPERTIES inside TYPE and a
valid algorithm name):
CREATE SHARDING TABLE RULE mnametest (
STORAGE_UNITS(db1_000, db1_001),
SHARDING_COLUMN=name,
TYPE(NAME='hash_mod', PROPERTIES('sharding-count'=2))
-- optional: , KEY_GENERATE_STRATEGY(COLUMN=name,
TYPE(NAME='snowflake'))
);
- If you need a key generator, use the correct spelling
KEY_GENERATE_STRATEGY and ensure the NAME is a supported key generator
algorithm (e.g., snowflake).
Conclusion
- The symptom comes from SQL not conforming to DistSQL syntax, not from a
ShardingSphere bug. Please adjust as above (place PROPERTIES inside TYPE, use a
valid algorithm name, and spell KEY_GENERATE_STRATEGY correctly) and retry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]