我试图通过加速在 java 流中编写查询。当我尝试sum (l_extendedprice * (1 - l_discount))选择时,出现此错误:
lambda 表达式中的错误返回类型:BigDecimal 无法转换为 long。运算符“-”不能应用于“int”、“java.math.BigDecimal”。
我的代码是这样的:
JoinComponent joinComponent = app.getOrThrow(JoinComponent.class);
Join<Tuple6<Customer, Orders, Lineitem, Supplier, Nation, Region>> join = joinComponent
.from(CustomerManager.IDENTIFIER)
.innerJoinOn(Orders.O_CUSTKEY).equal(Customer.C_CUSTKEY)
.where(Orders.O_ORDERDATE.greaterOrEqual(sqlDate))
.where(Orders.O_ORDERDATE.lessThan(sqlDate2))
.innerJoinOn(Lineitem.L_ORDERKEY).equal(Orders.O_ORDERDATE)
.innerJoinOn(Supplier.S_SUPPKEY ).equal(Customer.C_NATIONKEY)
.innerJoinOn(Nation.N_NATIONKEY).equal(Supplier.S_NATIONKEY)
.innerJoinOn(Region.R_REGIONKEY).equal(Nation.N_REGIONKEY)
.where(Region.R_NAME.equal("ASIA"))
.build(Tuples::of);
Comparator<Tuple1<String>> comparator = Comparator
.comparing((Function<Tuple1<String>, String>) Tuple1::get0)
.thenComparing(Tuple1::get0);
Map<Tuple1<String>, LongSummaryStatistics> grouped = join.stream()
.collect(groupingBy(t -> Tuples.of(t.get4().getNName()),
() -> new TreeMap<>(comparator),
summarizingLong(t->t.get2().getLDiscount()*(1-t.get2().getLDiscount()))
));
我该如何解决这个问题?
繁星点点滴滴
相关分类