Kafka CASE 错误 fieldSchema for field cannot be null
Kafka CASE error fieldSchema for field cannot be null
我不能 运行 KSQL 上的 CASE 表达式。
我设置了一个名为 api_log 的流。 api_log 流包含这些信息。
ksql> describe extended api_log;
Name : API_LOG
Type : STREAM
Key field :
Key format : STRING
Timestamp field : CREATED_ON
Value format : AVRO
Kafka topic : api.api_log(partitions: 1, replication: 1)
Field | Type
----------------------------------------------
ROWTIME | BIGINT (system)
ROWKEY | VARCHAR(STRING) (system)
ID | BIGINT
CREATED_ON | BIGINT
UPDATED_ON | BIGINT
API_CODE | VARCHAR(STRING)
API_MESSAGE | VARCHAR(STRING)
API_KEY | VARCHAR(STRING)
----------------------------------------------
Local runtime statistics
------------------------
(Statistics of the local KSQL server interaction with the Kafka topic api.api_log)
我尝试使用 CASE 作为我的 KSQL 语法。
select api_log.status,
case
when api_log.status = 200 then 'success'
else 'error' end as status
from api_log limit 3;
它显示了这个结果。
fieldSchema for field status cannot be null.
然而,当我尝试执行
ksql> select status from api_log limit 10;
200
200
200
200
200
200
200
200
200
200
Limit Reached
Query terminated
它们不是空值。
为什么不起作用????
您使用的是什么版本的 KSQL?
我刚刚尝试在我的环境 运行 KSQL 5.3.0 中重新创建它,并得到了预期的错误(以及更好的错误消息!):
ksql> select api_log.status,
>case
> when api_log.status = 200 then 'success'
> else 'error' end as status
>from api_log limit 3;
Cannot create field because of field name duplication STATUS
Statement: select api_log.status,
case
when api_log.status = 200 then 'success'
else 'error' end as status
from api_log limit 3;
Caused by: Cannot create field because of field name duplication STATUS
要解决这个问题,您应该为第二个状态字段提供不同的别名:
ksql> select api_log.status,
>case
> when api_log.status = 200 then 'success'
> else 'error' end as human_status
>from api_log limit 3;
407 | error
404 | error
302 | error
Limit Reached
Query terminated
我不能 运行 KSQL 上的 CASE 表达式。
我设置了一个名为 api_log 的流。 api_log 流包含这些信息。
ksql> describe extended api_log;
Name : API_LOG
Type : STREAM
Key field :
Key format : STRING
Timestamp field : CREATED_ON
Value format : AVRO
Kafka topic : api.api_log(partitions: 1, replication: 1)
Field | Type
----------------------------------------------
ROWTIME | BIGINT (system)
ROWKEY | VARCHAR(STRING) (system)
ID | BIGINT
CREATED_ON | BIGINT
UPDATED_ON | BIGINT
API_CODE | VARCHAR(STRING)
API_MESSAGE | VARCHAR(STRING)
API_KEY | VARCHAR(STRING)
----------------------------------------------
Local runtime statistics
------------------------
(Statistics of the local KSQL server interaction with the Kafka topic api.api_log)
我尝试使用 CASE 作为我的 KSQL 语法。
select api_log.status,
case
when api_log.status = 200 then 'success'
else 'error' end as status
from api_log limit 3;
它显示了这个结果。
fieldSchema for field status cannot be null.
然而,当我尝试执行
ksql> select status from api_log limit 10;
200
200
200
200
200
200
200
200
200
200
Limit Reached
Query terminated
它们不是空值。
为什么不起作用????
您使用的是什么版本的 KSQL?
我刚刚尝试在我的环境 运行 KSQL 5.3.0 中重新创建它,并得到了预期的错误(以及更好的错误消息!):
ksql> select api_log.status,
>case
> when api_log.status = 200 then 'success'
> else 'error' end as status
>from api_log limit 3;
Cannot create field because of field name duplication STATUS
Statement: select api_log.status,
case
when api_log.status = 200 then 'success'
else 'error' end as status
from api_log limit 3;
Caused by: Cannot create field because of field name duplication STATUS
要解决这个问题,您应该为第二个状态字段提供不同的别名:
ksql> select api_log.status,
>case
> when api_log.status = 200 then 'success'
> else 'error' end as human_status
>from api_log limit 3;
407 | error
404 | error
302 | error
Limit Reached
Query terminated