Skip to content

使用窗函数lead和lag时,default参数必须为null #1842

@italyfiori

Description

@italyfiori

Describe the bug
使用窗函数lead和lag时,默认值的参数如果不为NULL时,语句报错

To Reproduce
Steps to reproduce the behavior:

  1. create table
CREATE TABLE `table_test` (
  `active_day` date NOT NULL COMMENT "日期",
  `cuid` varchar(64) NOT NULL COMMENT "操作",
  `time` datetime NOT NULL COMMENT "上传时间",
  `operation` varchar(64) NOT NULL COMMENT "操作"
) ENGINE=OLAP
UNIQUE KEY(`active_day`, `cuid`, `time`, `operation`)
DISTRIBUTED BY HASH(`active_day`) BUCKETS 10
PROPERTIES (
"storage_type" = "COLUMN"
); 
  1. insert data
    省略
  2. 查询语句中使用窗函数时提示错误
SELECT cuid,
       operation,
       time,
       lag(operation, 1, '') over (partition BY cuid ORDER BY cuid, time) as last_op
FROM table_test limit 10;

ERROR 1064 (HY000): Type = VARCHAR() can't not convert to VARCHAR()

Expected behavior
SQL正常执行

Additional context
lag或lead的第3个参数改为null时,sql可以正常执行

SELECT cuid,
       operation,
       time,
       lag(operation, 1, null) over (partition BY cuid ORDER BY cuid, time) as last_op
FROM table_test limit 10;

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/fixCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions