chen0623-bak opened a new issue, #5245:
URL: https://github.com/apache/seatunnel/issues/5245

   ### Search before asking
   
   - [X] I had searched in the 
[feature](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22Feature%22)
 and found no similar feature requirement.
   
   
   ### Description
   
   I want to obtain data through data.a, data['a'], and data[0] in SQL
   I find code in
   
   ```txt
   type transform in ZetaSQLType class getExpressionType method
   data transform in ZetaSQLFunction class computeForValue method
   ```
   
   And I wrote a demo
   ```java
           // String sqlStr = "select student.a.b.c.d.e from dual where a=b";
           // String sqlStr = "select student[0] from dual where a=b";
           String sqlStr = "select student['a'] from dual where a=b";
           
           Select select = (Select)CCJSqlParserUtil.parse(sqlStr);
           PlainSelect selectBody = (PlainSelect) select.getSelectBody();
   
           for (SelectItem selectItem : selectBody.getSelectItems()) {
               if (selectItem instanceof SelectExpressionItem) {
                   SelectExpressionItem selectItem1 = (SelectExpressionItem) 
selectItem;
   
                   Expression expression = selectItem1.getExpression();
                   if (expression instanceof Column){
                       Column column = (Column) expression;
                       String columnName = column.getColumnName();
   
                       Table table = column.getTable();
                       // 普通字段
                       if (null == table) {
                           System.out.println("这是一个普通类型, 字段名为: "+columnName );
                           System.out.println(columnName);
                       //    row类型
                       }else{
                           System.out.println("这是一个row类型, 对象为: 
"+table.getFullyQualifiedName()+"\t 字段名为: "+columnName);
                       }
   
                   //    map或者数组
                   }else if (expression instanceof ArrayExpression){
                       ArrayExpression expression1 = (ArrayExpression) 
expression;
                       Expression indexExpression = 
expression1.getIndexExpression();
                       Expression objExpression = 
expression1.getObjExpression();
                       System.out.println("对象名为: "+objExpression.toString());
                       if(indexExpression instanceof StringValue){
                           System.out.println("这是一个map, key为: "+((StringValue) 
indexExpression).getValue());
                       }else if(indexExpression instanceof LongValue){
                           System.out.println("这是一个数组, 下标为: "+((LongValue) 
indexExpression).getValue());
                       }
                   }
   
               }
           }
   ```
   
   I think it can be achieved
   Sorry, my English is not good
   
   整个表可以看做row类型, 当顶层的fieldNames找不到时, 会报错
   where 应该也是一样的
   当 select 1 from a where student['name'] = 'zhangsan' 时
   
   ### Usage Scenario
   
   _No response_
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


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