ASTERIXDB-865: fix query compilation for if-else expression.

Change-Id: I80e7995e814180fe567818263c79493901af284c
Reviewed-on: https://asterix-gerrit.ics.uci.edu/703
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-1.plan b/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-1.plan
index ebbee79..3664ed8 100644
--- a/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-1.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-1.plan
@@ -23,23 +23,25 @@
                                 -- ASSIGN  |UNPARTITIONED|
                                   -- STREAM_PROJECT  |UNPARTITIONED|
                                     -- UNNEST  |UNPARTITIONED|
-                                      -- SUBPLAN  |UNPARTITIONED|
-                                              {
-                                                -- SUBPLAN  |UNPARTITIONED|
-                                                        {
-                                                          -- AGGREGATE  |UNPARTITIONED|
-                                                            -- STREAM_SELECT  |UNPARTITIONED|
-                                                              -- UNNEST  |UNPARTITIONED|
-                                                                -- SUBPLAN  |UNPARTITIONED|
-                                                                        {
-                                                                          -- AGGREGATE  |UNPARTITIONED|
-                                                                            -- IN_MEMORY_STABLE_SORT [$$21(ASC)]  |UNPARTITIONED|
-                                                                              -- UNNEST  |UNPARTITIONED|
-                                                                                -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
-                                                                        }
-                                                                  -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
-                                                        }
-                                                  -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
-                                              }
-                                        -- ASSIGN  |UNPARTITIONED|
-                                          -- EMPTY_TUPLE_SOURCE  |UNPARTITIONED|
+                                      -- STREAM_PROJECT  |UNPARTITIONED|
+                                        -- SUBPLAN  |UNPARTITIONED|
+                                                {
+                                                  -- ASSIGN  |UNPARTITIONED|
+                                                    -- SUBPLAN  |UNPARTITIONED|
+                                                            {
+                                                              -- AGGREGATE  |UNPARTITIONED|
+                                                                -- STREAM_SELECT  |UNPARTITIONED|
+                                                                  -- UNNEST  |UNPARTITIONED|
+                                                                    -- SUBPLAN  |UNPARTITIONED|
+                                                                            {
+                                                                              -- AGGREGATE  |UNPARTITIONED|
+                                                                                -- IN_MEMORY_STABLE_SORT [$$21(ASC)]  |UNPARTITIONED|
+                                                                                  -- UNNEST  |UNPARTITIONED|
+                                                                                    -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
+                                                                            }
+                                                                      -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
+                                                            }
+                                                      -- NESTED_TUPLE_SOURCE  |UNPARTITIONED|
+                                                }
+                                          -- ASSIGN  |UNPARTITIONED|
+                                            -- EMPTY_TUPLE_SOURCE  |UNPARTITIONED|
diff --git a/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-2.plan b/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-2.plan
index a6e7496..caf4c48 100644
--- a/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-2.plan
+++ b/asterix-app/src/test/resources/optimizerts/results/udfs/query-ASTERIXDB-1308-2.plan
@@ -9,22 +9,23 @@
                             {
                               -- SUBPLAN  |LOCAL|
                                       {
-                                        -- SUBPLAN  |LOCAL|
-                                                {
-                                                  -- AGGREGATE  |LOCAL|
-                                                    -- STREAM_SELECT  |LOCAL|
-                                                      -- ASSIGN  |LOCAL|
-                                                        -- UNNEST  |LOCAL|
-                                                          -- SUBPLAN  |LOCAL|
-                                                                  {
-                                                                    -- AGGREGATE  |LOCAL|
-                                                                      -- IN_MEMORY_STABLE_SORT [$$38(ASC)]  |LOCAL|
-                                                                        -- UNNEST  |LOCAL|
-                                                                          -- NESTED_TUPLE_SOURCE  |LOCAL|
-                                                                  }
-                                                            -- NESTED_TUPLE_SOURCE  |LOCAL|
-                                                }
-                                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                        -- ASSIGN  |LOCAL|
+                                          -- SUBPLAN  |LOCAL|
+                                                  {
+                                                    -- AGGREGATE  |LOCAL|
+                                                      -- STREAM_SELECT  |LOCAL|
+                                                        -- ASSIGN  |LOCAL|
+                                                          -- UNNEST  |LOCAL|
+                                                            -- SUBPLAN  |LOCAL|
+                                                                    {
+                                                                      -- AGGREGATE  |LOCAL|
+                                                                        -- IN_MEMORY_STABLE_SORT [$$38(ASC)]  |LOCAL|
+                                                                          -- UNNEST  |LOCAL|
+                                                                            -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                                                    }
+                                                              -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                                  }
+                                            -- NESTED_TUPLE_SOURCE  |LOCAL|
                                       }
                                 -- SUBPLAN  |LOCAL|
                                         {
@@ -38,22 +39,23 @@
                             }
                       -- SUBPLAN  |LOCAL|
                               {
-                                -- SUBPLAN  |LOCAL|
-                                        {
-                                          -- AGGREGATE  |LOCAL|
-                                            -- STREAM_SELECT  |LOCAL|
-                                              -- ASSIGN  |LOCAL|
-                                                -- UNNEST  |LOCAL|
-                                                  -- SUBPLAN  |LOCAL|
-                                                          {
-                                                            -- AGGREGATE  |LOCAL|
-                                                              -- IN_MEMORY_STABLE_SORT [$$31(ASC)]  |LOCAL|
-                                                                -- UNNEST  |LOCAL|
-                                                                  -- NESTED_TUPLE_SOURCE  |LOCAL|
-                                                          }
-                                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
-                                        }
-                                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                -- ASSIGN  |LOCAL|
+                                  -- SUBPLAN  |LOCAL|
+                                          {
+                                            -- AGGREGATE  |LOCAL|
+                                              -- STREAM_SELECT  |LOCAL|
+                                                -- ASSIGN  |LOCAL|
+                                                  -- UNNEST  |LOCAL|
+                                                    -- SUBPLAN  |LOCAL|
+                                                            {
+                                                              -- AGGREGATE  |LOCAL|
+                                                                -- IN_MEMORY_STABLE_SORT [$$31(ASC)]  |LOCAL|
+                                                                  -- UNNEST  |LOCAL|
+                                                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                                            }
+                                                      -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                          }
+                                    -- NESTED_TUPLE_SOURCE  |LOCAL|
                               }
                         -- NESTED_TUPLE_SOURCE  |LOCAL|
                   }