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

Odata4 metadata roundtrip is not in place

    XMLWordPrintable

Details

      1. define vdb with Foreign keys in the metadata
      2. expose it through odata4
      3. create another vdb which imports metadata from odata4
      4. see the DDL resulting from the import

    Description

      Teiid should be able to import (using odata4 translator) metadata exposed by its own odata4 interface.
      Currently there is following identified discrepancy.
      Foreign keys are not properly carried through the expose/import roundtrip. After importing metadata from odata4 endpoint for another vdb (all in single instance), the resulting metadata lacks FK definitions.

      For following data exposed in a VDB:

                  CREATE VIEW A(a_id integer PRIMARY KEY, a_value string) AS SELECT 1, 'a1' UNION ALL SELECT 2, 'a2';
                  CREATE VIEW B(b_id integer PRIMARY KEY, b_value string) AS SELECT 3, 'b1' UNION ALL SELECT 4, 'b2';
                  CREATE VIEW C(c_id integer PRIMARY KEY, a_ref integer, b_ref integer,
                  FOREIGN KEY (a_ref) REFERENCES A(a_id),
                  FOREIGN KEY (b_ref) REFERENCES B(b_id))
                  AS SELECT 5, 1, 3 UNION ALL SELECT 6, 2, 4;
      

      the following odata4 metadata are served:

      <?xml version="1.0" encoding="UTF-8"?>
      <edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
        <edmx:Reference Uri="http://localhost:8080/odata4/static/org.apache.olingo.v1.xml">
          <edmx:Include Namespace="org.apache.olingo.v1" Alias="olingo-extensions"/>
        </edmx:Reference>
        <edmx:DataServices>
          <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="teiid5221data.1.data" Alias="data">
            <EntityType Name="A">
              <Key>
                <PropertyRef Name="a_id"/>
              </Key>
              <Property Name="a_id" Type="Edm.Int32" Nullable="false"/>
              <Property Name="a_value" Type="Edm.String" MaxLength="4000"/>
              <NavigationProperty Name="C_FK0" Type="Collection(data.C)"/>
            </EntityType>
            <EntityType Name="B">
              <Key>
                <PropertyRef Name="b_id"/>
              </Key>
              <Property Name="b_id" Type="Edm.Int32" Nullable="false"/>
              <Property Name="b_value" Type="Edm.String" MaxLength="4000"/>
              <NavigationProperty Name="C_FK1" Type="Collection(data.C)"/>
            </EntityType>
            <EntityType Name="C">
              <Key>
                <PropertyRef Name="c_id"/>
              </Key>
              <Property Name="c_id" Type="Edm.Int32" Nullable="false"/>
              <Property Name="a_ref" Type="Edm.Int32"/>
              <Property Name="b_ref" Type="Edm.Int32"/>
              <NavigationProperty Name="FK0" Type="data.A"/>
              <NavigationProperty Name="FK1" Type="data.B"/>
            </EntityType>
            <EntityContainer Name="data">
              <EntitySet Name="A" EntityType="data.A">
                <NavigationPropertyBinding Path="C_FK0" Target="C"/>
              </EntitySet>
              <EntitySet Name="B" EntityType="data.B">
                <NavigationPropertyBinding Path="C_FK1" Target="C"/>
              </EntitySet>
              <EntitySet Name="C" EntityType="data.C">
                <NavigationPropertyBinding Path="FK0" Target="A"/>
                <NavigationPropertyBinding Path="FK1" Target="B"/>
              </EntitySet>
            </EntityContainer>
          </Schema>
        </edmx:DataServices>
      </edmx:Edmx>
      

      Then, when I import from the odata4 endpoint I get following:

      ===> SET NAMESPACE 'http://www.jboss.org/teiiddesigner/ext/odata/2012' AS teiid_odata;
      
      CREATE FOREIGN TABLE A (
      	a_id integer NOT NULL OPTIONS (NATIVE_TYPE 'Edm.Int32'),
      	a_value string,
      	PRIMARY KEY(a_id)
      ) OPTIONS (UPDATABLE TRUE, "teiid_odata:NameInSchema" 'data.A', "teiid_odata:Type" 'ENTITY_COLLECTION');
      
      CREATE FOREIGN TABLE B (
      	b_id integer NOT NULL OPTIONS (NATIVE_TYPE 'Edm.Int32'),
      	b_value string,
      	PRIMARY KEY(b_id)
      ) OPTIONS (UPDATABLE TRUE, "teiid_odata:NameInSchema" 'data.B', "teiid_odata:Type" 'ENTITY_COLLECTION');
      
      CREATE FOREIGN TABLE C (
      	c_id integer NOT NULL OPTIONS (NATIVE_TYPE 'Edm.Int32'),
      	a_ref integer OPTIONS (NATIVE_TYPE 'Edm.Int32'),
      	b_ref integer OPTIONS (NATIVE_TYPE 'Edm.Int32'),
      	PRIMARY KEY(c_id)
      ) OPTIONS (UPDATABLE TRUE, "teiid_odata:NameInSchema" 'data.C', "teiid_odata:Type" 'ENTITY_COLLECTION');
      

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-shawkins Steven Hawkins
              jstastny@redhat.com Jan Stastny
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: