如何在雅典娜中加入非最重要的功能?

发布于 2025-01-28 02:41:14 字数 1081 浏览 1 评论 0原文

我在雅典娜上有此查询。

trip.id as tripid
, segment.id as segmentid
, segment.distance as mileage
, segment.maxspeed as maxspeed
, segment.duration as duration
, segment.roadtype as roadtype
, segment.timeslotdata as timeslots
, extract( week from (from_unixtime(trip.referencedate /1000))) as weekyear
, extract( year from (from_unixtime(trip.referencedate /1000))) as year
, extract( month from (from_unixtime(trip.referencedate/1000))) as month
, unn.firstpositionlat
, unn.firstpositionlong
from
trip
, UNNEST(segments) as t(segment)
left join
(
select
position.latitude as firstpositionlat
, position.longitude as firstpositionlong
, position.id as id
from
trip
, UNNEST(segments) as t(segment)
, UNNEST(segment.positions) as t(position)
where
anno = 2021
and mese = 01
and giorno = 01
and tscid = 'XXX'
)
unn
on
segment.startpositionid = unn.id
where
anno = 2021
and mese = 01
and giorno = 01
and tscid = 'XXX'

问题是我无法加入第16:19行上的错误,并且我有此错误

stytax_error:line 16:19:列“段”无法解析

我无法弄清楚问题在哪里。 如果没有 语句,则效果很好。

先感谢您

i have this query on Athena

trip.id as tripid
, segment.id as segmentid
, segment.distance as mileage
, segment.maxspeed as maxspeed
, segment.duration as duration
, segment.roadtype as roadtype
, segment.timeslotdata as timeslots
, extract( week from (from_unixtime(trip.referencedate /1000))) as weekyear
, extract( year from (from_unixtime(trip.referencedate /1000))) as year
, extract( month from (from_unixtime(trip.referencedate/1000))) as month
, unn.firstpositionlat
, unn.firstpositionlong
from
trip
, UNNEST(segments) as t(segment)
left join
(
select
position.latitude as firstpositionlat
, position.longitude as firstpositionlong
, position.id as id
from
trip
, UNNEST(segments) as t(segment)
, UNNEST(segment.positions) as t(position)
where
anno = 2021
and mese = 01
and giorno = 01
and tscid = 'XXX'
)
unn
on
segment.startpositionid = unn.id
where
anno = 2021
and mese = 01
and giorno = 01
and tscid = 'XXX'

the problem is that i can't join because of an error on line 16:19, and i have this error

SYNTAX_ERROR: line 16:19: Column 'segments' cannot be resolved

i can't figure out where the problem is.
Without the ON statement, this works well.

thank you in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗喜 2025-02-04 02:41:14

presto(雅典娜的基础SQL引擎)支持仅在交叉加入的右侧。例如:

-- sample data
WITH dataset (id, animals) AS (
    values (1, ARRAY['dog', 'cat', 'bird']),
    (2, ARRAY['cow', 'pig'])
) 

-- query
SELECT id, animals, a
FROM dataset
CROSS JOIN UNNEST(animals) AS t (a);

输出:

ID动物1
2[狗,猫,鸟]1
[狗,猫,鸟]1
[狗,猫,鸟]
2[牛,猪]
[牛,牛,猪]

猫 似乎速记符号(trip,unnest(semgments)作为t(semgment))无法正常工作,然后再加入条件,请尝试将其展开到完整形式:

from trip
cross join UNNEST(segments) as t(segment)
left join (...)
on ...

Presto (underlying SQL engine for Athena) supports UNNEST only on the right side of CROSS JOIN. For example:

-- sample data
WITH dataset (id, animals) AS (
    values (1, ARRAY['dog', 'cat', 'bird']),
    (2, ARRAY['cow', 'pig'])
) 

-- query
SELECT id, animals, a
FROM dataset
CROSS JOIN UNNEST(animals) AS t (a);

Output:

idanimalsa
1[dog, cat, bird]dog
1[dog, cat, bird]cat
1[dog, cat, bird]bird
2[cow, pig]cow
2[cow, pig]pig

It seems that shorthand notation (from trip, UNNEST(segments) as t(segment)) is not working correctly when followed by another join with on condition, try to just expand it to the full form:

from trip
cross join UNNEST(segments) as t(segment)
left join (...)
on ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文