You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/10/12 23:20:03 UTC

[GitHub] [druid] paul-rogers commented on pull request #13106: Query test case definitions

paul-rogers commented on PR #13106:
URL: https://github.com/apache/druid/pull/13106#issuecomment-1276829856

   By popular demand, here is the example from the PR description converted to YAML:
   
   ```yaml
   cases:
     - name:  SELECT constant array expression from table
       description: Converted from testSelectConstantArrayExpressionFromTable()
       input:
         sql: |
           SELECT ARRAY[1,2] as arr, dim1 
           FROM foo 
           LIMIT 1
   
         options:
           sqlCompatibleNulls: both
           vectorize: true
       expected:
         schema:
           - name: arr
             type: INTEGER ARRAY
           - name: dim1 
             Type: VARCHAR
         plan: |
           LogicalSort(fetch=[1])
             LogicalProject(arr=[ARRAY(1, 2)], dim1=[$2])
               LogicalTableScan(table=[[druid, foo]])
   
         native: |
           {
             "queryType" : "scan",
             "dataSource" : {
               "type" : "table",
               "name" : "foo"
             },
             "intervals" : {
               "type" : "intervals",
               "intervals" : [ "-146136543-09-08T08:23:32.096Z/146140482-04-24T15:36:27.903Z" ]
             },
             "virtualColumns" : [ {
               "type" : "expression",
               "name" : "v0",
               "expression" : "array(1,2)",
               "outputType" : "ARRAY<LONG>"
             } ],
             "resultFormat" : "compactedList",
             "limit" : 1,
             "columns" : [ "dim1", "v0" ],
             "legacy" : false,
             "granularity" : {
               "type" : "all"
             }
           }
   
         results:
           - ["[1,2]",""]
   ```
   
   Some thoughts:
   
   * It works. Validated with [Yamllint](http://www.yamllint.com/).
   * Easier to handle the structured bits (name, description, options, context).
   * The fact that literal text has to be indented is a nuisance.
   * The result does not really solve the "wall of text" issue that folks raised about the proposed format.
   
   One alternative is to use YAML for the structured stuff, text for the other stuff. But, that ends up pretty much with the format  that is proposed with a few less sections:
   
   ```text
   ==============================================================
   name:  SELECT constant array expression from table
   description: Converted from testSelectConstantArrayExpressionFromTable()
   options:
       sqlCompatibleNulls: both
       vectorize: true
   === SQL
   ...
   === schema
   ...
   === plan
   ...
   === native
   ...
   ```
   
   Here, 4 (or more) equals signs introduces a new test case, where the first section is YAML. The other sections are as defined before. I'm not sure this is a huge win.
   
   Thoughts?


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org