Share via

pipeline expression

arkiboys 9,711 Reputation points
2022-02-03T07:13:03.433+00:00

Hello,
This is the path I would like to use inside the expression of dynamic source of a copy activity
folder1/subfolder1/subfolder2

@split(dataset().pFolderName,'/')[0] --> This gives folder1

Question:
How do I get the remaining of the path: subfolder1/subfolder2
I think what I really need is an expression to get everything after the first '/'
Thanks

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

Vaibhav Chaudhari 39,011 Reputation points Volunteer Moderator
2022-02-03T07:54:30.13+00:00

Try out something like this:

@substring(pipeline().parameters.paramMyFolder,
indexOf(pipeline().parameters.paramMyFolder,'/'),
sub(length(pipeline().parameters.paramMyFolder),indexOf(pipeline().parameters.paramMyFolder,'/')))

Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Nandan Hegde 36,886 Reputation points MVP Volunteer Moderator
    2022-02-03T07:28:09.487+00:00

    Hey,
    You can use a combination of IndexOf and Substring to achieve that.

    @substring(pipeline().parameters.ABC,add(indexof(pipeline().parameters.ABC,'/'),1),sub(length(pipeline().parameters.ABC),add(indexof(pipeline().parameters.ABC,'/'),1)))
    

    Sample code:

    {
        "name": "pipeline1",
        "properties": {
            "activities": [
                {
                    "name": "Set variable1",
                    "type": "SetVariable",
                    "dependsOn": [],
                    "userProperties": [],
                    "typeProperties": {
                        "variableName": "x",
                        "value": {
                            "value": "@string(indexof(pipeline().parameters.ABC,';'))",
                            "type": "Expression"
                        }
                    }
                },
                {
                    "name": "Set variable2",
                    "type": "SetVariable",
                    "dependsOn": [],
                    "userProperties": [],
                    "typeProperties": {
                        "variableName": "y",
                        "value": {
                            "value": "@substring(pipeline().parameters.ABC,add(indexof(pipeline().parameters.ABC,';'),1),sub(length(pipeline().parameters.ABC),add(indexof(pipeline().parameters.ABC,';'),1)))",
                            "type": "Expression"
                        }
                    }
                },
                {
                    "name": "Set variable3",
                    "type": "SetVariable",
                    "dependsOn": [],
                    "userProperties": [],
                    "typeProperties": {
                        "variableName": "z",
                        "value": {
                            "value": "@string(sub(length(pipeline().parameters.ABC),indexof(pipeline().parameters.ABC,';')))",
                            "type": "Expression"
                        }
                    }
                }
            ],
            "parameters": {
                "ABC": {
                    "type": "string",
                    "defaultValue": "11;2;3;4"
                }
            },
            "variables": {
                "x": {
                    "type": "String"
                },
                "y": {
                    "type": "String"
                },
                "z": {
                    "type": "String"
                }
            },
            "annotations": []
        }
    }
    

    Was this answer helpful?

    1 person found this answer helpful.

  2. HimanshuSinha 19,637 Reputation points Microsoft Employee Moderator
    2022-02-03T20:14:32.287+00:00

    Hello @arkiboys ,
    Thanks for the ask and using Microsoft Q&A platform .
    As we understand the ask here is to get the string "subfolder1/subfolder2" from "folder1/subfolder1/subfolder2" . Please do let me know if that not accurate.
    I am in agreement with @Nandan Hegde and anonymous userChaudhari answeer , but you do this way alaso since you are already using the split function
    , you can

    @markus.bohland@hotmail.de (split(pipeline().parameters.paramMyFolder,'/')1,'/',split(pipeline().parameters.paramMyFolder,'/')2)

    171123-image.png

    Please do let me if you have any queries .
    Thanks
    Himanshu

    -------------------------------------------------------------------------------------------------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

    Was this answer helpful?

    0 comments No comments

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.