Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Improve mapping coverage analysis algorithm to support auto mapped properties via binding #2575

Open
2 tasks done
YannanGao-gs opened this issue Sep 7, 2023 · 0 comments
Assignees
Labels
Studio Core Team Opened by a member of the Studio core team Type: Feature Request
Milestone

Comments

@YannanGao-gs
Copy link
Contributor

Similar requests

  • I have searched and found no existing similar requests

How are you using Legend?

Legend Studio

What problems are you trying to solve?

###Relational
Database inheritance::store::MemSQLDB
(
  Schema PERSON_SCHEMA
  (
    Table PERSON_TABLE
    (
      ID INTEGER PRIMARY KEY,
      FIRSTNAME VARCHAR(100),
      LASTNAME VARCHAR(100),
      FIRM_DETAILS JSON,
      MANAGERID INTEGER
    )
  )
)

Database inheritance::store::SnowflakeDB
(
  Schema PERSON_SCHEMA
  (
    Table PERSON_TABLE
    (
      ID INTEGER PRIMARY KEY,
      FIRSTNAME VARCHAR(100),
      LASTNAME VARCHAR(100),
      FIRM_DETAILS SEMISTRUCTURED,
      MANAGERID INTEGER
    )
  )
)

Database inheritance::store::H2DB
(
  Schema PERSON_SCHEMA
  (
    Table PERSON_TABLE
    (
      ID INTEGER PRIMARY KEY,
      FIRSTNAME VARCHAR(100),
      LASTNAME VARCHAR(100),
      FIRM_DETAILS VARCHAR(1000),
      MANAGERID INTEGER
    )
  )
)


###ExternalFormat
Binding inheritance::store::FirmBinding
{
  contentType: 'application/json';
  modelIncludes: [
    inheritance::model::Firm,
    inheritance::model::Address,
    inheritance::model::AddressWithLines,
    inheritance::model::AddressLine,
    inheritance::model::StreetAddressLine,
    inheritance::model::CityAddressLine,
    inheritance::model::StateAddressLine
  ];
}


###Pure
Class inheritance::model::AddressLine
{
  lineno: Integer[1];
}

Class inheritance::model::StreetAddressLine extends inheritance::model::AddressLine
{
  street: String[1];
}

Class inheritance::model::StateAddressLine extends inheritance::model::AddressLine
{
  state: String[1];
}

Class inheritance::model::CityAddressLine extends inheritance::model::AddressLine
{
  city: String[1];
}

Class inheritance::model::Address
{
  name: String[1];
}

Class inheritance::model::Person
{
  firstName: String[1];
  lastName: String[1];
  firm: inheritance::model::Firm[1];
}

Class inheritance::model::Firm
{
  legalName: String[1];
  address: inheritance::model::Address[1];
}

Class inheritance::model::AddressWithLines extends inheritance::model::Address
{
  lines: inheritance::model::AddressLine[*];
}

function inheritance::semiStructuredPropertyAccessAtSubClass(): meta::pure::tds::TabularDataSet[1]
{
  inheritance::model::Person.all()->project(
    [
      col(
        x|$x.firstName,
        'First Name'
      ),
      col(
        x|$x.firm.address->subType(
          @inheritance::model::AddressWithLines
        ).lines->at(0).lineno,
        'Firm Address 0 Line No'
      )
    ]
  )
}

function inheritance::semiStructuredPropertyAccessAtSubClassNested(): meta::pure::tds::TabularDataSet[1]
{
  inheritance::model::Person.all()->project(
    [
      col(
        x|$x.firstName,
        'First Name'
      ),
      col(
        x|$x.firm.address->subType(
          @inheritance::model::AddressWithLines
        ).lines->at(0).lineno,
        'Firm Address 0 Line No'
      ),
      col(
        x|$x.firm.address->subType(
          @inheritance::model::AddressWithLines
        ).lines->at(0)->subType(
          @inheritance::model::StreetAddressLine
        ).street,
        'Firm Address Street'
      ),
      col(
        x|$x.firm.address->subType(
          @inheritance::model::AddressWithLines
        ).lines->at(1)->subType(
          @inheritance::model::CityAddressLine
        ).city,
        'Firm Address City'
      ),
      col(
        x|$x.firm.address->subType(
          @inheritance::model::AddressWithLines
        ).lines->at(2)->subType(
          @inheritance::model::StateAddressLine
        ).state,
        'Firm Address State'
      )
    ]
  )
}

function inheritance::semiStructuredPropertyAccessAtSubClassNestedUsingProjectWithFunctions(): meta::pure::tds::TabularDataSet[1]
{
  inheritance::model::Person.all()->project(
    [
      x|$x.firstName,
      x|$x.firm.address->subType(
      @inheritance::model::AddressWithLines
    ).lines->at(0).lineno,
      x|$x.firm.address->subType(
      @inheritance::model::AddressWithLines
    ).lines->at(0)->subType(
      @inheritance::model::StreetAddressLine
    ).street,
      x|$x.firm.address->subType(
      @inheritance::model::AddressWithLines
    ).lines->at(1)->subType(
      @inheritance::model::CityAddressLine
    ).city,
      x|$x.firm.address->subType(
      @inheritance::model::AddressWithLines
    ).lines->at(2)->subType(
      @inheritance::model::StateAddressLine
    ).state
    ],
    [
      'First Name',
      'Firm Address 0 Line No',
      'Firm Address Street',
      'Firm Address City',
      'Firm Address State'
    ]
  )
}

function inheritance::semiStructuredPropertyAccessAtBaseClass(): meta::pure::tds::TabularDataSet[1]
{
  inheritance::model::Person.all()->project(
    [
      col(
        x|$x.firstName,
        'First Name'
      ),
      col(
        x|$x.firm.address.name,
        'Firm Address Name'
      )
    ]
  )
}


###Mapping
Mapping inheritance::mapping::MemSQLMapping
(
  inheritance::model::Person: Relational
  {
    ~primaryKey
    (
      [inheritance::store::MemSQLDB]PERSON_SCHEMA.PERSON_TABLE.ID
    )
    ~mainTable [inheritance::store::MemSQLDB]PERSON_SCHEMA.PERSON_TABLE
    firstName: [inheritance::store::MemSQLDB]PERSON_SCHEMA.PERSON_TABLE.FIRSTNAME,
    lastName: [inheritance::store::MemSQLDB]PERSON_SCHEMA.PERSON_TABLE.LASTNAME,
    firm: Binding inheritance::store::FirmBinding : [inheritance::store::MemSQLDB]PERSON_SCHEMA.PERSON_TABLE.FIRM_DETAILS
  }
)

Mapping inheritance::mapping::H2Mapping
(
  inheritance::model::Person: Relational
  {
    ~primaryKey
    (
      [inheritance::store::H2DB]PERSON_SCHEMA.PERSON_TABLE.ID
    )
    ~mainTable [inheritance::store::H2DB]PERSON_SCHEMA.PERSON_TABLE
    firstName: [inheritance::store::H2DB]PERSON_SCHEMA.PERSON_TABLE.FIRSTNAME,
    lastName: [inheritance::store::H2DB]PERSON_SCHEMA.PERSON_TABLE.LASTNAME,
    firm: Binding inheritance::store::FirmBinding : [inheritance::store::H2DB]PERSON_SCHEMA.PERSON_TABLE.FIRM_DETAILS
  }
)

Mapping inheritance::mapping::SnowflakeMapping
(
  inheritance::model::Person: Relational
  {
    ~primaryKey
    (
      [inheritance::store::SnowflakeDB]PERSON_SCHEMA.PERSON_TABLE.ID
    )
    ~mainTable [inheritance::store::SnowflakeDB]PERSON_SCHEMA.PERSON_TABLE
    firstName: [inheritance::store::SnowflakeDB]PERSON_SCHEMA.PERSON_TABLE.FIRSTNAME,
    lastName: [inheritance::store::SnowflakeDB]PERSON_SCHEMA.PERSON_TABLE.LASTNAME,
    firm: Binding inheritance::store::FirmBinding : [inheritance::store::SnowflakeDB]PERSON_SCHEMA.PERSON_TABLE.FIRM_DETAILS
  }
)

Describe the solution you would like to see implemented

Improve mapping coverage analysis algorithm to support auto mapped properties via binding

Describe alternatives you have considered

No response

Documentation, Design, Adoption, Migration Strategy

No response

Contribution

  • I would like to work on this feature
@YannanGao-gs YannanGao-gs self-assigned this Sep 7, 2023
@github-actions github-actions bot added the Studio Core Team Opened by a member of the Studio core team label Sep 7, 2023
@github-actions github-actions bot added this to the Backlog milestone Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Studio Core Team Opened by a member of the Studio core team Type: Feature Request
Projects
None yet
Development

No branches or pull requests

1 participant