如何正确编写我的 clickhouse sql 查询?
Posted
技术标签:
【中文标题】如何正确编写我的 clickhouse sql 查询?【英文标题】:How to write my clickhouse sql query correctly? 【发布时间】:2020-11-26 08:52:15 【问题描述】:我写了一个sql查询:
WITH
type = "id" AND match(value, '*** ID WAS ACTIVATED ***') as id_activ
SELECT
multiIf(
id_activ, 'id_activ',
NULL) as case,
date,
value
FROM my.data.base
但是它不起作用。由于这部分出现问题:match(value, '*** ID WAS ACTIVATED ***')。当我尝试这个时,它完美地工作:
WITH
type = "id" AND value LIKE '%*** ID WAS ACTIVATED ***%' as id_activ
SELECT
multiIf(
id_activ, 'id_activ',
NULL) as case,
date,
value
FROM my.data.base
这是我在比赛中使用的带有该模式的完整消息:
*** ID WAS ACTIVATED *** : Values expired
我怎样才能修复它并编写匹配正确的查询?
与包含方括号的查询相同:
WITH
type = "id" AND match(value, 'Values processed [NUMBERS]') as id_number
SELECT
multiIf(
id_number, 'id_number',
NULL) as case,
date,
value
FROM my.data.base
【问题讨论】:
【参考方案1】:match()
匹配正则表达式
“等价于”
LIKE '%*** ID WAS ACTIVATED ***%'
是
match(value, '.*\*\*\* ID WAS ACTIVATED \*\*\*.*')
https://regex101.com/r/XkRmEY/1
【讨论】:
以上是关于如何正确编写我的 clickhouse sql 查询?的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot + Mybatis-puls + ClickHouse增删改查入门教程
Spring Boot + Mybatis Plus + ClickHouse 轻松实现增删改查,看了必懂。。
Spring Boot + Mybatis Plus + ClickHouse 轻松实现增删改查,看了必懂。。