azure - U-SQL FROM 参数

标签 azure azure-data-lake u-sql

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

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):一个函数,可以选择接受一些参数(如您的示例)并返回一组记录。

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

这同样适用于表格。也可能是 tvf。

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

关于azure - U-SQL FROM 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71695500/

相关文章:

azure - U-SQL 比较标量表达式中的行集数据

visual-studio - 在 Visual Studio 中升级 Azure Functions 项目

java - azure-storage-api java 的 downloadAttributes 上不存在指定的 blob

azure - 如何在Azure Scheduler中安排Azure机器学习的批量执行服务

ssl - 使用 MVC 通配符证书在 Azure 上托管许多 SSL 站点

python - 如何使用python在azure-data-lake中的文件上应用elasticsearch?

azure - 如何在 Azure 数据工厂中将 txt 转换为 csv 文件

azure - 其余操作 Azure Datalake gen2

u-SQL - 是否可以从代码隐藏文件中引用已注册的程序集

azure - 如何在 ADLA 中的 U-SQL 中添加多个文件中的列?