MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / receiveSampleBlock

Method receiveSampleBlock

src/Client/ClientBase.cpp:1892–1926  ·  view source on GitHub ↗

Receive the block that serves as an example of the structure of table where data will be inserted.

Source from the content-addressed store, hash-verified

1890
1891/// Receive the block that serves as an example of the structure of table where data will be inserted.
1892bool ClientBase::receiveSampleBlock(Block & out, ColumnsDescription & columns_description, ASTPtr parsed_query)
1893{
1894 while (true)
1895 {
1896 Packet packet = connection->receivePacket();
1897
1898 switch (packet.type)
1899 {
1900 case Protocol::Server::Data:
1901 out = packet.block;
1902 return true;
1903
1904 case Protocol::Server::Exception:
1905 onReceiveExceptionFromServer(std::move(packet.exception));
1906 return false;
1907
1908 case Protocol::Server::Log:
1909 onLogData(packet.block);
1910 break;
1911
1912 case Protocol::Server::TableColumns:
1913 columns_description = ColumnsDescription::parse(packet.columns_description);
1914 return receiveSampleBlock(out, columns_description, parsed_query);
1915
1916 case Protocol::Server::TimezoneUpdate:
1917 onTimezoneUpdate(packet.server_timezone);
1918 break;
1919
1920 default:
1921 throw NetException(ErrorCodes::UNEXPECTED_PACKET_FROM_SERVER,
1922 "Unexpected packet from server (expected Data, Exception, Log or TimezoneUpdate, got {})",
1923 String(Protocol::Server::toString(packet.type)));
1924 }
1925 }
1926}
1927
1928
1929void ClientBase::setInsertionTable(const ASTInsertQuery & insert_query)

Callers

nothing calls this directly

Calls 5

NetExceptionClass · 0.85
parseFunction · 0.50
StringClass · 0.50
toStringFunction · 0.50
receivePacketMethod · 0.45

Tested by

no test coverage detected