U-SQL 脚本中的基本 trim() 函数出错
Getting error with basic trim() function in U-SQL script
我想在列上应用 .trim() 函数但出现错误。
样本数据:
Product_ID,Product_Name
1、办公用品
2、个人护理
我必须进行一些数据操作,但无法正确使用基本的 trim() 函数。
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output = Select Product_ID, Product_Name.trim() from @productlog;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();
错误:
Activity U-SQL1 失败:错误 ID:E_CSC_USER_SYNTAXERROR,错误消息:语法错误。预期之一:“。” ALL ANTISEMIJOIN ANY AS BROADCASTLEFT BROADCASTRIGHT CROSS DISTINCT EXPEPT FULLCROSS GROUP HASHAVING INDEXLOOKUP INNER INTERSECT JOIN LEFT LOOP MERGE ON OPTION ORDER OUTER OUTER UNION PAIR PIVOT PRESORT PRODUCE REONONLY REquired RIGHT SAMPING UNHERFORPION SERIAL TOSE; '(' ')' ',' .
试试下面的方法,据我所知,您需要为修剪后的字段起别名
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output = Select Product_ID, Product_Name.trim() as Trimmed_Product_Name from @productlog;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();
终于做对了,以防其他人遇到同样的问题。 U-SQL 更像是 C#,所以对于像我这样来自纯 SQL 背景的人来说会有点棘手。
代码:
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output =
SELECT
T.Product_ID,
T.Prduct_Name.ToUpper().Trim() AS Prduct_Name
FROM @productlog AS T;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();
我想在列上应用 .trim() 函数但出现错误。 样本数据: Product_ID,Product_Name 1、办公用品 2、个人护理
我必须进行一些数据操作,但无法正确使用基本的 trim() 函数。
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output = Select Product_ID, Product_Name.trim() from @productlog;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();
错误: Activity U-SQL1 失败:错误 ID:E_CSC_USER_SYNTAXERROR,错误消息:语法错误。预期之一:“。” ALL ANTISEMIJOIN ANY AS BROADCASTLEFT BROADCASTRIGHT CROSS DISTINCT EXPEPT FULLCROSS GROUP HASHAVING INDEXLOOKUP INNER INTERSECT JOIN LEFT LOOP MERGE ON OPTION ORDER OUTER OUTER UNION PAIR PIVOT PRESORT PRODUCE REONONLY REquired RIGHT SAMPING UNHERFORPION SERIAL TOSE; '(' ')' ',' .
试试下面的方法,据我所知,您需要为修剪后的字段起别名
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output = Select Product_ID, Product_Name.trim() as Trimmed_Product_Name from @productlog;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();
终于做对了,以防其他人遇到同样的问题。 U-SQL 更像是 C#,所以对于像我这样来自纯 SQL 背景的人来说会有点棘手。
代码:
@productlog =
EXTRACT Product_ID string,
Prduct_Name string
FROM "/Staging/Products.csv"
USING Extractors.Csv();
@output =
SELECT
T.Product_ID,
T.Prduct_Name.ToUpper().Trim() AS Prduct_Name
FROM @productlog AS T;
OUTPUT @output
TO "/Output/Products.csv"
USING Outputters.Csv();