MCPcopy Create free account
hub / github.com/ByConity/ByConity / getBasicSelectQuery

Function getBasicSelectQuery

src/Storages/RemoteFile/IStorageCnchFile.cpp:48–69  ·  view source on GitHub ↗

Get basic select query to read from prepared pipe: remove prewhere, sampling, offset, final

Source from the content-addressed store, hash-verified

46
47/// Get basic select query to read from prepared pipe: remove prewhere, sampling, offset, final
48static ASTPtr getBasicSelectQuery(const ASTPtr & original_query)
49{
50 auto query = original_query->clone();
51 auto & select = query->as<ASTSelectQuery &>();
52 auto & tables_in_select_query = select.refTables()->as<ASTTablesInSelectQuery &>();
53 if (tables_in_select_query.children.empty())
54 throw Exception(ErrorCodes::LOGICAL_ERROR, "Tables list is empty, it's a bug");
55 auto & tables_element = tables_in_select_query.children[0]->as<ASTTablesInSelectQueryElement &>();
56 if (!tables_element.table_expression)
57 throw Exception(ErrorCodes::LOGICAL_ERROR, "There is no table expression, it's a bug");
58 tables_element.table_expression->as<ASTTableExpression &>().final = false;
59 tables_element.table_expression->as<ASTTableExpression &>().sample_size = nullptr;
60 tables_element.table_expression->as<ASTTableExpression &>().sample_offset = nullptr;
61
62 /// TODO @canh: can we just throw prewhere away?
63 if (select.prewhere() && select.where())
64 select.setExpression(ASTSelectQuery::Expression::WHERE, makeASTFunction("and", select.where(), select.prewhere()));
65 else if (select.prewhere())
66 select.setExpression(ASTSelectQuery::Expression::WHERE, select.prewhere()->clone());
67 select.setExpression(ASTSelectQuery::Expression::PREWHERE, nullptr);
68 return query;
69}
70
71IStorageCnchFile::IStorageCnchFile(
72 ContextPtr context_,

Callers 1

readMethod · 0.70

Calls 7

makeASTFunctionFunction · 0.85
prewhereMethod · 0.80
ExceptionClass · 0.50
cloneMethod · 0.45
emptyMethod · 0.45
whereMethod · 0.45
setExpressionMethod · 0.45

Tested by

no test coverage detected