在databricks中使用max命令时出现问题

x4shl7ld  于 2021-07-24  发布在  Java
关注(0)|答案(1)|浏览(330)

只是运行一个简单的查询

select COL1
from ( 
    select *
    , monotonically_increasing_id() as row_id 
    from db00sparkmigration_landingzone_template.tbl_Ingestion_note_load_errors_pipes 
    ) aa
where row_id > 1 and row_id < max(row_id)

但是得到下面的错误,有什么想法吗?
sql语句中的错误:unsupportedoperationexception:无法计算表达式:max(input[1,bigint,false])

djmepvbi

djmepvbi1#

我建议你 row_number() 这里-但是您需要一个列来定义行的顺序:

select col1
from ( 
    select 
        t.*,
        row_number() over(order by <ordering_col> asc)  rn_asc,
        row_number() over(order by <ordering_col> desc) rn_desc
    from db00sparkmigration_landingzone_template.tbl_Ingestion_note_load_errors_pipes t
) aa
where 1 not in (rn_asc, rn_desc)

相关问题