映射数据流中的排名转换Rank transformation in mapping data flow

适用于: Azure 数据工厂 Azure Synapse Analytics

根据用户指定的排序条件,使用排名转换生成已排序的排名。Use the rank transformation to generate an ordered ranking based upon sort conditions specified by the user.

ConfigurationConfiguration

排名设置Rank settings

不区分大小写:如果排序列的类型为 string,则大小写会影响排名结果。Case insensitive: If a sort column is of type string, case will be factored into the ranking.

密集:如果启用,则排名列将会是密集排名的排名列。Dense: If enabled, the rank column will be dense ranked. 每个排名计数都将是连续数字,并且在出现不相上下的结果后不会跳过排名值。Each rank count will be a consecutive number and rank values won't be skipped after a tie.

排名列:生成的排名列的名称。Rank column: The name of the rank column generated. 此列的类型为 long。This column will be of type long.

排序条件:选择要作为排序依据的列以及排序顺序。Sort conditions: Choose which columns you're sorting by and in which order the sort happens. 该顺序决定排序优先级。The order determines sorting priority.

上述配置将使用传入的篮球数据,并创建一个名为“pointsRanking”的排名列。The above configuration takes incoming basketball data and creates a rank column called 'pointsRanking'. PTS 列值最高的行的 pointsRanking 值将为 1。The row with the highest value of the column PTS will have a pointsRanking value of 1.

数据流脚本Data flow script

语法Syntax

<incomingStream>
    rank(
        desc(<sortColumn1>),
        asc(<sortColumn2>),
        ...,
        caseInsensitive: { true | false }
        dense: { true | false }
        output(<rankColumn> as long)
    ) ~> <sortTransformationName<>

示例Example

排名设置Rank settings

以上排名配置的数据流脚本在下面的代码片段中。The data flow script for the above rank configuration is in the following code snippet.

PruneColumns
    rank(
        desc(PTS, true),
        caseInsensitive: false,
        output(pointsRanking as long),
        dense: false
    ) ~> RankByPoints

后续步骤Next steps

使用筛选器转换根据排名值筛选行。Filter rows based upon the rank values using the filter transformation.