我想使用Flink Table API在同一个字段上连接两个表。
我想实施
DECLARE @T DATETIME2
DBCC DROPCLEANBUFFERS
SET @T =GETDATE()
SELECT SUM(cost)
from tblLog
WHERE logID <=100000
PRINT cast(DATEDIFF(ms,@T,GETDATE()) as NVARCHAR(255))+' Milli seconds'
DBCC DROPCLEANBUFFERS
SET @T =GETDATE()
SELECT SUM(cost)
from tblLog
WHERE logID <=100000
PRINT cast(DATEDIFF(ms,@T,GETDATE()) as NVARCHAR(255))+' Milli seconds'
我试过,但发现实现目标的唯一方法就是
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Warning: Null value is eliminated by an aggregate or other SET operation.
(1 row(s) affected)
(1 row(s) affected)
403 Milli seconds
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Warning: Null value is eliminated by an aggregate or other SET operation.
(1 row(s) affected)
(1 row(s) affected)
103 Milli seconds
但我想重用密钥&#34; id&#34;。
我在Flink文档中找到了这个:
两个表必须具有不同的字段名称,并且必须使用where或filter运算符定义相等连接谓词。
如何重复使用提交的密钥?
答案 0 :(得分:0)
连接结果的模式是两个输入模式的串联。
例如,如果您有left: [a, b, c]
和right: [d, e, f]
,则left
和right
的加入结果是带有架构Table
的新[a, b, c, d, e, f]
。< / p>
如果left
和right
具有相同名称的字段,则后续操作(例如select
)无法识别该字段而不会产生歧义。
所以基本上
val left: Table = ??? // [id, valLeft]
val right: Table = ??? // [id, valRight]
val result: Table = left.join(right).where('id === 'id)
等同于SQL查询
SELECT l.id AS id, l.valLeft, r.id AS id, r.valRight
FROM left l, right r
WHERE l.id = r.id
此SQL查询也不会被接受,因为结果中有两个名为id
的字段。
您可以通过
解决问题as