You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/09/16 10:25:34 UTC

[GitHub] [shardingsphere] marker-wu opened a new issue #12491: About custom sharding algorithm

marker-wu opened a new issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491


   An error was reported at runtime, when the generic type of PreciseShardingValue is Long
   ![image](https://user-images.githubusercontent.com/45256940/133595828-12c5ec53-c874-4939-abe5-cc4fe8000993.png)
   When the type is changed to Integer, it can run normally
   This is my table structure:
   ![image](https://user-images.githubusercontent.com/45256940/133596047-4c290ae8-b20e-4652-b4ca-365c08c6247b.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920790471


   ![image](https://user-images.githubusercontent.com/45256940/133598769-042a7ccb-ba79-40aa-bdb1-f6d7cc846e92.png)
   My field type is bigint, why do I still report this error?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920805896


   > Hi @marker-wu
   > Please check your fields type of Java entity, may not long?
   
   I did not create the table object in the code,I just set the routing rules in yaml
   ![image](https://user-images.githubusercontent.com/45256940/133601817-160d8212-a643-487e-99c4-8ddc01f6e281.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920791543


   > The problem is `+1`, please try `+1L`.
   
   it does not work


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920809984


   > > I did not create the table object in the code,I just set the routing rules in yaml
   > 
   > So you shoud find the entity definition and determine the type of the fields, so that you can determine the type of sharding key, rather than just define the sharding algorithm.
   
   Where is the entity defined? Is the configuration information in config-sharding.yaml?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920818727


   I ran it in the terminal
   ![image](https://user-images.githubusercontent.com/45256940/133604225-bed78ca1-035a-4b67-9342-d4dbed50d82e.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920811287


   😀 How did you get the SQL?


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu edited a comment on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
marker-wu edited a comment on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920791543


   > The problem is `+1`, please try `+1L`.
   
   it does not work
   ![image](https://user-images.githubusercontent.com/45256940/133599621-afece0f9-0257-4050-b168-3be087559d4b.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920950243


   @marker-wu 
   OK, your scene is different from what I said, I will continue to investigate.
   
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang closed issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang closed issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491


   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-927302659


   Because the question was resolved, I will close this issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang edited a comment on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang edited a comment on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-927302659


   Because the question was resolved, I will close this issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920813602


   For example, the type of entity field, which affects the parameter type you set in PreparedStatement. 
   This type should be consistent with the sharding key type defined by the sharding algorithm.
   ![image](https://user-images.githubusercontent.com/5668787/133603256-f39c355f-3d05-46c5-9bfc-0c3f57d6c475.png)
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang edited a comment on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang edited a comment on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-927302659


   Because the question was been resolved, I will close this issue.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-921540329


   Hi @marker-wu 
   I investigated this issue and I have the following information to give you feedback:
   1. In the SQL parse progress, ANTLR recognizes ‘5’ as a Number type;
   2. The most suitable type corresponding to ‘5’ is Integer, so it becomes Interger;
   3. Although your table field type is bigint, meta data has not been used during parse progress, so it has not been converted to Long type.
   4. The sharding algorithm specifies that Long is required, so a conversion exception occurs.
   
   I think this problem needs to be corrected. Before that, you can also temporarily solve this problem by declaring the parameter as ‘Comparable’:
   ```java
       @Override
       public String doSharding(final Collection<String> availableTargetNames, final PreciseShardingValue<Comparable<?>> shardingValue) {
           for (String each : availableTargetNames) {
               if (each.endsWith(String.valueOf(Long.valueOf(shardingValue.getValue().toString()) % 2 + 1))) {
                   return each;
               }
           }
           return null;
       }
   ```


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920801237


   Hi @marker-wu 
   Please check your fields type of Java entity, may not long? 


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920796386


   Let me check it.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920807739


   > I did not create the table object in the code,I just set the routing rules in yaml
   
   So you shoud find the entity definition and determine the type of the fields, so that you can determine the type of sharding key, rather than just define the sharding algorithm.
   


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] taojintianxia commented on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
taojintianxia commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920781823


   you may take a look of the [FAQ](https://shardingsphere.apache.org/document/current/en/others/faq/)


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920829332


   If I use sql tool (navicat) to connect to proxy, an error will be reported when the source sql is executed


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] RaigorJiang commented on issue #12491: An error About custom sharding algorithm

Posted by GitBox <gi...@apache.org>.
RaigorJiang commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-920790594


   The problem is `+1`, please try `+1L`.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] marker-wu commented on issue #12491: An error About custom sharding algorithm in 5.0.0-beta

Posted by GitBox <gi...@apache.org>.
marker-wu commented on issue #12491:
URL: https://github.com/apache/shardingsphere/issues/12491#issuecomment-921549858


   it worked !
   3Q


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org