-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push down filter on timestamp type column to storage layer (#1875)
* try push down timestamp filter to storage
- Loading branch information
Showing
12 changed files
with
312 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <Common/typeid_cast.h> | ||
#include <Debug/dbgFuncMisc.h> | ||
#include <Interpreters/Context.h> | ||
#include <Parsers/ASTLiteral.h> | ||
|
||
#include <fstream> | ||
#include <regex> | ||
|
||
namespace DB | ||
{ | ||
void dbgFuncSearchLogForKey(Context & context, const ASTs & args, DBGInvoker::Printer output) | ||
{ | ||
if (args.size() < 1) | ||
throw Exception("Args not matched, should be: key", ErrorCodes::BAD_ARGUMENTS); | ||
|
||
String key = safeGet<String>(typeid_cast<const ASTLiteral &>(*args[0]).value); | ||
auto log_path = context.getConfigRef().getString("logger.log"); | ||
|
||
std::ifstream file(log_path); | ||
std::vector<String> line_candidates; | ||
String line; | ||
while (std::getline(file, line)) | ||
{ | ||
if ((line.find(key) != String::npos) && (line.find("DBGInvoke") == String::npos)) | ||
line_candidates.emplace_back(line); | ||
} | ||
if (line_candidates.empty()) | ||
{ | ||
output("Invalid"); | ||
return; | ||
} | ||
auto & target_line = line_candidates.back(); | ||
auto sub_line = target_line.substr(target_line.find(key)); | ||
std::regex rx(R"([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+))"); | ||
std::smatch m; | ||
if (regex_search(sub_line, m, rx)) | ||
output(m[1]); | ||
else | ||
output("Invalid"); | ||
} | ||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <Debug/DBGInvoker.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
class Context; | ||
|
||
// Find the last occurence of `key` in log file and extract the first number follow the key. | ||
// Usage: | ||
// ./storage-client.sh "DBGInvoke search_log_for_key(key)" | ||
void dbgFuncSearchLogForKey(Context & context, const ASTs & args, DBGInvoker::Printer output); | ||
|
||
} // namespace DB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.