Share via

data factory dynamic content error

arkiboys 9,711 Reputation points
2021-09-08T10:04:39.827+00:00

Hello,
Do you know what is wrong here please?

select * from edp.LoadTables where SchemaName = '@{pipeline().parameters.pSchemaName}' and SourceSystem = '@{pipeline().parameters.pSourceSystem}' and (@pipeline().parameters.pEntityName IS NULL OR EntityName = '@{pipeline().parameters.pEntityName}')

error: 'Must declare the scalar variable \"@pipeline\".

It looks like the issue is here
and (@pipeline().parameters.pEntityName IS NULL OR...

My intention is to have the expression as same as sql which works:
declare @EntityName varchar(50) --= 'vw_Department'
select * from edp.LoadTables
where SchemaName = 'eol' and SourceSystem = 'xyz'
and (@EntityName is null OR EntityName = @EntityName)

Thank you

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.

0 comments No comments

Answer accepted by question author

HimanshuSinha 19,637 Reputation points Microsoft Employee Moderator
2021-09-10T00:06:35.71+00:00

Hello @arkiboys ,

I think you can achieve the same result by using a UNION ALL clause . I am sharing the dynamic expression below and I think it should help .

@markus.bohland@hotmail.de ('select * from edp.LoadTables where SchemaName =''',pipeline().parameters.pSchemaName,'''',
' and SourceSystem = ','''',pipeline().parameters.pSourceSystem,'''',' AND ', pipeline().parameters.pEntityName,' is null' , ' UNION ALL ', 'select * from edp.LoadTables where SchemaName =''',pipeline().parameters.pSchemaName,'''',
' and SourceSystem = ','''',pipeline().parameters.pSourceSystem,'''',' AND ENTITYName =', '''',pipeline().parameters.pEntityName,''''
)

Let me know how it goes .

Thanks
Himanshu

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Nandan Hegde 36,886 Reputation points MVP Volunteer Moderator
    2021-09-08T10:44:14+00:00

    There is a similar thread :

    you can use a combination of equals and coalesce to handle that scenario something like below:

    @equals(coalesce(pipeline().parameters.Test,'0'),'0')
    

    for this scenario : @{pipeline().parameters.pEntityName} is null

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.