Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-1893

TeiidException when executing SELECT subquery with more than 2 UNIONs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.7
    • 7.6
    • Query Engine
    • None

      Exception: org.teiid.core.TeiidException happens after executing select statement #1, but works fine on #2 and #3.
      The execution plan for problematic statement attached.

      1. Problematic SQL Statement:

      SELECT T.ROLE_NAME as ROLE_NAME, T.SCHEMA_NAME as SCHEMA_NAME, T.INSTALL_STATUS as INSTALL_STATUS
      FROM (
      SELECT ROLE_NAME, 'demodata_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from demodata_chorus_metadata.chorus_role
      UNION
      SELECT ROLE_NAME, 'security_cia_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from security_cia_chorus_metadata.chorus_role
      UNION
      SELECT ROLE_NAME, 'vantage_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from vantage_chorus_metadata.chorus_role
      ) AS T, chorus_license.RL_LICENSE as L
      WHERE T.ROLE_NAME = L.ROLE_NAME
      AND T.install_status = true;

      2. This SQL statement works fine (the difference between #1 and #2 is in final 'AND...' clause):

      SELECT T.ROLE_NAME as ROLE_NAME, T.SCHEMA_NAME as SCHEMA_NAME, T.INSTALL_STATUS as INSTALL_STATUS
      FROM (
      SELECT ROLE_NAME, 'demodata_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from demodata_chorus_metadata.chorus_role
      UNION
      SELECT ROLE_NAME, 'security_cia_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from security_cia_chorus_metadata.chorus_role
      UNION
      SELECT ROLE_NAME, 'vantage_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from vantage_chorus_metadata.chorus_role
      ) AS T, chorus_license.RL_LICENSE as L
      WHERE T.ROLE_NAME = L.ROLE_NAME;

      3. This SQL statement also works fine (the difference between #1 and #3 is only two UNIONs included out of three, does not matter which ones)

      SELECT T.ROLE_NAME as ROLE_NAME, T.SCHEMA_NAME as SCHEMA_NAME, T.INSTALL_STATUS as INSTALL_STATUS
      FROM (
      SELECT ROLE_NAME, 'security_cia_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from security_cia_chorus_metadata.chorus_role
      UNION
      SELECT ROLE_NAME, 'vantage_chorus_metadata' as SCHEMA_NAME, INSTALL_STATUS from vantage_chorus_metadata.chorus_role
      ) AS T, chorus_license.RL_LICENSE as L
      WHERE T.ROLE_NAME = L.ROLE_NAME
      AND T.install_status = true;

        1. plan.txt
          46 kB
          Andriy Rokhmanov

              rhn-engineering-shawkins Steven Hawkins
              rokhmanov_jira Andriy Rokhmanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: