-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: min/max消除, top n #249
base: master
Are you sure you want to change the base?
Conversation
cyz-2023
commented
Nov 20, 2024
•
edited
Loading
edited
- 当select字段只包括min或max函数时,转换为order by xx limit 1。
- sort算子存在limit时,使用topn
- agg/distinct没有聚合函数时,支持limit
- db支持动态修改user quota。
- 无结果时,agg返回0值
- json类型和bit类型支持
- like前缀匹配转range
- 支持distinct count(*)
- float & double返回值精度同to_string函数
body_len = snprintf(tmp_buf, sizeof(tmp_buf), "%.12g", _u.double_val); | ||
std::ostringstream oss; | ||
if (float_precision_len != -1) { | ||
oss << std::fixed << std::setprecision(float_precision_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
精度改回12,否则最大值四舍五入会溢出
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
src/logical_plan/select_planner.cpp
Outdated
if (select_expr.nodes_size() != 2) { | ||
return 0; | ||
} | ||
if (select_expr.nodes(0).node_type() != pb::AGG_EXPR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
上面有了_select_exprs[0].nodes(0).node_type() != pb::AGG_EXPR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
include/sqlparser/sql_parse.y
Outdated
@@ -4028,7 +4028,7 @@ FloatingPointType: | |||
BitValueType: | |||
BIT | |||
{ | |||
$$ = MYSQL_TYPE_BIT; | |||
$$ = MYSQL_TYPE_LONG; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥转MYSQL_TYPE_LONG
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没有针对MYSQL_TYPE_BIT的逻辑,, 为了支持这个类型, 就用long去存储了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sql parser可以不变,可以ddl那里映射到long
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改,ddl_planner中将bit映射为pb::int32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
搞错了, 修改为了int64
@@ -848,6 +849,158 @@ ExprValue json_extract(const std::vector<ExprValue>& input) { | |||
return tmp; | |||
} | |||
|
|||
ExprValue json_extract1(const std::vector<ExprValue>& input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥不能调用json_extract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json对象的 ->和->>操作符返回的结果不一样, 就写了两个函数
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看了下mysql函数,原来的json_extract返回不兼容是吧,mysql带引号
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的, 就是带引号和不带引号两种都有, 那个json_extract不带引号
@@ -168,7 +168,7 @@ int AggNode::open(RuntimeState* state) { | |||
ExecNode* packet = get_parent_node(pb::PACKET_NODE); | |||
// baikaldb才有packet_node;只在baikaldb上产生数据 | |||
// TODB:join和子查询后续如果要完全推到store运行得注意 | |||
if (packet != nullptr) { | |||
if (packet != nullptr || _is_merger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啥sql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
select id from (select max(id) as id from test where id < 1) t;
子查询里面如果没有符合条件的数据, 不会返回null。 导致外面的查询没有结果。 实际应该返回个null
write_binlog_param.username = client_conn->user_info->username; | ||
write_binlog_param.ip = client_conn->ip; | ||
write_binlog_param.client_conn = client_conn; | ||
write_binlog_param.fetcher_store = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
啥情况会core来着
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optype = rollback的时候, 会走到write_binlog里面,取param->client_conn时出core
@@ -832,6 +832,7 @@ static void on_health_check_done(pb::StoreRes* response, brpc::Controller* cntl, | |||
std::unique_ptr<pb::StoreRes> response_guard(response); | |||
std::unique_ptr<brpc::Controller> cntl_guard(cntl); | |||
pb::Status new_status = pb::NORMAL; | |||
old_status = SchemaFactory::get_instance()->get_instance_status(addr).status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会传过来,为啥再拿一遍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
传过来的是旧的, 有个场景, store A在一轮检测的最后一个实例检测, 1s超时会设置为faulty, 但在设置为faulty之前。 已经开始下一轮检测了, 第二轮开始的时候取的status,中间不会变更status,第二轮检测完后应该设置为dead, 但因为是第二轮检测刚开始的时候拿的status, 所以old_status还等于normal。
ScalarFnCall *ltexpr = new ScalarFnCall(); | ||
SlotRef* ltslot = slot->clone(); | ||
ExprValue end_val = prefix_value; | ||
int i = end_val.str_val.length() - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那这个不对,c==255的情况,应该是c=0,然后前一个char+1
@@ -848,6 +849,158 @@ ExprValue json_extract(const std::vector<ExprValue>& input) { | |||
return tmp; | |||
} | |||
|
|||
ExprValue json_extract1(const std::vector<ExprValue>& input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我看了下mysql函数,原来的json_extract返回不兼容是吧,mysql带引号
src/logical_plan/ddl_planner.cpp
Outdated
@@ -1899,6 +1899,12 @@ pb::PrimitiveType DDLPlanner::to_baikal_type(parser::FieldType* field_type) { | |||
case parser::MYSQL_TYPE_TDIGEST: { | |||
return pb::TDIGEST; | |||
} break; | |||
case parser::MYSQL_TYPE_BIT: { | |||
return pb::INT32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是INT64吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改,是应该int64, mysql最大支持到64位