Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-54531

UnionAll introduces multiple useless casts in view-based queries

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Morpheus
    • Morpheus
    • analytics
    • Untriaged
    • 0
    • Unknown
    • Analytics Sprint 8

    Description

      For example, in the test travel-sample-views, the plan contains several calls to cast even though the input and output types are exactly the same.

      For example:

      assign [$$7264, $$4010] <- [cast(cast(cast(cast(cast(cast(cast({\"t\": \"airline_view\", \"k\": $$4072, \"v\": {\"airline_iata_code\": $$4072, \"airline_icao_code\": string-default-null($$airline.getField(\"icao\")), \"airline_callsign\": string-default-null($$airline.getField(\"callsign\")), \"airline_name\": string-default-null($$airline.getField(\"name\")), \"country\": string-default-null($$airline.getField(\"country\"))}}))))))), \"airline_view\"]
      -- ASSIGN  |UNPARTITIONED|
        limit 3
        -- STREAM_LIMIT  |UNPARTITIONED|
          exchange
          -- SORT_MERGE_EXCHANGE [$$4072(ASC) ]  |PARTITIONED|
            limit 3
            -- STREAM_LIMIT  |PARTITIONED|
              exchange
              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                order (topK: 3) (ASC, $$4072)
                -- STABLE_SORT [topK: 3] [$$4072(ASC)]  |PARTITIONED|
                  exchange
                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                    select (not(is-null($$4072)))
                    -- STREAM_SELECT  |PARTITIONED|
                      assign [$$4072] <- [string-default-null($$airline.getField(\"iata\"))]
                      -- ASSIGN  |PARTITIONED|
                        project ([$$airline])
                        -- STREAM_PROJECT  |PARTITIONED|
                          exchange
                          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                            data-scan []<-[$$1295, $$airline, $$1296] <- `travel-sample`.inventory.airline
                            -- DATASOURCE_SCAN  |PARTITIONED|
                              exchange
                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
                                empty-tuple-source
                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED
      

      The multiple casts below are mostly useless as the input and output record types are exactly the same.

      assign [$$7264, $$4010] <- [cast(cast(cast(cast(cast(cast(cast({\"t\": \"airline_view\", \"k\": $$4072, \"v\": {\"airline_iata_code\": $$4072, \"airline_icao_code\": string-default-null($$airline.getField(\"icao\")), \"airline_callsign\": string-default-null($$airline.getField(\"callsign\")), \"airline_name\": string-default-null($$airline.getField(\"name\")), \"country\": string-default-null($$airline.getField(\"country\"))}}))))))), \"airline_view\"]
      

      The issue is ARecordType deepEqual also compares allPossibleAdditionalFieldNames, which (I believe) should not be included in the comparison as it sole purpose is to provide a hint to the compiler about the possible fields in the open part.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            There are no comments yet on this issue.

            People

              wail.alkowaileet Wail Alkowaileet
              wail.alkowaileet Wail Alkowaileet
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty