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

XmlTable path language is not always identical to XPathValue expressions

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 9.3.4
    • Fix Version/s: 10.0, 8.12.x-6.4, 9.2.7, 9.3.5
    • Component/s: Query Engine
    • Labels:
      None
    • Environment:

      teiid-9.3.4 on WildFly Full 10.0.0.Final (WildFly Core 2.0.10.Final)

    • Steps to Reproduce:
      Hide

      1. run the following query:

      Select xpathvalue('<root>
              <item>
                  <id>id1</id>
                  <val>val1</val>
              </item>
          </root>', '/root/item[id = "id1"]/val');;
      

      it will return "val1" as expected.

      2. run the following query:

      Select * From
          (select '<root>
              <item>
                  <id>id1</id>
                  <val>val1</val>
              </item>
          </root>' as resp) w,
          XMLTABLE(
              '/root' passing XMLPARSE(document w.resp) columns
              valOption2 string PATH 'item[id = "id1"]/val'
              ,valOption1 string PATH 'item[id/text() = "id1"]/val'
          ) x;;
      

      it will return the "val1" twice which looks quite expected.
      3. comment out the line with "valOption1"

      Select * From
          (select '<root>
              <item>
                  <id>id1</id>
                  <val>val1</val>
              </item>
          </root>' as resp) w,
          XMLTABLE(
              '/root' passing XMLPARSE(document w.resp) columns
              valOption2 string PATH 'item[id = "id1"]/val'
              --,valOption1 string PATH 'item[id/text() = "id1"]/val'
          ) x;;
      

      and the returned value for "valOption2" will be changed from "val1" to "null" that is incorrect and unexpected behavior.

      Show
      1. run the following query: Select xpathvalue( '<root> <item> <id>id1</id> <val>val1</val> </item> </root>' , '/root/item[id = "id1"]/val' );; it will return "val1" as expected. 2. run the following query: Select * From ( select '<root> <item> <id>id1</id> <val>val1</val> </item> </root>' as resp) w, XMLTABLE( '/root' passing XMLPARSE(document w.resp) columns valOption2 string PATH 'item[id = "id1"]/val' ,valOption1 string PATH 'item[id/text() = "id1"]/val' ) x;; it will return the "val1" twice which looks quite expected. 3. comment out the line with "valOption1" Select * From ( select '<root> <item> <id>id1</id> <val>val1</val> </item> </root>' as resp) w, XMLTABLE( '/root' passing XMLPARSE(document w.resp) columns valOption2 string PATH 'item[id = "id1"]/val' --,valOption1 string PATH 'item[id/text() = "id1"]/val' ) x;; and the returned value for "valOption2" will be changed from "val1" to "null" that is incorrect and unexpected behavior.
    • Bugzilla Update:
      Perform

      Description

      The same Path value, used in XPathValue and XmlTable->Path brings different results.
      That is for the following query:

      Select * From
          (select '<root>
              <item>
                  <id>id1</id>
                  <val>val1</val>
              </item>
          </root>' as resp) w,
          XMLTABLE(
              '/root' passing XMLPARSE(document w.resp) columns
              valOption2 string PATH 'item[id = "id1"]/val'
              --,valOption1 string PATH 'item[id/text() = "id1"]/val'
          ) x;;
      

      returned value for "valOption2" will be changed from "val1" to "null" that is incorrect and unexpected behavior.
      Using "node/text()" in Path expressions may result in side effects.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                shawkins Steven Hawkins
                Reporter:
                dalex005 dalex dalex
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: