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

   ## Refactor
   
   There are various PostgreSQL/openGauss type cast syntax:
   
https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS
   
https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-GENERIC
   
   Consider creating a `TypeCastExpressionSegment` to unify the SQL parse 
result.
   
   Example:
   ```sql
   select CAST(money '1' as varchar)::char(10)
   ```
   
   Parse result of PostgreSQL
   ```json
   {
     "version": 150001,
     "stmts": [
       {
         "stmt": {
           "SelectStmt": {
             "targetList": [
               {
                 "ResTarget": {
                   "val": {
                     "TypeCast": {
                       "arg": {
                         "TypeCast": {
                           "arg": {
                             "TypeCast": {
                               "arg": {
                                 "A_Const": {
                                   "sval": {
                                     "sval": "1"
                                   },
                                   "location": 18
                                 }
                               },
                               "typeName": {
                                 "names": [
                                   {
                                     "String": {
                                       "sval": "money"
                                     }
                                   }
                                 ],
                                 "typemod": -1,
                                 "location": 12
                               },
                               "location": -1
                             }
                           },
                           "typeName": {
                             "names": [
                               {
                                 "String": {
                                   "sval": "pg_catalog"
                                 }
                               },
                               {
                                 "String": {
                                   "sval": "varchar"
                                 }
                               }
                             ],
                             "typemod": -1,
                             "location": 25
                           },
                           "location": 7
                         }
                       },
                       "typeName": {
                         "names": [
                           {
                             "String": {
                               "sval": "pg_catalog"
                             }
                           },
                           {
                             "String": {
                               "sval": "bpchar"
                             }
                           }
                         ],
                         "typmods": [
                           {
                             "A_Const": {
                               "ival": {
                                 "ival": 10
                               },
                               "location": 40
                             }
                           }
                         ],
                         "typemod": -1,
                         "location": 35
                       },
                       "location": 33
                     }
                   },
                   "location": 7
                 }
               }
             ],
             "limitOption": "LIMIT_OPTION_DEFAULT",
             "op": "SETOP_NONE"
           }
         }
       }
     ]
   }
   ```
   


-- 
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]

Reply via email to