TheMasterRoot opened a new issue, #34725:
URL: https://github.com/apache/shardingsphere/issues/34725

   # Sharding error when inserting data into ShardingSphere-Proxy with AlloyDB
   
   I am using **ShardingSphere-Proxy** with **AlloyDB** and I am facing an 
error when trying to insert data into the `ni_contribuinte` table.
   
   ## Error when executing an `INSERT`:
   
   ```sql
   rtc_db_des_aa=> INSERT INTO identifier(identifier) VALUES ('1a2b3c4d5e');
   ERROR: Inline sharding algorithms expression 
'shard_${(abs(identifier.hashCode())) % 5}' and sharding column 'identifier' do 
not match.
   ```
   
   **My table schema is as follows:**
   ```sql
   Table "identifier" {
   "identifier" "character varying(14)" [pk, not null]
   }
   ```
   **And my ShardingSphere configuration is as follows:**
   ```yaml
   databaseName: rtc_db_des_aa
   dataSources:
   shard_0:
   url: jdbc:postgresql://10.0.0.2:5432/rtc_db_des_aa
   username: postgres
   password: "pass"
   shard_1:
   url: jdbc:postgresql://10.0.0.7:5432/rtc_db_des_aa
   username: postgres
   password: "pass"
   shard_2:
   url: jdbc:postgresql://10.0.0.8:5432/rtc_db_des_aa
    username: postgres
    password: "pass"
    shard_3:
    url: jdbc:postgresql://10.0.0.9:5432/rtc_db_des_aa
    username: postgres
    password: "pass"
    shard_4:
    url: jdbc:postgresql://10.0.0.10:5432/rtc_db_des_aa
    username: postgres
    password: "pass"
   
   rules:
    - !SHARDING
    tables:
    identifier:
    actualDataNodes: shard_${0..4}.identifier
    tableStrategy:
    standard:
    shardingColumn: identifier
    shardingAlgorithmName: hash_inline
   
    shardingAlgorithms:
   hash_inline:
   type: INLINE
   props:
   sharding-count: 5
   algorithm-expression: shard_${(abs(identifier.hashCode())) % 5}
   
   ```
   From the error, it seems that the sharding expression is not being applied 
correctly to the `identifier` column. What could be causing this?
   
   ## I have already tried:
   
   - Making sure that the `identifier` column is correctly set to `character 
varying(14)`.
   - Testing other sharding expressions, but I still get the same error.
   
   Could someone help me understand what the problem might be?
   


-- 
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-unsubscr...@shardingsphere.apache.org.apache.org

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

Reply via email to