Query 4: Using the primary index

Fetch the name and routing details of all male passengers.
SELECT fullname,bag.bagInfo[].routing FROM BaggageInfo bag 
WHERE gender!="F"
Plan:
{
  "iterator kind" : "RECEIVE",
  "distribution kind" : "ALL_PARTITIONS",
  "input iterator" :
  {
    "iterator kind" : "SELECT",
    "FROM" :
    {
      "iterator kind" : "TABLE",
      "target table" : "BaggageInfo",
      "row variable" : "$$bag",
      "index used" : "primary index",
      "covering index" : false,
      "index scans" : [
        {
          "equality conditions" : {},
          "range conditions" : {}
        }
      ]
    },
    "FROM variable" : "$$bag",
    "WHERE" :
    {
      "iterator kind" : "NOT_EQUAL",
      "left operand" :
      {
        "iterator kind" : "FIELD_STEP",
        "field name" : "gender",
        "input iterator" :
        {
          "iterator kind" : "VAR_REF",
          "variable" : "$$bag"
        }
      },
      "right operand" :
      {
        "iterator kind" : "CONST",
        "value" : "F"
      }
    },
    "SELECT expressions" : [
      {
        "field name" : "fullname",
        "field expression" :
        {
          "iterator kind" : "FIELD_STEP",
          "field name" : "fullname",
          "input iterator" :
          {
            "iterator kind" : "VAR_REF",
            "variable" : "$$bag"
          }
        }
      },
      {
        "field name" : "routing",
        "field expression" :
        {
          "iterator kind" : "ARRAY_CONSTRUCTOR",
          "conditional" : true,
          "input iterators" : [
            {
              "iterator kind" : "FIELD_STEP",
              "field name" : "routing",
              "input iterator" :
              {
                "iterator kind" : "ARRAY_FILTER",
                "input iterator" :
                {
                  "iterator kind" : "FIELD_STEP",
                  "field name" : "bagInfo",
                  "input iterator" :
                  {
                    "iterator kind" : "VAR_REF",
                    "variable" : "$$bag"
                  }
                }
              }
            }
          ]
        }
      }
    ]
  }
}
Explanation:
  • The root iterator of this query plan is a RECEIVE iterator with a single child (input iterator) that is a SELECT iterator.
  • The value of the FROM field is an iterator; in this case, it is a TABLE iterator.
  • The primary key index is used and the index is not covering ( as you need to scan the table to fetch columns other than the index entries).
  • The FROM variable is the name of a variable ranging over the records produced by the FROM iterator. Here the FROM iterator is a TABLE iterator, and the FROM variable ($$bag) is the same as the row variable of the TABLE iterator, as the index used is not covering.
  • In the SELECT expression two fields (fullname,bag.bagInfo[].routing) are fetched. These correspond to two field names and field expressions in the SELECT expression clause. For the first field, the field expression is computed using FIELD_STEP iterator. For the second field, an ARRAY_CONSTRUCTOR iterator is used which iterates over the corresponding array to fetch the field value.