Five Stars

concatenate context variable in a table name

I have to extract data daily from big query. There is a new table created daily with the timestamp in it. 

for example [dw-bigquery:45234.ga_table_20170626]

 

I am using a context variable which receives the date from a table in YYYY-mm-dd format.

 

Following is my query.

 

select * from 

'[dw-bigquery:45234.ga_table_' +TalendDate.formatDate("yyyyMMdd", context.load_date)+ ']'

 

I get an error for invalid assignment operator.

 

 

  • Data Integration
6 REPLIES
Nine Stars TRF
Nine Stars

Re: concatenate context variable in a table name

Try this:

"select * from 
[dw-bigquery:45234.ga_table_" +TalendDate.formatDate("yyyyMMdd", context.load_date)+ "]"

because each string part must be enclosed between "" (don't know if you need ' and [] for big query).

 

 


TRF
Five Stars

Re: concatenate context variable in a table name

I was still getting errors. 

So I made it more simple 

 

"select * from 
[dw-bigquery:45234.ga_table_" +context.load_date+ "]"

When I run it does not recognise context variable and the table looks like following 

[dw-bigquery:45234.ga_table_]

 

Ten Stars

Re: concatenate context variable in a table name

Your context variable appears to be holding an empty String.

Rilhia Solutions
Ten Stars

Re: concatenate context variable in a table name

Can you show us the part of your job that retrieves the date and sets the context variable?

Five Stars

Re: concatenate context variable in a table name

I set a value where I define my context. Somehow it is not being passed.
But when I set it from sql in tjavarow it works
Five Stars

Re: concatenate context variable in a table name

I found a way by using tposgresqlinput and tjavarow