Impala比较连续行,并插入相同的行,如果没有值
我有一个表格,每个月都会为我提供数据,我需要这段时间。我注意到有时我有3/4个月没有数据,但是我需要复制丢失的时间戳的最后一行。
示例:
product_id | total_revenue | eymonth |
---|---|---|
1 | 50 | 202201 |
2 | 17 | 202201 |
3 | 30 | 202201 |
1 | 67 | 202202 |
2 | 31 | 202202 |
1 67 202202 1 | 67 | 202203 |
2 | 31 | 202203 |
3 | 33 | 202203, |
但我需要一个输出,例如:
product_ID | tote_id tote_id tote_ide_revenue | yearth |
---|---|---|
1 | 3 | 502201 2 17 202201 |
302201 3 | 302201 | 3 302201 3 302201 |
3 | 67 67 7 67 7 | 302201 3 302201 3 302201 3 302201 |
3 | 302201 1 67 67 | 67 7 67 202202 |
2 | 31 | 202202 |
3 | 30 | 202202 |
1 | 67 | 202203 |
2 | 31 | 202203 |
3 | 33 | 202203 |
我有一个精选的陈述,例如:
select
product_id, total_revenue, yearmonth
from
revenue
我找到了类似的问题, (如果没有值)插入相同的行,但是在Impala中,我没有横向连接,有人知道我该怎么做吗?
I have a table that gives me data every month and I need that range of time. I noticed that sometimes I don't have data for 3/4 month but I need to duplicate the last row available with the missing timestamp.
Example:
product_id | total_revenue | yearmonth |
---|---|---|
1 | 50 | 202201 |
2 | 17 | 202201 |
3 | 30 | 202201 |
1 | 67 | 202202 |
2 | 31 | 202202 |
1 | 67 | 202203 |
2 | 31 | 202203 |
3 | 33 | 202203 |
But I need an output like:
product_id | total_revenue | yearmonth |
---|---|---|
1 | 50 | 202201 |
2 | 17 | 202201 |
3 | 30 | 202201 |
1 | 67 | 202202 |
2 | 31 | 202202 |
3 | 30 | 202202 |
1 | 67 | 202203 |
2 | 31 | 202203 |
3 | 33 | 202203 |
I have a select statement like:
select
product_id, total_revenue, yearmonth
from
revenue
I found a similar question, (Postgresql compare consecutive rows and insert identical row if there are no values) but in Impala I have not the lateral join, does anybody know how can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我做到了!
I did it!