TDE Template – Unknown Table
- 28 November, 2021
- By admin
- 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.
DuckSize,DuckDescription small,pirate medium,dinosaurWith 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.RubberDuckHopes for a quick exploration are dashed:
SQL-TABLENOTFOUND: amped-qconsole:qconsole-sql($query, ()) -- Unknown table: Table 'RubberDuck.RubberDuck' not found
ExplanationThis 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):
ResolutionTo 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
tde-viewrole. 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-developerrole to avoid this error.