(Talend OS for Data Integration)
Is it possible to use a dynamic table name? I've researched all of the resources within the user manual and, whilst none of the them seem to expressly rule it out, I can't seem to get it to work.
Scenario
Say you had a huge list of 1,000,000 names - Dave Smith, Dave Jones, Dave Bloggs etc. These are all stored in one table.
You need to split these into tables which reflect the first name, so you would have a DB with tables names such as 'Andy', 'Adrian', 'Adam' etc.
Where I'm at
What I can do, without issue, is batch export a full dataset into a table. I can also iterate through the field to create my individual tables using a tMysqlRow
(this is much quicker on its own).
I then attempted to select and spit out the data into its respective fields, but came across these issues:
It was suggested to look at the ETL components, but their definitions clearly suggest that the table name has to be defined in quotation marks.
It seems really odd for Talend to provide so much use of context variables, but seemingly won't allow you to split one data set into multiple tables dynamically. Is it a product limitation, or just me?
Thanks in advance.
Edit - added screenshots
The context is printing to the window in this screenshot ('AB' was the test context value used) to show that this value was relevant until it was declared in the 'Table' field, but that then returns a null value
Just to add to this, I have managed to get this to work.
information_schema
that are created in a subjobThese are then passes to tHashOutput_1.
tHashInput_1 then feeds these to a tFlowtoIterate
component,
which iterates through my input job.
I can then access each table name by calling (String)globalMap.get("row6.TABLE_NAME"))
, as my tHash schema has one column which I have named 'Table_Name'.
I have a few actions which take place whereby I use the Table_Name
in a filter to extract only the fields which match the table name, then passing it to my yMysqlOutput component, which looks like this:
I've tested it and it's all good. Hopefully this might save someone a LOT of time figuring out this in future (or 5 minutes to someone who is much better with Talend than I am!).
Thanks!