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

XmlTable path language is not always identical to XPathValue expressions

    XMLWordPrintable

Details

    • 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.

    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.

      Attachments

        Activity

          People

            rhn-engineering-shawkins Steven Hawkins
            dalex005 Dmitrii Pogorelov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: