| 1751 | } |
| 1752 | |
| 1753 | BlockIO InterpreterCreateQuery::execute() |
| 1754 | { |
| 1755 | FunctionNameNormalizer().visit(query_ptr.get()); |
| 1756 | auto & create = query_ptr->as<ASTCreateQuery &>(); |
| 1757 | if (!create.cluster.empty()) |
| 1758 | { |
| 1759 | prepareOnClusterQuery(create, getContext(), create.cluster); |
| 1760 | return executeDDLQueryOnCluster(query_ptr, getContext(), getRequiredAccess()); |
| 1761 | } |
| 1762 | |
| 1763 | auto context = getContext(); |
| 1764 | context->checkAccess(getRequiredAccess()); |
| 1765 | if (create.is_dictionary && context->is_tenant_user()) |
| 1766 | { |
| 1767 | if (create.dictionary) |
| 1768 | { |
| 1769 | auto& refresh_query = create.dictionary->clickhouse_query; |
| 1770 | auto& invalidate_query = create.dictionary->clickhouse_invalidate_query; |
| 1771 | if (!refresh_query.empty()) |
| 1772 | executeQuery("explain " + refresh_query, context, true); |
| 1773 | if (!invalidate_query.empty()) |
| 1774 | executeQuery(invalidate_query, context, true); |
| 1775 | } |
| 1776 | |
| 1777 | } |
| 1778 | |
| 1779 | ASTQueryWithOutput::resetOutputASTIfExist(create); |
| 1780 | |
| 1781 | if (!create.catalog.empty() && create.database.empty() && create.table.empty()) |
| 1782 | return createExternalCatalog(create); |
| 1783 | else if (!create.catalog.empty() && (!create.database.empty() || !create.table.empty())) |
| 1784 | throw Exception("create database or table in externcal catalog is not supported", ErrorCodes::INCORRECT_QUERY ); |
| 1785 | /// CREATE|ATTACH DATABASE |
| 1786 | else if (!create.database.empty() && create.table.empty()) |
| 1787 | return createDatabase(create); |
| 1788 | else |
| 1789 | return createTable(create); |
| 1790 | } |
| 1791 | |
| 1792 | |
| 1793 | AccessRightsElements InterpreterCreateQuery::getRequiredAccess() const |
no test coverage detected