typhon-project / typhonql

Typhon Query Language
Eclipse Public License 2.0
4 stars 1 forks source link

[BUG] Identifier name in relational table is too long #99

Closed meuriceloup closed 4 years ago

meuriceloup commented 4 years ago

Hi guys,

I tried to deploy the polystore corresponding to the following ML model:

entity "CustomerDemographics" {
   "CustomerTypeID" : string[10]
   "CustomerDesc" : text
   "Customers" -> "Customers"[0..*]
}

entity "Orders" {
   "OrderDate" : date
   "RequiredDate" : date
   "ShippedDate" : date
   "Freight" : float
   "ShipName" : string[40]
   "ShipAddress" : string[60]
   "ShipCity" : string[15]
   "ShipRegion" : string[15]
   "ShipPostalCode" : string[10]
   "ShipCountry" : string[15]
   "Customers" -> "Customers"[0..1]
   "Employees" -> "Employees"[0..1]
   "Shippers" -> "Shippers"[0..1]
   "Order Details" -> "Order Details"."Order Details.Orders"[0..*]
}

entity "Products" {
   "ProductName" : string[40]
   "QuantityPerUnit" : string[20]
   "UnitPrice" : float
   "UnitsInStock" : int
   "UnitsOnOrder" : int
   "ReorderLevel" : int
   "Discontinued" : string[3]
   "Categories" -> "Categories"[0..1]
   "Suppliers" -> "Suppliers"[0..1]
   "Order Details" -> "Order Details"."Order Details.Products"[0..*]
}

entity "Suppliers" {
   "CompanyName" : string[40]
   "ContactName" : string[30]
   "ContactTitle" : string[30]
   "Address" : string[60]
   "City" : string[15]
   "Region" : string[15]
   "PostalCode" : string[10]
   "Country" : string[15]
   "Phone" : string[24]
   "Fax" : string[24]
   "HomePage" : text
   "Products" -> "Products"."Products.Suppliers"[0..*]
}

entity "Customers" {
   "CustomerID" : string[5]
   "CompanyName" : string[40]
   "ContactName" : string[30]
   "ContactTitle" : string[30]
   "Address" : string[60]
   "City" : string[15]
   "Region" : string[15]
   "PostalCode" : string[10]
   "Country" : string[15]
   "Phone" : string[24]
   "Fax" : string[24]
   "Orders" -> "Orders"."Orders.Customers"[0..*]
   "CustomerDemographics" -> "CustomerDemographics"."CustomerDemographics.Customers"[0..*]
}

entity "Categories" {
   "CategoryName" : string[15]
   "Description" : text
   "Picture" : text
   "Products" -> "Products"."Products.Categories"[0..*]
}

entity "Shippers" {
   "CompanyName" : string[40]
   "Phone" : string[24]
   "Orders" -> "Orders"."Orders.Shippers"[0..*]
}

entity "Employees" {
   "LastName" : string[20]
   "FirstName" : string[10]
   "Title" : string[30]
   "TitleOfCourtesy" : string[25]
   "BirthDate" : date
   "HireDate" : date
   "Address" : string[60]
   "City" : string[15]
   "Region" : string[15]
   "PostalCode" : string[10]
   "Country" : string[15]
   "HomePhone" : string[24]
   "Extension" : string[4]
   "Photo" : text
   "Notes" : text
   "PhotoPath" : string[255]
   "Salary" : float
   "Employees" -> "Employees"[0..1]
   "Orders" -> "Orders"."Orders.Employees"[0..*]
   "Employees_1" -> "Employees"."Employees.Employees"[0..*]
   "Territories" -> "Territories"[0..*]
}

entity "Region" {
   "RegionID" : int
   "RegionDescription" : string[50]
   "Territories" -> "Territories"."Territories.Region"[0..*]
}

entity "Order Details" {
   "UnitPrice" : float
   "Quantity" : int
   "Discount" : float
   "Products" -> "Products"[1]
   "Orders" -> "Orders"[1]
}

entity "Territories" {
   "TerritoryID" : string[20]
   "TerritoryDescription" : string[50]
   "Region" -> "Region"[1]
   "Employees" -> "Employees"."Employees.Territories"[0..*]
}

relationaldb RelationalDatabase {
   tables {
      table {
         "CustomerDemographics" : "CustomerDemographics"
         idSpec ("CustomerTypeID")
      }
      table {
         "Orders" : "Orders"
         index "index_0" {
            attributes ("OrderDate")
         }
      }
      table {
         "Products" : "Products"
         index "index_1" {
            attributes ("ProductName")
         }
      }
      table {
         "Suppliers" : "Suppliers"
         index "index_2" {
            attributes ("CompanyName")
         }
      }
      table {
         "Customers" : "Customers"
         index "index_3" {
            attributes ("City")
         }
         idSpec ("CustomerID")
      }
      table {
         "Categories" : "Categories"
         index "index_4" {
            attributes ("CategoryName")
         }
      }
      table {
         "Shippers" : "Shippers"
      }
      table {
         "Employees" : "Employees"
         index "index_5" {
            attributes ("LastName")
         }
      }
      table {
         "Region" : "Region"
         idSpec ("RegionID")
      }
      table {
         "Order Details" : "Order Details"
      }
      table {
         "Territories" : "Territories"
         idSpec ("TerritoryID")
      }
   }
}

After the deployment, I executed the resetdatabases operation. Unfortunately it returns the following error: image

I guess the problem is due to a name too long in the mariadb database.

Thanks in advance, Loup

DavyLandman commented 4 years ago

Ouch, well take a look into fixing it, but for now, use shorter names?

meuriceloup commented 4 years ago

Yes indeed, a shorter name will fix it. However, this schema was automatically inferred by the data ingestion tool which connected an existing relational database (the generated entities names are similar to the original relational tables names, and the same for the attributes),. And the idea would be to avoid manually modifying the generated ML model at the end

DavyLandman commented 4 years ago

Okay, then hold on while we are figuring out a schema 🙂