gpt4 book ai didi

sql - U-SQL 构建错误,equijoin 有不同的类型

转载 作者:行者123 更新时间:2023-12-05 00:17:05 26 4
gpt4 key购买 nike

我正在尝试创建一个 USQL 作业并从它们将被检索的 CSV 中定义我的列,但是我总是在 JOIN 部分遇到问题,因为我匹配的列是不同的类型。这很奇怪,因为我已经将它们定义为相同的类型。查看问题所在的屏幕截图:

enter image description here

这是完整的 USQL:

@guestCheck = 
EXTRACT GuestCheckID int,
POSCheckGUID Guid,
POSCheckNumber int?,
OwnerEmployeeID int,
CreatedDateTime DateTime?,
ClosedDateTime DateTime?,
TicketReference string,
CheckAmount decimal?,
POSTerminalID int,
CheckState string,
LocationID int?,
TableID int?,
Covers int?,
PostedDateTime DateTime?,
OrderChannelID int?,
MealPeriodID int?,
RVCLocationID int?,
ReopenedTerminalID int?,
ReopenedEmployeeID int?,
ReopenedDateTime DateTime?,
ClosedBusDate int?,
PostedBusDate int?,
BusHour byte?,
TaxExempt bool?,
TaxExemptReference string
FROM "/GuestCheck/GuestCheck-incomplete.csv"
USING Extractors.Csv();

@guestCheckAncillaryAmount =
EXTRACT CheckAncillaryAmountID int,
GuestCheckID int,
GuestCheckItemID int?,
AncillaryAmountTypeID int,
Amount decimal,
FirstDetail int?,
LastDetail int?,
IsReturn bool?,
ReturnReasonID int?,
AncillaryReasonID int?,
AncillaryNote string,
ClosedBusDate int?,
PostedBusDate int?,
BusHour byte?,
LocationID int?,
RVCLocationID int?,
IsDelisted bool?,
Exempted bool?
FROM "/GuestCheck/GuestCheckAncillaryAmount.csv"
USING Extractors.Csv();

@ancillaryAmountType =
EXTRACT AncillaryAmountTypeID int,
AncillaryAmountCategoryID int,
CustomerID int,
CheckTitle string,
ReportTitle string,
Percentage decimal,
FixedAmount decimal,
IncludeOnCheck bool,
AutoCalculate bool,
StoreAtCheckLevel bool?,
DateTimeModified DateTime?,
CheckTitleToken Guid?,
ReportTitleToken Guid?,
DeletedFlag bool,
MaxUsageQty int?,
ApplyToBasePriceOnly bool?,
Exclusive bool,
IsItem bool,
MinValue decimal,
MaxValue decimal,
ItemGroupID int?,
LocationID int,
ApplicationOrder int?,
RequiresReason bool,
Exemptable bool?
FROM "/GuestCheck/AncillaryAmountType.csv"
USING Extractors.Csv();

@read =
SELECT t.POSCheckGUID,
t.POSCheckNumber,
t.CheckAmount,
aat.AncillaryAmountTypeID,
aat.CheckTitle,
gcd.Amount
FROM @guestCheck AS t
LEFT JOIN
@guestCheckAncillaryAmount AS gcd
ON t.GuestCheckID == gcd.GuestCheckID
LEFT JOIN
@ancillaryAmountType AS aat
ON gcd.AncillaryAmountTypeID == aat.AncillaryAmountTypeID
WHERE aat.AncillaryAmountCategoryID IN(2, 4, 8);

OUTPUT @read
TO "/GuestCheckOutput/output.csv"
USING Outputters.Csv();

最佳答案

事实上,U-SQL 是强类型的,而且 intint?是不同的类型。您需要在中间行集中进行转换:

@ancillaryAmountType2 =
SELECT (int?) aat.AncillaryAmountTypeID AS AncillaryAmountTypeID,
aat.AncillaryAmountCategoryID,
aat.CheckTitle
FROM @ancillaryAmountType AS aat;

或者,更好的是,使用维度建模最佳实践,并出于 http://blog.chrisadamson.com/2013/01/avoid-null-in-dimensions.html 中所述的原因避免可空的“维度”。 .

关于sql - U-SQL 构建错误,equijoin 有不同的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40912416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com