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

Method elementDatabaseAndTable

src/Interpreters/InterpreterExplainQuery.cpp:377–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375
376
377void InterpreterExplainQuery::elementDatabaseAndTable(const ASTSelectQuery & select_query, const ASTPtr & where, WriteBuffer & buffer)
378{
379 if (!select_query.tables())
380 throw Exception("Can not get database and table in element query", ErrorCodes::LOGICAL_ERROR);
381
382 if (select_query.tables()->children.size() != 1)
383 throw Exception("Element query not support multiple table query, such as join, etc", ErrorCodes::LOGICAL_ERROR);
384
385 auto database_and_table = getDatabaseAndTable(select_query, 0);
386 if (database_and_table)
387 {
388 StoragePtr storage = DatabaseCatalog::instance().getTable({database_and_table->database, database_and_table->table}, getContext());
389 buffer << "\"database\": \"" << storage->getStorageID().getDatabaseName() << "\", ";
390 buffer << "\"table\": \"" << storage->getStorageID().getTableName() << "\", ";
391 auto dependencies = DatabaseCatalog::instance().getDependencies(storage->getStorageID());
392 buffer << "\"dependencies\": [";
393 for (size_t i = 0, size = dependencies.size(); i < size; ++i)
394 buffer << "\"" << dependencies[i].getDatabaseName() << "." << dependencies[i].getTableName() << "\""
395 << (i + 1 != size ? ", " : "");
396 buffer << "], ";
397
398 listPartitionKeys(storage, buffer);
399 listRowsOfOnePartition(storage, select_query.groupBy(), where, buffer);
400 }
401 else
402 throw Exception("Can not get database and table in element query", ErrorCodes::LOGICAL_ERROR);
403}
404
405void InterpreterExplainQuery::listPartitionKeys(StoragePtr & storage, WriteBuffer & buffer)
406{

Callers

nothing calls this directly

Calls 10

getDatabaseAndTableFunction · 0.85
ExceptionClass · 0.70
tablesMethod · 0.45
sizeMethod · 0.45
getTableMethod · 0.45
getDatabaseNameMethod · 0.45
getStorageIDMethod · 0.45
getTableNameMethod · 0.45
getDependenciesMethod · 0.45
groupByMethod · 0.45

Tested by

no test coverage detected