Get basic select query to read from prepared pipe: remove prewhere, sampling, offset, final
| 46 | |
| 47 | /// Get basic select query to read from prepared pipe: remove prewhere, sampling, offset, final |
| 48 | static 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 | |
| 71 | IStorageCnchFile::IStorageCnchFile( |
| 72 | ContextPtr context_, |
no test coverage detected