In V2, the model is the same as it was before. We renamed the method to take into account that in version 2, you can bring back multiple tables of data.
You will still be able to dynamically create the schema based on what users do in the interactive phase. The getSchema call does not happen until after the interactive phase has completed.
In the interactive phase, can I pass in a query and then call connector.getSchema() on the results to see what columns are returned?
In all of the examples, the columns are pre-defined.
If I am understanding correctly, what you would like to do gather some form of input from the user of the WDC, and use that to dynamically create the schema of your connector, is that correct? If so, I would recommend the following workflow:
- User enters your WDC URL
- Tableau launches your WDC in interactive mode.
- In this interactive mode, you would take input from your use - the custom query.
- Store this is the tableau.connectionData property.
- Next, Tableau will launch your WDC in the data gathering mode.
- Tableau will call the connector.getSchema method (you shouldn't need to call this yourself).
- Within this method, you can use the custom query to get the schema and return it to Tableau.
Does that flow sound like it would accomplish your goals?
Let me give that a try and see how it works.
This worked for me.
I go and gather columns based on user input and then save it in the connectionData as described. Do all this prior to tableau.submit and you're off and running.
I have a similar situation with custom queries in a schema on read context. In that case the schema can be determined after the data are retrieved (in getData function). So, how to deal with that?
What I've seen others do in that situation is get a subset of the data during the init function or get schema function, which can be used to generate the schema. Is it possible for you to determine the schema based on a subset of data?
yea, that's what I had in mind too. At the moment I load all data in getSchema(). But having a sample to determine the schema (think of nested json) means probably losing information.