EntityFrameworkCore.ClickHouse icon indicating copy to clipboard operation
EntityFrameworkCore.ClickHouse copied to clipboard

Can translate, clickhouse cannot execute

Open ysq5202121 opened this issue 10 months ago • 8 comments

SELECT "t"."Sku", "t"."StockRegionCode", "t"."ShipmentDate0", COALESCE(SUM("t"."SalesQty"), 0), COALESCE(SUM("t"."NetSalesPrice" * "t"."ExchangeRate"), 0.0), COALESCE(SUM("t"."NetSalesPrice" * "t"."ExchangeRate"), 0.0) / CAST(COALESCE(SUM("t"."SalesQty"), 0) AS Decimal(32, 9))
FROM (
    SELECT "g"."NetSalesPrice", "g"."SalesQty", "g"."Sku", "s"."StockRegionCode", "o"."ExchangeRate", "toYYYYMM"("g"."ShipmentDate") AS "ShipmentDate0"
    FROM "GP_Order_View" AS "g"
    LEFT JOIN "Site" AS "s" ON "g"."SiteID" = "s"."SiteID"
    LEFT JOIN "ODS_Base_CurrencyMonth" AS "o" ON "g"."Period" = "o"."DayPeriod" AND "g"."Currency" = "o"."CurrencyName"
    WHERE "g"."OrderTypeID" = 10 AND "g"."SourceTalbe" = 'GP_OrderDetail' AND "g"."ShipmentDate" >= '2024-04-01' AND "g"."ShipmentDate" < '2024-04-30'
) AS "t"
GROUP BY "t"."Sku", "t"."StockRegionCode", "t"."ShipmentDate0"

The outer layer cannot access the inner layer, and "As" needs to be added inside. I'm not sure if there is a good solution Nested syntax is prone to this problem and is quite common

Error [47] [07000]: Code: 47. DB::Exception: There's no column 't.Sku' in table 't': While processing t.Sku. (UNKNOWN_IDENTIFIER) (version 23.6.2.18 (official build))

ysq5202121 avatar Apr 26 '24 02:04 ysq5202121