Blog
TDE Template – Unknown Table
- 28 November, 2021
- By Dave Cassel
- No Comments
MarkLogic’s Data Hub Central offers an easy way to create entities. As a bonus, it automatically creates a TDE Template for you, making your entity accessible through SQL or Optic API queries. However, we ran into an error with this process recently.
After creating an entity and processing some sample data, a member of the team tried to run a simple “select *” on the view associated with the entity. That failed with a “SQL-TABLENOTFOUND -- Unknown table
” error. A little investigation revealed the problem. Let’s look at an example.
Like many developers, I have a rubber duck on my desk. It seems appropriate to use that duck to illustrate the problem.
I fired up a new Data Hub example and used Hub Central to create a RubberDuck entity. It has two properties, size and description, both strings. Looking in my data-hub-file-SCHEMAS database, I see my RubberDuck entity (/entities/RubberDuck.entity.json) and a TDE template (/tde/RubberDuck-1.0.0.tdex). I threw in some sample data:
DuckSize,DuckDescription small,pirate medium,dinosaur
With just a little more work, I had a couple RubberDuck entities in my final database. Great! Now I can run a nice simple query (in Query Console as the admin user):
select * from RubberDuck.RubberDuck
Hopes for a quick exploration are dashed:
SQL-TABLENOTFOUND: amped-qconsole:qconsole-sql($query, ()) -- Unknown table: Table 'RubberDuck.RubberDuck' not found
Explanation
This turns out to be a security configuration problem. But wait — I ran that query as my admin user, shouldn’t that work? As it turns out, no. There are some limits on admin users and this is one.
Digging deeper, here are the permissions for the template document (as shown by Query Console):
Role | R | U | I | E | N |
data-hub-entity-model-writer | x | ||||
data-hub-common | x | ||||
tde-admin | x | x | |||
tde-view | x |
If a TDE template document has permissions, then those permissions are extended to the triples and rows built by the template.
Resolution
To solve this, you need to query with a user that has a role with read permissions. For applications, this error is a sign that the user being configured is missing an important role. Odds are, you’re seeing this in development while working with your local admin user. How do I know that?
Looking at the users & roles that make up the Data Hub security model, we can see that data-hub-developer
inherits the tde-admin
role, while data-hub-operator
inherits the tde-view
role. The intent is that users who interact with Data Hub data will have at least one of these roles, which will allow it to read data generated by the TDE templates. Make sure users and roles for your application have these roles assigned appropriately.
If you’re working locally and connecting to Query Console using your admin user, you can give that user the data-hub-developer
role to avoid this error.
Share this post:
4V Services works with development teams to boost their knowledge and capabilities. Contact us today to talk about how we can help you succeed!
MarkLogic’s Data Hub Central offers an easy way to create entities. As a bonus, it automatically creates a TDE Template...