@@ -30,33 +30,67 @@ public void init() throws IOException {
3030
3131  @ Test 
3232  public  void  testBasicProjection () throws  IOException  {
33-     JSONObject  result  =
34-         executeQuery (
35-             source (TEST_INDEX_DYNAMIC , "fields firstname, lastname, department, salary | head 1" ));
36- 
33+     String  query  =
34+         source (TEST_INDEX_DYNAMIC , "fields firstname, lastname, department, salary | head 1" );
35+     JSONObject  result  = executeQuery (query );
3736    verifySchema (
3837        result ,
3938        schema ("firstname" , "string" ),
4039        schema ("lastname" , "string" ),
4140        schema ("department" , "string" ),
4241        schema ("salary" , "int" ));
4342    verifyDataRows (result , rows ("John" , "Doe" , "Engineering" , 75000 ));
43+ 
44+     assertExplainYaml (
45+         query ,
46+         "calcite:\n " 
47+             + "  logical: |\n " 
48+             + "    LogicalSystemLimit(fetch=[200], type=[QUERY_SIZE_LIMIT])\n " 
49+             + "      LogicalSort(fetch=[1])\n " 
50+             + "        LogicalProject(firstname=[$0], lastname=[$2], department=[ITEM($9," 
51+             + " 'department')], salary=[ITEM($9, 'salary')])\n " 
52+             + "          CalciteLogicalIndexScan(table=[[OpenSearch, test_dynamic_fields]])\n " 
53+             + "  physical: |\n " 
54+             + "    EnumerableLimit(fetch=[200])\n " 
55+             + "      EnumerableCalc(expr#0..9=[{inputs}], expr#10=['department']," 
56+             + " expr#11=[ITEM($t9, $t10)], expr#12=['salary'], expr#13=[ITEM($t9, $t12)]," 
57+             + " firstname=[$t0], lastname=[$t2], department=[$t11], salary=[$t13])\n " 
58+             + "        EnumerableLimit(fetch=[1])\n " 
59+             + "          CalciteEnumerableIndexScan(table=[[OpenSearch, test_dynamic_fields]])\n " );
4460  }
4561
4662  @ Test 
4763  public  void  testEval () throws  IOException  {
48-     JSONObject   result  =
49-         executeQuery (
50-             source ( 
51-                  TEST_INDEX_DYNAMIC , 
52-                 "eval salary = cast( salary as int) * 2 | fields firstname," 
53-                     +  " lastname, salary | head 1" ) );
64+     String   query  =
65+         source (
66+             TEST_INDEX_DYNAMIC , 
67+             "eval salary = cast(salary as int) * 2 | fields firstname," 
68+                 +  " lastname,  salary | head 1" ); 
69+     JSONObject   result  =  executeQuery ( query );
5470
5571    verifySchema (
5672        result ,
5773        schema ("firstname" , "string" ),
5874        schema ("lastname" , "string" ),
5975        schema ("salary" , "int" ));
76+ 
77+     assertExplainYaml (
78+         query ,
79+         "calcite:\n " 
80+             + "  logical: |\n " 
81+             + "    LogicalSystemLimit(fetch=[200], type=[QUERY_SIZE_LIMIT])\n " 
82+             + "      LogicalSort(fetch=[1])\n " 
83+             + "        LogicalProject(firstname=[$0], lastname=[$2], salary=[*(SAFE_CAST(ITEM($9," 
84+             + " 'salary')), 2)])\n " 
85+             + "          CalciteLogicalIndexScan(table=[[OpenSearch, test_dynamic_fields]])\n " 
86+             + "  physical: |\n " 
87+             + "    EnumerableLimit(fetch=[200])\n " 
88+             + "      EnumerableCalc(expr#0..9=[{inputs}], expr#10=['salary'], expr#11=[ITEM($t9," 
89+             + " $t10)], expr#12=[SAFE_CAST($t11)], expr#13=[2], expr#14=[*($t12, $t13)]," 
90+             + " firstname=[$t0], lastname=[$t2], salary=[$t14])\n " 
91+             + "        EnumerableLimit(fetch=[1])\n " 
92+             + "          CalciteEnumerableIndexScan(table=[[OpenSearch, test_dynamic_fields]])\n " 
93+             + "" );
6094  }
6195
6296  private  void  createTestIndexWithUnmappedFields () throws  IOException  {
@@ -67,8 +101,8 @@ private void createTestIndexWithUnmappedFields() throws IOException {
67101    String  mapping  =
68102        "{" 
69103            + "\" mappings\" : {" 
70-             +  "   \" dynamic \" : false,"   // Disable dynamic mapping - extra fields won't be indexed but 
71-             // will be stored 
104+             // Disable dynamic mapping - extra fields won't be indexed but will be stored  
105+             +  "   \" dynamic \" : false," 
72106            + "  \" properties\" : {" 
73107            + "    \" firstname\" : {\" type\" : \" text\" }," 
74108            + "    \" lastname\" : {\" type\" : \" text\" }," 
0 commit comments