ying-hua opened a new pull request, #11006:
URL: https://github.com/apache/inlong/pull/11006

   
   <!-- Prepare a Pull Request
   Change the title of pull request refer to the following example:
     [INLONG-XYZ][Component] Title of the pull request 
   -->
   
   <!-- Specify the issue this pull request going to fix.
   The following *XYZ* should be replaced by the actual [GitHub 
Issue](https://github.com/apache/inlong/issues) number)-->
   
   Fixes #10962 
   
   ### Motivation
   
   <!--Explain here the context, and why you're making that change. What is the 
problem you're trying to solve.-->
   Extend Inlong transform SQL support selecting data from multi-dimensional 
array.
   ### Use case
   
   ### case 1
   transformSql = "select $root.matrix(0,1) from source"
   jsonString:
   ```
   {
     "matrix":[
       [1,2,3],
       [4,5,6],
       [7,8,9]
     ]
   }
   ```
   result: $root.matrix(0,1)="2"
   
   ### case 2
   transformSql = "select $root.arr(1).id, $root.arr(2,1) from source"
   jsonString:
   ```
   {
     "arr":[
       "value1",
       {"id":"1001"},
       [12,-3,25]
     ]
   }
   ```
   result: $root.arr(1).id = "1001", $root.arr(2,1) = "-3"
   
   ### case 3
   transformSql = "select  $root.departments(0).courses(0,1).courseId, 
sqrt($root.departments(0).courses(0,1).courseId - 2) from source"
   jsonString:
   ```
   {
     "departments": [
       {
         "name": "Mathematics",
         "courses": [
           [
             {"courseId": "101","title": "Calculus I"},
             {"courseId": "102","title": "Linear Algebra"}
           ],
           [
             {"courseId": "201","title": "Calculus II"},
             {"courseId": "202","title": "Abstract Algebra"}
           ]
         ]
       }
     ]
   }
   ```
   ### Modifications
   
   <!--Describe the modifications you've done.-->
   - JsonNode.java
   Enhanced the JsonNode class to handle multi-dimensional arrays.
   - JsonSourceDecoder.java
   Added a new private method getElementFromArray to handle the extraction of 
data from arrays.
   - JsonSourceData.java
   Added a new private method getElementFromArray to handle the extraction of 
data from arrays.
   
   ### Problem
   Currently, the implementation uses arr(0,1) for accessing array elements, 
whereas a more conventional approach would use nested parentheses such as 
arr(0)(1).
   I wonder is it necessary to support the syntax of arr(0)(1)(2) or 
arr[0][1][2]?
   If necessary, we can replace substring ")(" with "," before parsing Sql 
statement to avoid syntax error.
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [x] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads 
(10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up 
issue for adding the documentation
   


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