SelectWithUnionQuery (children 1)
 ExpressionList (children 1)
  SelectQuery (children 3)
   ExpressionList (children 1)
    Asterisk
   TablesInSelectQuery (children 1)
    TablesInSelectQueryElement (children 1)
     TableExpression (children 1)
      Subquery (alias ANIMAL) (children 1)
       SelectWithUnionQuery (children 1)
        ExpressionList (children 1)
         SelectQuery (children 5)
          ExpressionList (children 2)
           Identifier x.b (alias x)
           Function countDistinct (alias ANIMAL) (children 1)
            ExpressionList (children 1)
             Identifier x.c
          TablesInSelectQuery (children 1)
           TablesInSelectQueryElement (children 1)
            TableExpression (children 1)
             Subquery (alias x) (children 1)
              SelectWithUnionQuery (children 1)
               ExpressionList (children 1)
                SelectQuery (children 3)
                 ExpressionList (children 4)
                  Identifier a.ANIMAL (alias a)
                  Literal \'CAT\' (alias b)
                  Identifier c.ANIMAL (alias c)
                  Identifier d.ANIMAL (alias d)
                 TablesInSelectQuery (children 4)
                  TablesInSelectQueryElement (children 1)
                   TableExpression (children 1)
                    TableIdentifier ANIMAL (alias a)
                  TablesInSelectQueryElement (children 2)
                   TableExpression (children 1)
                    TableIdentifier ANIMAL (alias b)
                   TableJoin (children 1)
                    Function equals (children 1)
                     ExpressionList (children 2)
                      Identifier a.ANIMAL
                      Identifier b.ANIMAL
                  TablesInSelectQueryElement (children 2)
                   TableExpression (children 1)
                    TableIdentifier ANIMAL (alias c)
                   TableJoin (children 1)
                    Function equals (children 1)
                     ExpressionList (children 2)
                      Identifier b.ANIMAL
                      Identifier c.ANIMAL
                  TablesInSelectQueryElement (children 2)
                   TableExpression (children 1)
                    Subquery (alias d) (children 1)
                     SelectWithUnionQuery (children 1)
                      ExpressionList (children 3)
                       SelectQuery (children 2)
                        ExpressionList (children 1)
                         Asterisk
                        TablesInSelectQuery (children 1)
                         TablesInSelectQueryElement (children 1)
                          TableExpression (children 1)
                           TableIdentifier ANIMAL
                       SelectQuery (children 2)
                        ExpressionList (children 1)
                         Asterisk
                        TablesInSelectQuery (children 1)
                         TablesInSelectQueryElement (children 1)
                          TableExpression (children 1)
                           TableIdentifier ANIMAL
                       SelectQuery (children 2)
                        ExpressionList (children 1)
                         Asterisk
                        TablesInSelectQuery (children 1)
                         TablesInSelectQueryElement (children 1)
                          TableExpression (children 1)
                           TableIdentifier ANIMAL
                   TableJoin (children 1)
                    Function equals (children 1)
                     ExpressionList (children 2)
                      Identifier a.ANIMAL
                      Identifier d.ANIMAL
                 Function and (children 1)
                  ExpressionList (children 3)
                   Function notEquals (children 1)
                    ExpressionList (children 2)
                     Identifier d.ANIMAL
                     Literal \'CAT\'
                   Function notEquals (children 1)
                    ExpressionList (children 2)
                     Identifier c.ANIMAL
                     Literal \'DOG\'
                   Function notEquals (children 1)
                    ExpressionList (children 2)
                     Identifier b.ANIMAL
                     Literal \'FISH\'
          Function greaterOrEquals (children 1)
           ExpressionList (children 2)
            Identifier x.b
            Literal \'CAT\'
          ExpressionList (children 1)
           Identifier x.b
          Function greaterOrEquals (children 1)
           ExpressionList (children 2)
            Identifier ANIMAL
            Literal UInt64_0
   Function greaterOrEquals (children 1)
    ExpressionList (children 2)
     Identifier ANIMAL.ANIMAL
     Literal UInt64_0
