U-SQL FROM 参数

U-SQL FROM parameter

我想知道是否有人可以帮助我理解以下代码的含义以及使用它的目的。

DECLARE @INPUT_BatchID string = "9035";
DECLARE @BatchID int? = (int?) int.Parse(@INPUT_BatchID);

@dataset1 = 
SELECT col1,col2,col3 
FROM Table AS T

@dataset2 =
SELECT col1,col2,col3
FROM Table2(@dataset1, 0, 20, @BatchID)

TVF 代码如下:

CREATE FUNCTION [Table2](
@baseValues TABLE(ENT_MBR_NM string, [ALS] string,
[NC] string, [DELD] string,
PRNT_MBR_NM string, HIER_LVL int,
GEO_ENT_GENERATION_ID int?, [PATH] string,
RGN_CD string, GLB_GRP string),
@CurrentIteration int = 0,
@MaxIterations int = 20,
@BatchID int? = -1)
RETURNS @result TABLE(ENT_MBR_NM string, [ALS]
string, [NC] string, [DELD]string, PRNT_MBR_NM
string, HIER_LVL int, GEO_ENT_GENERATION_ID int?,
[PATH]string, RGN_CD string, GLB_GRP string) AS

BEGIN
DECLARE @cont1 string = "EMEA";
DECLARE @cont2 string = "EUROPE";
DECLARE @cont3 string = "TOTAL CHINA";
DECLARE @cont4 string = "ASIA PACIFIC";
DECLARE @cont5 string = "UNITED STATES";
DECLARE @cont6 string = "OTHER AMERICAS";
DECLARE @cont7 string = "TOTAL AMERICAS";
DECLARE @cont8 string = "MIDDLE EAST/AFRICA";
DECLARE @cont9 string = "OTHER ASIA PACIFIC";
IF (@CurrentIteration >= @MaxIterations) THEN
@result = SELECT * FROM @baseValues;
ELSE
@nextLevel =
    SELECT A.ENT_MBR_NM,
           A.[ALS],
           A.[NC],
           A.[DELD],
           A.PRNT_MBR_NM,
           T.HIER_LVL + 1 AS HIER_LVL,
           A.GEO_ENT_GENERATION_ID,
           T.[PATH] + " | " + (A.PRNT_MBR_NM ?? "*") AS [PATH],
           A.ENT_MBR_NM.Trim().ToUpper() IN (@cont5, @cont6, @cont2, @cont8, @cont3, @cont9) ? A.ENT_MBR_NM : T.RGN_CD AS RGN_CD,
           A.ENT_MBR_NM.Trim().ToUpper() IN (@cont7, @cont1, @cont4) ? A.ENT_MBR_NM : T.GLB_GRP AS GLB_GRP
    FROM @baseValues AS T 
         INNER JOIN
            [Wz].[Fc].[DH_FCS_GEO_ENT] AS A 
         ON T.ENT_MBR_NM == A.PRNT_MBR_NM
    WHERE A.PartitionID == @BatchID.Value;
    
@baseValues =
    SELECT *
    FROM @baseValues
    UNION ALL
    SELECT *
    FROM @nextLevel;
     
@result = [Table2](@baseValues, @CurrentIteration + 1, @MaxIterations, @BatchID);
END;
END;

这段代码需要很多执行时间,我想减少这些时间,但我不确定@dataset2 中的代码部分(@dataset1、0、20、@BatchID)是什么意思以及它的用途。

任何帮助将不胜感激。

提前致谢。

Table2 很可能是 table valued function(tvf):一个函数,可以选择接受一些参数(如您的示例)和 returns 一组记录。

Table2 函数在您的脚本或引用中的某处定义。

同样适用于Table。也可能是tvf

注意:自从我上次看到使用 u-sql 的问题已经有一段时间了。你已经知道了 the service is being retired?