mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge branch 'master' into mvcc_prototype
This commit is contained in:
commit
6591d1ceb7
@ -1,12 +1,9 @@
|
||||
# During cross-compilation in our CI we have to use llvm-tblgen and other building tools
|
||||
# tools to be build for host architecture and everything else for target architecture (e.g. AArch64)
|
||||
# Possible workaround is to use llvm-tblgen from some package...
|
||||
# But lets just enable LLVM for native builds
|
||||
if (CMAKE_CROSSCOMPILING OR SANITIZE STREQUAL "undefined")
|
||||
set (ENABLE_EMBEDDED_COMPILER_DEFAULT OFF)
|
||||
if (APPLE OR NOT ARCH_AMD64 OR SANITIZE STREQUAL "undefined")
|
||||
set (ENABLE_EMBEDDED_COMPILER_DEFAULT OFF)
|
||||
else()
|
||||
set (ENABLE_EMBEDDED_COMPILER_DEFAULT ON)
|
||||
set (ENABLE_EMBEDDED_COMPILER_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
option (ENABLE_EMBEDDED_COMPILER "Enable support for 'compile_expressions' option for query execution" ${ENABLE_EMBEDDED_COMPILER_DEFAULT})
|
||||
|
||||
if (NOT ENABLE_EMBEDDED_COMPILER)
|
||||
|
@ -688,7 +688,7 @@ Tags:
|
||||
- `volume_name_N` — Volume name. Volume names must be unique.
|
||||
- `disk` — a disk within a volume.
|
||||
- `max_data_part_size_bytes` — the maximum size of a part that can be stored on any of the volume’s disks. If the a size of a merged part estimated to be bigger than `max_data_part_size_bytes` then this part will be written to a next volume. Basically this feature allows to keep new/small parts on a hot (SSD) volume and move them to a cold (HDD) volume when they reach large size. Do not use this setting if your policy has only one volume.
|
||||
- `move_factor` — when the amount of available space gets lower than this factor, data automatically start to move on the next volume if any (by default, 0.1).
|
||||
- `move_factor` — when the amount of available space gets lower than this factor, data automatically starts to move on the next volume if any (by default, 0.1). ClickHouse sorts existing parts by size from largest to smallest (in descending order) and selects parts with the total size that is sufficient to meet the `move_factor` condition. If the total size of all parts is insufficient, all parts will be moved.
|
||||
- `prefer_not_to_merge` — Disables merging of data parts on this volume. When this setting is enabled, merging data on this volume is not allowed. This allows controlling how ClickHouse works with slow disks.
|
||||
|
||||
Cofiguration examples:
|
||||
|
@ -36,6 +36,7 @@ Example of configuration:
|
||||
<access_key_id>AKIAIOSFODNN7EXAMPLE</access_key_id>
|
||||
<secret_access_key> wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY</secret_access_key>
|
||||
<format>CSV</format>
|
||||
<url>https://s3.us-east-1.amazonaws.com/yourbucket/mydata/</url>
|
||||
</s3_mydata>
|
||||
</named_collections>
|
||||
</clickhouse>
|
||||
@ -44,12 +45,12 @@ Example of configuration:
|
||||
### Example of using named connections with the s3 function
|
||||
|
||||
```sql
|
||||
INSERT INTO FUNCTION s3(s3_mydata, url = 'https://s3.us-east-1.amazonaws.com/yourbucket/mydata/test_file.tsv.gz',
|
||||
INSERT INTO FUNCTION s3(s3_mydata, filename = 'test_file.tsv.gz',
|
||||
format = 'TSV', structure = 'number UInt64', compression_method = 'gzip')
|
||||
SELECT * FROM numbers(10000);
|
||||
|
||||
SELECT count()
|
||||
FROM s3(s3_mydata, url = 'https://s3.us-east-1.amazonaws.com/yourbucket/mydata/test_file.tsv.gz')
|
||||
FROM s3(s3_mydata, filename = 'test_file.tsv.gz')
|
||||
|
||||
┌─count()─┐
|
||||
│ 10000 │
|
||||
|
@ -273,7 +273,7 @@ GitHubのUIでforkリポジトリに移動します。 ブランチで開発し
|
||||
|
||||
プル要求は、作業がまだ完了していない場合でも作成できます。 この場合、単語を入れてください “WIP” (進行中の作業)タイトルの先頭に、それは後で変更することができます。 これは、変更の協調的なレビューと議論、および利用可能なすべてのテストの実行に役立ちます。 変更の簡単な説明を提供することが重要です。
|
||||
|
||||
Yandexの従業員がタグであなたのPRにラベルを付けるとすぐにテストが開始されます “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour.
|
||||
ClickHouseの従業員がタグであなたのPRにラベルを付けるとすぐにテストが開始されます “can be tested”. The results of some first checks (e.g. code style) will come in within several minutes. Build check results will arrive within half an hour. And the main set of tests will report itself within an hour.
|
||||
|
||||
システムは、プル要求用にClickHouseバイナリビルドを個別に準備します。 これらのビルドを取得するには “Details” 次のリンク “ClickHouse build check” 小切手のリストのエントリ。 そこには、ビルドへの直接リンクがあります。ClickHouseのdebパッケージは、本番サーバーにも展開できます(恐れがない場合)。
|
||||
|
||||
|
@ -72,11 +72,11 @@ ClickHouse не работает и не собирается на 32-битны
|
||||
|
||||
Этот вариант не подходит для отправки изменений на сервер. Вы можете временно его использовать, а затем добавить ssh ключи и заменить адрес репозитория с помощью команды `git remote`.
|
||||
|
||||
Вы можете также добавить для своего локального репозитория адрес оригинального репозитория Яндекса, чтобы притягивать оттуда обновления:
|
||||
Вы можете также добавить для своего локального репозитория адрес оригинального репозитория, чтобы притягивать оттуда обновления:
|
||||
|
||||
git remote add upstream git@github.com:ClickHouse/ClickHouse.git
|
||||
|
||||
После этого, вы сможете добавлять в свой репозиторий обновления из репозитория Яндекса с помощью команды `git pull upstream master`.
|
||||
После этого, вы сможете добавлять в свой репозиторий обновления из репозитория ClickHouse с помощью команды `git pull upstream master`.
|
||||
|
||||
### Работа с сабмодулями Git {#rabota-s-sabmoduliami-git}
|
||||
|
||||
@ -288,7 +288,7 @@ sudo ./llvm.sh 12
|
||||
|
||||
Pull request можно создать, даже если работа над задачей ещё не завершена. В этом случае, добавьте в его название слово «WIP» (work in progress). Название можно будет изменить позже. Это полезно для совместного просмотра и обсуждения изменений, а также для запуска всех имеющихся тестов. Введите краткое описание изменений - впоследствии, оно будет использовано для релизных changelog.
|
||||
|
||||
Тесты будут запущены, как только сотрудники Яндекса поставят для pull request тег «Can be tested». Результаты первых проверок (стиль кода) появятся уже через несколько минут. Результаты сборки появятся примерно через пол часа. Результаты основного набора тестов будут доступны в пределах часа.
|
||||
Тесты будут запущены, как только сотрудники ClickHouse поставят для pull request тег «Can be tested». Результаты первых проверок (стиль кода) появятся уже через несколько минут. Результаты сборки появятся примерно через пол часа. Результаты основного набора тестов будут доступны в пределах часа.
|
||||
|
||||
Система подготовит сборки ClickHouse специально для вашего pull request. Для их получения, нажмите на ссылку «Details» у проверки «Clickhouse build check». Там вы сможете найти прямые ссылки на собранные .deb пакеты ClickHouse, которые, при желании, вы даже сможете установить на свои продакшен серверы (если не страшно).
|
||||
|
||||
|
@ -678,7 +678,7 @@ TTL d + INTERVAL 1 MONTH GROUP BY k1, k2 SET x = max(x), y = min(y);
|
||||
- `volume_name_N` — название тома. Названия томов должны быть уникальны.
|
||||
- `disk` — диск, находящийся внутри тома.
|
||||
- `max_data_part_size_bytes` — максимальный размер куска данных, который может находится на любом из дисков этого тома. Если в результате слияния размер куска ожидается больше, чем max_data_part_size_bytes, то этот кусок будет записан в следующий том. В основном эта функция позволяет хранить новые / мелкие куски на горячем (SSD) томе и перемещать их на холодный (HDD) том, когда они достигают большого размера. Не используйте этот параметр, если политика имеет только один том.
|
||||
- `move_factor` — доля доступного свободного места на томе, если места становится меньше, то данные начнут перемещение на следующий том, если он есть (по умолчанию 0.1).
|
||||
- `move_factor` — доля доступного свободного места на томе, если места становится меньше, то данные начнут перемещение на следующий том, если он есть (по умолчанию 0.1). Для перемещения куски сортируются по размеру от большего к меньшему (по убыванию) и выбираются куски, совокупный размер которых достаточен для соблюдения условия `move_factor`, если совокупный размер всех партов недостаточен, будут перемещены все парты.
|
||||
- `prefer_not_to_merge` — Отключает слияние кусков данных, хранящихся на данном томе. Если данная настройка включена, то слияние данных, хранящихся на данном томе, не допускается. Это позволяет контролировать работу ClickHouse с медленными дисками.
|
||||
|
||||
Примеры конфигураций:
|
||||
|
@ -259,7 +259,7 @@ ClickHouse的架构描述可以在此处查看:https://clickhouse.com/docs/en/
|
||||
|
||||
即使工作尚未完成,也可以创建拉取请求。在这种情况下,请在标题的开头加上«WIP»(正在进行中),以便后续更改。这对于协同审查和讨论更改以及运行所有可用测试用例很有用。提供有关变更的简短描述很重要,这将在后续用于生成重新发布变更日志。
|
||||
|
||||
Yandex成员一旦在您的拉取请求上贴上«可以测试»标签,就会开始测试。一些初始检查项(例如,代码类型)的结果会在几分钟内反馈。构建的检查结果将在半小时内完成。而主要的测试用例集结果将在一小时内报告给您。
|
||||
ClickHouse成员一旦在您的拉取请求上贴上«可以测试»标签,就会开始测试。一些初始检查项(例如,代码类型)的结果会在几分钟内反馈。构建的检查结果将在半小时内完成。而主要的测试用例集结果将在一小时内报告给您。
|
||||
|
||||
系统将分别为您的拉取请求准备ClickHouse二进制版本。若要检索这些构建信息,请在检查列表中单击« ClickHouse构建检查»旁边的«详细信息»链接。在这里,您会找到指向ClickHouse的.deb软件包的直接链接,此外,甚至可以将其部署在生产服务器上(如果您不担心)。
|
||||
|
||||
|
@ -183,6 +183,7 @@ enum class AccessType
|
||||
M(JDBC, "", GLOBAL, SOURCES) \
|
||||
M(HDFS, "", GLOBAL, SOURCES) \
|
||||
M(S3, "", GLOBAL, SOURCES) \
|
||||
M(HIVE, "", GLOBAL, SOURCES) \
|
||||
M(SOURCES, "", GROUP, ALL) \
|
||||
\
|
||||
M(ALL, "ALL PRIVILEGES", GROUP, NONE) /* full access */ \
|
||||
|
@ -220,7 +220,7 @@ static void incrementProfileEventsBlock(Block & dst, const Block & src)
|
||||
}
|
||||
|
||||
|
||||
std::atomic_flag exit_on_signal = ATOMIC_FLAG_INIT;
|
||||
std::atomic_flag exit_on_signal;
|
||||
|
||||
class QueryInterruptHandler : private boost::noncopyable
|
||||
{
|
||||
|
@ -241,6 +241,10 @@ FileSegmentsHolder LRUFileCache::getOrSet(const Key & key, size_t offset, size_t
|
||||
|
||||
std::lock_guard cache_lock(mutex);
|
||||
|
||||
#ifndef NDEBUG
|
||||
assertCacheCorrectness(key, cache_lock);
|
||||
#endif
|
||||
|
||||
/// Get all segments which intersect with the given range.
|
||||
auto file_segments = getImpl(key, range, cache_lock);
|
||||
|
||||
@ -315,7 +319,7 @@ FileSegmentsHolder LRUFileCache::getOrSet(const Key & key, size_t offset, size_t
|
||||
|
||||
LRUFileCache::FileSegmentCell * LRUFileCache::addCell(
|
||||
const Key & key, size_t offset, size_t size, FileSegment::State state,
|
||||
std::lock_guard<std::mutex> & /* cache_lock */)
|
||||
std::lock_guard<std::mutex> & cache_lock)
|
||||
{
|
||||
/// Create a file segment cell and put it in `files` map by [key][offset].
|
||||
|
||||
@ -323,8 +327,10 @@ LRUFileCache::FileSegmentCell * LRUFileCache::addCell(
|
||||
return nullptr; /// Empty files are not cached.
|
||||
|
||||
if (files[key].contains(offset))
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Cache already exists for key: `{}`, offset: {}, size: {}", keyToStr(key), offset, size);
|
||||
throw Exception(
|
||||
ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Cache already exists for key: `{}`, offset: {}, size: {}.\nCurrent cache structure: {}",
|
||||
keyToStr(key), offset, size, dumpStructureImpl(key, cache_lock));
|
||||
|
||||
auto file_segment = std::make_shared<FileSegment>(offset, size, key, this, state);
|
||||
FileSegmentCell cell(std::move(file_segment), queue);
|
||||
@ -340,8 +346,10 @@ LRUFileCache::FileSegmentCell * LRUFileCache::addCell(
|
||||
|
||||
auto [it, inserted] = offsets.insert({offset, std::move(cell)});
|
||||
if (!inserted)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Failed to insert into cache key: `{}`, offset: {}, size: {}", keyToStr(key), offset, size);
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Failed to insert into cache key: `{}`, offset: {}, size: {}",
|
||||
keyToStr(key), offset, size);
|
||||
|
||||
return &(it->second);
|
||||
}
|
||||
@ -523,8 +531,8 @@ void LRUFileCache::loadCacheInfoIntoMemory()
|
||||
std::lock_guard cache_lock(mutex);
|
||||
|
||||
Key key;
|
||||
UInt64 offset;
|
||||
size_t size;
|
||||
UInt64 offset = 0;
|
||||
size_t size = 0;
|
||||
std::vector<FileSegmentCell *> cells;
|
||||
|
||||
/// cache_base_path / key_prefix / key / offset
|
||||
@ -687,22 +695,32 @@ LRUFileCache::FileSegmentCell::FileSegmentCell(FileSegmentPtr file_segment_, LRU
|
||||
}
|
||||
}
|
||||
|
||||
String LRUFileCache::dumpStructure(const Key & key_)
|
||||
String LRUFileCache::dumpStructure(const Key & key)
|
||||
{
|
||||
std::lock_guard cache_lock(mutex);
|
||||
return dumpStructureImpl(key, cache_lock);
|
||||
}
|
||||
|
||||
String LRUFileCache::dumpStructureImpl(const Key & key, std::lock_guard<std::mutex> & /* cache_lock */)
|
||||
{
|
||||
WriteBufferFromOwnString result;
|
||||
for (auto it = queue.begin(); it != queue.end(); ++it)
|
||||
{
|
||||
auto [key, offset] = *it;
|
||||
if (key == key_)
|
||||
{
|
||||
auto * cell = getCell(key, offset, cache_lock);
|
||||
result << (it != queue.begin() ? ", " : "") << cell->file_segment->range().toString();
|
||||
result << "(state: " << cell->file_segment->download_state << ")";
|
||||
}
|
||||
}
|
||||
const auto & cells_by_offset = files[key];
|
||||
|
||||
for (const auto & [offset, cell] : cells_by_offset)
|
||||
result << cell.file_segment->getInfoForLog() << "\n";
|
||||
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void LRUFileCache::assertCacheCorrectness(const Key & key, std::lock_guard<std::mutex> & /* cache_lock */)
|
||||
{
|
||||
const auto & cells_by_offset = files[key];
|
||||
|
||||
for (const auto & [_, cell] : cells_by_offset)
|
||||
{
|
||||
const auto & file_segment = cell.file_segment;
|
||||
file_segment->assertCorrectness();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace DB
|
||||
class IFileCache : private boost::noncopyable
|
||||
{
|
||||
friend class FileSegment;
|
||||
friend struct FileSegmentsHolder;
|
||||
|
||||
public:
|
||||
using Key = UInt128;
|
||||
@ -196,6 +197,8 @@ private:
|
||||
FileSegments splitRangeIntoEmptyCells(
|
||||
const Key & key, size_t offset, size_t size, std::lock_guard<std::mutex> & cache_lock);
|
||||
|
||||
String dumpStructureImpl(const Key & key_, std::lock_guard<std::mutex> & cache_lock);
|
||||
|
||||
public:
|
||||
struct Stat
|
||||
{
|
||||
@ -208,6 +211,7 @@ public:
|
||||
Stat getStat();
|
||||
|
||||
String dumpStructure(const Key & key_) override;
|
||||
void assertCacheCorrectness(const Key & key, std::lock_guard<std::mutex> & cache_lock);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -159,7 +159,18 @@ void FileSegment::setRemoteFileReader(RemoteFileReaderPtr remote_file_reader_)
|
||||
remote_file_reader = remote_file_reader_;
|
||||
}
|
||||
|
||||
void FileSegment::write(const char * from, size_t size)
|
||||
void FileSegment::resetRemoteFileReader()
|
||||
{
|
||||
if (!isDownloader())
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR, "Only downloader can use remote filesystem file reader");
|
||||
|
||||
if (!remote_file_reader)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Remote file reader does not exist");
|
||||
|
||||
remote_file_reader.reset();
|
||||
}
|
||||
|
||||
void FileSegment::write(const char * from, size_t size, size_t offset_)
|
||||
{
|
||||
if (!size)
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR, "Writing zero size is not allowed");
|
||||
@ -174,8 +185,24 @@ void FileSegment::write(const char * from, size_t size)
|
||||
"Only downloader can do the downloading. (CallerId: {}, DownloaderId: {})",
|
||||
getCallerId(), downloader_id);
|
||||
|
||||
if (downloaded_size == range().size())
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Attempt to write {} bytes to offset: {}, but current file segment is already fully downloaded",
|
||||
size, offset_);
|
||||
|
||||
auto download_offset = range().left + downloaded_size;
|
||||
if (offset_ != download_offset)
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Attempt to write {} bytes to offset: {}, but current download offset is {}",
|
||||
size, offset_, download_offset);
|
||||
|
||||
if (!cache_writer)
|
||||
{
|
||||
if (downloaded_size > 0)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Cache writer was finalized (downloaded size: {}, state: {})",
|
||||
downloaded_size, stateToString(download_state));
|
||||
|
||||
auto download_path = cache->getPathInLocalCache(key(), offset());
|
||||
cache_writer = std::make_unique<WriteBufferFromFile>(download_path);
|
||||
}
|
||||
@ -190,19 +217,26 @@ void FileSegment::write(const char * from, size_t size)
|
||||
|
||||
downloaded_size += size;
|
||||
}
|
||||
catch (...)
|
||||
catch (Exception & e)
|
||||
{
|
||||
std::lock_guard segment_lock(mutex);
|
||||
|
||||
LOG_ERROR(log, "Failed to write to cache. File segment info: {}", getInfoForLogImpl(segment_lock));
|
||||
auto info = getInfoForLogImpl(segment_lock);
|
||||
e.addMessage("while writing into cache, info: " + info);
|
||||
|
||||
LOG_ERROR(log, "Failed to write to cache. File segment info: {}", info);
|
||||
|
||||
download_state = State::PARTIALLY_DOWNLOADED_NO_CONTINUATION;
|
||||
|
||||
cache_writer->finalize();
|
||||
cache_writer.reset();
|
||||
|
||||
cv.notify_all();
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
assert(getDownloadOffset() == offset_ + size);
|
||||
}
|
||||
|
||||
FileSegment::State FileSegment::wait()
|
||||
@ -270,7 +304,6 @@ void FileSegment::setDownloaded(std::lock_guard<std::mutex> & /* segment_lock */
|
||||
download_state = State::DOWNLOADED;
|
||||
is_downloaded = true;
|
||||
|
||||
assert(cache_writer);
|
||||
if (cache_writer)
|
||||
{
|
||||
cache_writer->finalize();
|
||||
@ -299,107 +332,125 @@ void FileSegment::completeBatchAndResetDownloader()
|
||||
|
||||
void FileSegment::complete(State state)
|
||||
{
|
||||
{
|
||||
std::lock_guard segment_lock(mutex);
|
||||
|
||||
bool is_downloader = downloader_id == getCallerId();
|
||||
if (!is_downloader)
|
||||
{
|
||||
cv.notify_all();
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"File segment can be completed only by downloader or downloader's FileSegmentsHodler");
|
||||
}
|
||||
|
||||
if (state != State::DOWNLOADED
|
||||
&& state != State::PARTIALLY_DOWNLOADED
|
||||
&& state != State::PARTIALLY_DOWNLOADED_NO_CONTINUATION)
|
||||
{
|
||||
cv.notify_all();
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Cannot complete file segment with state: {}", stateToString(state));
|
||||
}
|
||||
|
||||
download_state = state;
|
||||
}
|
||||
|
||||
completeImpl();
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void FileSegment::complete()
|
||||
{
|
||||
{
|
||||
std::lock_guard segment_lock(mutex);
|
||||
|
||||
if (download_state == State::SKIP_CACHE || detached)
|
||||
return;
|
||||
|
||||
if (download_state != State::DOWNLOADED && getDownloadedSize(segment_lock) == range().size())
|
||||
setDownloaded(segment_lock);
|
||||
|
||||
if (download_state == State::DOWNLOADING || download_state == State::EMPTY)
|
||||
download_state = State::PARTIALLY_DOWNLOADED;
|
||||
}
|
||||
|
||||
completeImpl(true);
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void FileSegment::completeImpl(bool allow_non_strict_checking)
|
||||
{
|
||||
/// cache lock is always taken before segment lock.
|
||||
std::lock_guard cache_lock(cache->mutex);
|
||||
std::lock_guard segment_lock(mutex);
|
||||
|
||||
bool download_can_continue = false;
|
||||
|
||||
if (download_state == State::PARTIALLY_DOWNLOADED
|
||||
|| download_state == State::PARTIALLY_DOWNLOADED_NO_CONTINUATION)
|
||||
bool is_downloader = downloader_id == getCallerId();
|
||||
if (!is_downloader)
|
||||
{
|
||||
bool is_last_holder = cache->isLastFileSegmentHolder(key(), offset(), cache_lock, segment_lock);
|
||||
download_can_continue = !is_last_holder && download_state == State::PARTIALLY_DOWNLOADED;
|
||||
cv.notify_all();
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"File segment can be completed only by downloader or downloader's FileSegmentsHodler");
|
||||
}
|
||||
|
||||
if (!download_can_continue)
|
||||
if (state != State::DOWNLOADED
|
||||
&& state != State::PARTIALLY_DOWNLOADED
|
||||
&& state != State::PARTIALLY_DOWNLOADED_NO_CONTINUATION)
|
||||
{
|
||||
cv.notify_all();
|
||||
throw Exception(ErrorCodes::REMOTE_FS_OBJECT_CACHE_ERROR,
|
||||
"Cannot complete file segment with state: {}", stateToString(state));
|
||||
}
|
||||
|
||||
download_state = state;
|
||||
|
||||
try
|
||||
{
|
||||
completeImpl(cache_lock, segment_lock);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!downloader_id.empty() && downloader_id == getCallerIdImpl(true))
|
||||
downloader_id.clear();
|
||||
|
||||
cv.notify_all();
|
||||
throw;
|
||||
}
|
||||
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void FileSegment::complete(std::lock_guard<std::mutex> & cache_lock)
|
||||
{
|
||||
std::lock_guard segment_lock(mutex);
|
||||
|
||||
if (download_state == State::SKIP_CACHE || detached)
|
||||
return;
|
||||
|
||||
if (download_state != State::DOWNLOADED && getDownloadedSize(segment_lock) == range().size())
|
||||
setDownloaded(segment_lock);
|
||||
|
||||
if (download_state == State::DOWNLOADING || download_state == State::EMPTY)
|
||||
{
|
||||
/// Segment state can be changed from DOWNLOADING or EMPTY only if the caller is the
|
||||
/// downloader or the only owner of the segment.
|
||||
|
||||
bool can_update_segment_state = downloader_id == getCallerIdImpl(true)
|
||||
|| cache->isLastFileSegmentHolder(key(), offset(), cache_lock, segment_lock);
|
||||
|
||||
if (can_update_segment_state)
|
||||
download_state = State::PARTIALLY_DOWNLOADED;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
completeImpl(cache_lock, segment_lock, /* allow_non_strict_checking */true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!downloader_id.empty() && downloader_id == getCallerIdImpl(true))
|
||||
downloader_id.clear();
|
||||
|
||||
cv.notify_all();
|
||||
throw;
|
||||
}
|
||||
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void FileSegment::completeImpl(std::lock_guard<std::mutex> & cache_lock, std::lock_guard<std::mutex> & segment_lock, bool allow_non_strict_checking)
|
||||
{
|
||||
bool is_last_holder = cache->isLastFileSegmentHolder(key(), offset(), cache_lock, segment_lock);
|
||||
|
||||
if (is_last_holder
|
||||
&& (download_state == State::PARTIALLY_DOWNLOADED || download_state == State::PARTIALLY_DOWNLOADED_NO_CONTINUATION))
|
||||
{
|
||||
size_t current_downloaded_size = getDownloadedSize(segment_lock);
|
||||
if (current_downloaded_size == 0)
|
||||
{
|
||||
size_t current_downloaded_size = getDownloadedSize(segment_lock);
|
||||
if (current_downloaded_size == 0)
|
||||
{
|
||||
download_state = State::SKIP_CACHE;
|
||||
LOG_TEST(log, "Remove cell {} (nothing downloaded)", range().toString());
|
||||
cache->remove(key(), offset(), cache_lock, segment_lock);
|
||||
download_state = State::SKIP_CACHE;
|
||||
LOG_TEST(log, "Remove cell {} (nothing downloaded)", range().toString());
|
||||
cache->remove(key(), offset(), cache_lock, segment_lock);
|
||||
}
|
||||
else
|
||||
{
|
||||
/**
|
||||
* Only last holder of current file segment can resize the cell,
|
||||
* because there is an invariant that file segments returned to users
|
||||
* in FileSegmentsHolder represent a contiguous range, so we can resize
|
||||
* it only when nobody needs it.
|
||||
*/
|
||||
LOG_TEST(log, "Resize cell {} to downloaded: {}", range().toString(), current_downloaded_size);
|
||||
cache->reduceSizeToDownloaded(key(), offset(), cache_lock, segment_lock);
|
||||
}
|
||||
|
||||
detached = true;
|
||||
}
|
||||
else if (is_last_holder)
|
||||
{
|
||||
/**
|
||||
* Only last holder of current file segment can resize the cell,
|
||||
* because there is an invariant that file segments returned to users
|
||||
* in FileSegmentsHolder represent a contiguous range, so we can resize
|
||||
* it only when nobody needs it.
|
||||
*/
|
||||
LOG_TEST(log, "Resize cell {} to downloaded: {}", range().toString(), current_downloaded_size);
|
||||
cache->reduceSizeToDownloaded(key(), offset(), cache_lock, segment_lock);
|
||||
detached = true;
|
||||
|
||||
detached = true;
|
||||
}
|
||||
if (cache_writer)
|
||||
{
|
||||
cache_writer->finalize();
|
||||
cache_writer.reset();
|
||||
remote_file_reader.reset();
|
||||
}
|
||||
}
|
||||
|
||||
if (!downloader_id.empty() && downloader_id == getCallerIdImpl(allow_non_strict_checking))
|
||||
if (!downloader_id.empty() && (downloader_id == getCallerIdImpl(allow_non_strict_checking) || is_last_holder))
|
||||
{
|
||||
LOG_TEST(log, "Clearing downloader id: {}, current state: {}", downloader_id, stateToString(download_state));
|
||||
downloader_id.clear();
|
||||
}
|
||||
|
||||
if (!download_can_continue && cache_writer)
|
||||
{
|
||||
cache_writer->finalize();
|
||||
cache_writer.reset();
|
||||
remote_file_reader.reset();
|
||||
}
|
||||
|
||||
assert(download_state != FileSegment::State::DOWNLOADED || std::filesystem::file_size(cache->getPathInLocalCache(key(), offset())) > 0);
|
||||
assertCorrectnessImpl(segment_lock);
|
||||
}
|
||||
|
||||
String FileSegment::getInfoForLog() const
|
||||
@ -440,6 +491,56 @@ String FileSegment::stateToString(FileSegment::State state)
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
void FileSegment::assertCorrectness() const
|
||||
{
|
||||
std::lock_guard segment_lock(mutex);
|
||||
assertCorrectnessImpl(segment_lock);
|
||||
}
|
||||
|
||||
void FileSegment::assertCorrectnessImpl(std::lock_guard<std::mutex> & /* segment_lock */) const
|
||||
{
|
||||
assert(downloader_id.empty() == (download_state != FileSegment::State::DOWNLOADING));
|
||||
assert(!downloader_id.empty() == (download_state == FileSegment::State::DOWNLOADING));
|
||||
assert(download_state != FileSegment::State::DOWNLOADED || std::filesystem::file_size(cache->getPathInLocalCache(key(), offset())) > 0);
|
||||
}
|
||||
|
||||
FileSegmentsHolder::~FileSegmentsHolder()
|
||||
{
|
||||
/// In CacheableReadBufferFromRemoteFS file segment's downloader removes file segments from
|
||||
/// FileSegmentsHolder right after calling file_segment->complete(), so on destruction here
|
||||
/// remain only uncompleted file segments.
|
||||
|
||||
IFileCache * cache = nullptr;
|
||||
|
||||
for (auto file_segment_it = file_segments.begin(); file_segment_it != file_segments.end();)
|
||||
{
|
||||
auto current_file_segment_it = file_segment_it;
|
||||
auto & file_segment = *current_file_segment_it;
|
||||
|
||||
if (!cache)
|
||||
cache = file_segment->cache;
|
||||
|
||||
try
|
||||
{
|
||||
/// File segment pointer must be reset right after calling complete() and
|
||||
/// under the same mutex, because complete() checks for segment pointers.
|
||||
std::lock_guard cache_lock(cache->mutex);
|
||||
|
||||
file_segment->complete(cache_lock);
|
||||
|
||||
file_segment_it = file_segments.erase(current_file_segment_it);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
#ifdef NDEBUG
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
#else
|
||||
throw;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String FileSegmentsHolder::toString()
|
||||
{
|
||||
String ranges;
|
||||
|
@ -95,12 +95,14 @@ public:
|
||||
|
||||
bool reserve(size_t size);
|
||||
|
||||
void write(const char * from, size_t size);
|
||||
void write(const char * from, size_t size, size_t offset_);
|
||||
|
||||
RemoteFileReaderPtr getRemoteFileReader();
|
||||
|
||||
void setRemoteFileReader(RemoteFileReaderPtr remote_file_reader_);
|
||||
|
||||
void resetRemoteFileReader();
|
||||
|
||||
String getOrSetDownloader();
|
||||
|
||||
String getDownloader() const;
|
||||
@ -121,16 +123,32 @@ public:
|
||||
|
||||
String getInfoForLog() const;
|
||||
|
||||
void assertCorrectness() const;
|
||||
|
||||
private:
|
||||
size_t availableSize() const { return reserved_size - downloaded_size; }
|
||||
bool lastFileSegmentHolder() const;
|
||||
void complete();
|
||||
void completeImpl(bool allow_non_strict_checking = false);
|
||||
void setDownloaded(std::lock_guard<std::mutex> & segment_lock);
|
||||
static String getCallerIdImpl(bool allow_non_strict_checking = false);
|
||||
void resetDownloaderImpl(std::lock_guard<std::mutex> & segment_lock);
|
||||
|
||||
size_t getDownloadedSize(std::lock_guard<std::mutex> & segment_lock) const;
|
||||
String getInfoForLogImpl(std::lock_guard<std::mutex> & segment_lock) const;
|
||||
void assertCorrectnessImpl(std::lock_guard<std::mutex> & segment_lock) const;
|
||||
|
||||
void setDownloaded(std::lock_guard<std::mutex> & segment_lock);
|
||||
|
||||
bool lastFileSegmentHolder() const;
|
||||
|
||||
/// complete() without any completion state is called from destructor of
|
||||
/// FileSegmentsHolder. complete() might check if the caller of the method
|
||||
/// is the last alive holder of the segment. Therefore, complete() and destruction
|
||||
/// of the file segment pointer must be done under the same cache mutex.
|
||||
void complete(std::lock_guard<std::mutex> & cache_lock);
|
||||
|
||||
void completeImpl(
|
||||
std::lock_guard<std::mutex> & cache_lock,
|
||||
std::lock_guard<std::mutex> & segment_lock, bool allow_non_strict_checking = false);
|
||||
|
||||
static String getCallerIdImpl(bool allow_non_strict_checking = false);
|
||||
|
||||
void resetDownloaderImpl(std::lock_guard<std::mutex> & segment_lock);
|
||||
|
||||
const Range segment_range;
|
||||
|
||||
@ -169,28 +187,7 @@ struct FileSegmentsHolder : private boost::noncopyable
|
||||
explicit FileSegmentsHolder(FileSegments && file_segments_) : file_segments(std::move(file_segments_)) {}
|
||||
FileSegmentsHolder(FileSegmentsHolder && other) : file_segments(std::move(other.file_segments)) {}
|
||||
|
||||
~FileSegmentsHolder()
|
||||
{
|
||||
/// In CacheableReadBufferFromRemoteFS file segment's downloader removes file segments from
|
||||
/// FileSegmentsHolder right after calling file_segment->complete(), so on destruction here
|
||||
/// remain only uncompleted file segments.
|
||||
|
||||
for (auto & segment : file_segments)
|
||||
{
|
||||
try
|
||||
{
|
||||
segment->complete();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
throw;
|
||||
#else
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
~FileSegmentsHolder();
|
||||
|
||||
FileSegments file_segments{};
|
||||
|
||||
|
@ -38,21 +38,7 @@ unsigned getCGroupLimitedCPUCores(unsigned default_cpu_count)
|
||||
quota_count = ceil(static_cast<float>(cgroup_quota) / static_cast<float>(cgroup_period));
|
||||
}
|
||||
|
||||
// Share number (typically a number relative to 1024) (2048 typically expresses 2 CPUs worth of processing)
|
||||
// -1 for no share setup
|
||||
int cgroup_share = read_from("/sys/fs/cgroup/cpu/cpu.shares", -1);
|
||||
// Convert 1024 to no shares setup
|
||||
if (cgroup_share == 1024)
|
||||
cgroup_share = -1;
|
||||
|
||||
# define PER_CPU_SHARES 1024
|
||||
unsigned share_count = default_cpu_count;
|
||||
if (cgroup_share > -1)
|
||||
{
|
||||
share_count = ceil(static_cast<float>(cgroup_share) / static_cast<float>(PER_CPU_SHARES));
|
||||
}
|
||||
|
||||
return std::min(default_cpu_count, std::min(share_count, quota_count));
|
||||
return std::min(default_cpu_count, quota_count);
|
||||
}
|
||||
#endif // OS_LINUX
|
||||
|
||||
@ -91,6 +77,7 @@ unsigned getNumberOfPhysicalCPUCores()
|
||||
cpu_count = std::thread::hardware_concurrency();
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
/// TODO: add a setting for disabling that, similar to UseContainerSupport in java
|
||||
cpu_count = getCGroupLimitedCPUCores(cpu_count);
|
||||
#endif // OS_LINUX
|
||||
return cpu_count;
|
||||
|
@ -67,7 +67,7 @@ void download(DB::FileSegmentPtr file_segment)
|
||||
fs::create_directories(subdir);
|
||||
|
||||
std::string data(size, '0');
|
||||
file_segment->write(data.data(), size);
|
||||
file_segment->write(data.data(), size, file_segment->getDownloadOffset());
|
||||
}
|
||||
|
||||
void prepareAndDownload(DB::FileSegmentPtr file_segment)
|
||||
|
@ -63,7 +63,11 @@ void CachedReadBufferFromRemoteFS::initialize(size_t offset, size_t size)
|
||||
|
||||
SeekableReadBufferPtr CachedReadBufferFromRemoteFS::getCacheReadBuffer(size_t offset) const
|
||||
{
|
||||
return std::make_shared<ReadBufferFromFile>(cache->getPathInLocalCache(cache_key, offset), settings.local_fs_buffer_size);
|
||||
auto path = cache->getPathInLocalCache(cache_key, offset);
|
||||
auto buf = std::make_shared<ReadBufferFromFile>(path, settings.local_fs_buffer_size);
|
||||
if (buf->size() == 0)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Attempt to read from an empty cache file: {}", path);
|
||||
return buf;
|
||||
}
|
||||
|
||||
SeekableReadBufferPtr CachedReadBufferFromRemoteFS::getRemoteFSReadBuffer(FileSegmentPtr & file_segment, ReadType read_type_)
|
||||
@ -96,7 +100,6 @@ SeekableReadBufferPtr CachedReadBufferFromRemoteFS::getRemoteFSReadBuffer(FileSe
|
||||
remote_fs_segment_reader = remote_file_reader_creator();
|
||||
file_segment->setRemoteFileReader(remote_fs_segment_reader);
|
||||
|
||||
///TODO: add check for pending data
|
||||
return remote_fs_segment_reader;
|
||||
}
|
||||
case ReadType::REMOTE_FS_READ_BYPASS_CACHE:
|
||||
@ -119,7 +122,6 @@ SeekableReadBufferPtr CachedReadBufferFromRemoteFS::getReadBufferForFileSegment(
|
||||
{
|
||||
auto range = file_segment->range();
|
||||
|
||||
/// Each wait() call has a timeout of 1 second.
|
||||
size_t wait_download_max_tries = settings.remote_fs_cache_max_wait_sec;
|
||||
size_t wait_download_tries = 0;
|
||||
|
||||
@ -296,17 +298,21 @@ SeekableReadBufferPtr CachedReadBufferFromRemoteFS::getImplementationBuffer(File
|
||||
{
|
||||
case ReadType::CACHED:
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
auto * file_reader = assert_cast<ReadBufferFromFile *>(read_buffer_for_file_segment.get());
|
||||
size_t file_size = file_reader->size();
|
||||
|
||||
if (file_size == 0 || range.left + file_size <= file_offset_of_buffer_end)
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Unexpected state of cache file. Cache file size: {}, cache file offset: {}, "
|
||||
"expected file size to be non-zero and file downloaded size to exceed current file read offset (expected: {} > {})",
|
||||
file_size, range.left, range.left + file_size, file_offset_of_buffer_end);
|
||||
#endif
|
||||
|
||||
size_t seek_offset = file_offset_of_buffer_end - range.left;
|
||||
read_buffer_for_file_segment->seek(seek_offset, SEEK_SET);
|
||||
|
||||
auto * file_reader = assert_cast<ReadBufferFromFile *>(read_buffer_for_file_segment.get());
|
||||
size_t file_size = file_reader->size();
|
||||
auto state = file_segment->state();
|
||||
|
||||
LOG_TEST(log, "Cache file: {}. Cached seek to: {}, file size: {}, file segment state: {}, download offset: {}",
|
||||
file_reader->getFileName(), seek_offset, file_size, state, file_segment->getDownloadOffset());
|
||||
|
||||
assert(file_size > 0);
|
||||
break;
|
||||
}
|
||||
case ReadType::REMOTE_FS_READ_BYPASS_CACHE:
|
||||
@ -384,6 +390,7 @@ void CachedReadBufferFromRemoteFS::predownload(FileSegmentPtr & file_segment)
|
||||
LOG_TEST(log, "Bytes to predownload: {}, caller_id: {}", bytes_to_predownload, FileSegment::getCallerId());
|
||||
|
||||
assert(implementation_buffer->getFileOffsetOfBufferEnd() == file_segment->getDownloadOffset());
|
||||
size_t current_offset = file_segment->getDownloadOffset();
|
||||
|
||||
while (true)
|
||||
{
|
||||
@ -423,7 +430,11 @@ void CachedReadBufferFromRemoteFS::predownload(FileSegmentPtr & file_segment)
|
||||
{
|
||||
LOG_TEST(log, "Left to predownload: {}, buffer size: {}", bytes_to_predownload, implementation_buffer->buffer().size());
|
||||
|
||||
file_segment->write(implementation_buffer->buffer().begin(), current_predownload_size);
|
||||
assert(file_segment->getDownloadOffset() == static_cast<size_t>(implementation_buffer->getPosition()));
|
||||
|
||||
file_segment->write(implementation_buffer->buffer().begin(), current_predownload_size, current_offset);
|
||||
|
||||
current_offset += current_predownload_size;
|
||||
|
||||
bytes_to_predownload -= current_predownload_size;
|
||||
implementation_buffer->position() += current_predownload_size;
|
||||
@ -537,13 +548,15 @@ bool CachedReadBufferFromRemoteFS::nextImpl()
|
||||
}
|
||||
catch (Exception & e)
|
||||
{
|
||||
e.addMessage("Cache info: {}", getInfoForLog());
|
||||
e.addMessage("Cache info: {}", nextimpl_step_log_info);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
{
|
||||
last_caller_id = FileSegment::getCallerId();
|
||||
|
||||
if (IFileCache::shouldBypassCache())
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR, "Using cache when not allowed");
|
||||
|
||||
@ -554,6 +567,9 @@ bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
return false;
|
||||
|
||||
SCOPE_EXIT({
|
||||
/// Save state of current file segment before it is completed.
|
||||
nextimpl_step_log_info = getInfoForLog();
|
||||
|
||||
if (current_file_segment_it == file_segments_holder->file_segments.end())
|
||||
return;
|
||||
|
||||
@ -623,6 +639,18 @@ bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
|
||||
if (!result)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (auto * cache_file_reader = typeid_cast<ReadBufferFromFile *>(implementation_buffer.get()))
|
||||
{
|
||||
auto cache_file_size = cache_file_reader->size();
|
||||
if (cache_file_size == 0)
|
||||
throw Exception(
|
||||
ErrorCodes::LOGICAL_ERROR,
|
||||
"Attempt to read from an empty cache file: {} (just before actual read)",
|
||||
cache_file_size);
|
||||
}
|
||||
#endif
|
||||
|
||||
result = implementation_buffer->next();
|
||||
size = implementation_buffer->buffer().size();
|
||||
}
|
||||
@ -635,7 +663,12 @@ bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
|
||||
if (file_segment->reserve(size))
|
||||
{
|
||||
file_segment->write(needed_to_predownload ? implementation_buffer->position() : implementation_buffer->buffer().begin(), size);
|
||||
assert(file_segment->getDownloadOffset() == static_cast<size_t>(implementation_buffer->getPosition()));
|
||||
|
||||
file_segment->write(needed_to_predownload ? implementation_buffer->position() : implementation_buffer->buffer().begin(), size, file_offset_of_buffer_end);
|
||||
|
||||
assert(file_segment->getDownloadOffset() <= file_segment->range().right + 1);
|
||||
assert(std::next(current_file_segment_it) == file_segments_holder->file_segments.end() || file_segment->getDownloadOffset() == implementation_buffer->getFileOffsetOfBufferEnd());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -665,10 +698,15 @@ bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
}
|
||||
}
|
||||
|
||||
/// - If last file segment was read from remote fs, then we read up to segment->range().right, but
|
||||
/// the requested right boundary could be segment->range().left < requested_right_boundary < segment->range().right.
|
||||
/// Therefore need to resize to a smaller size. And resize must be done after write into cache.
|
||||
/// - If last file segment was read from local fs, then we could read more than file_segemnt->range().right, so resize is also needed.
|
||||
if (std::next(current_file_segment_it) == file_segments_holder->file_segments.end())
|
||||
{
|
||||
size_t remaining_size_to_read = std::min(current_read_range.right, read_until_position - 1) - file_offset_of_buffer_end + 1;
|
||||
size = std::min(size, remaining_size_to_read);
|
||||
assert(implementation_buffer->buffer().size() >= nextimpl_working_buffer_offset + size);
|
||||
implementation_buffer->buffer().resize(nextimpl_working_buffer_offset + size);
|
||||
}
|
||||
|
||||
@ -692,9 +730,16 @@ bool CachedReadBufferFromRemoteFS::nextImplStep()
|
||||
read_until_position, first_offset, file_segments_holder->toString());
|
||||
|
||||
if (size == 0 && file_offset_of_buffer_end < read_until_position)
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Having zero bytes, but range is not finished: file offset: {}, reading until: {}",
|
||||
file_offset_of_buffer_end, read_until_position);
|
||||
{
|
||||
std::optional<size_t> cache_file_size;
|
||||
if (auto * cache_file_reader = assert_cast<ReadBufferFromFile *>(implementation_buffer.get()))
|
||||
cache_file_size = cache_file_reader->size();
|
||||
|
||||
throw Exception(ErrorCodes::LOGICAL_ERROR,
|
||||
"Having zero bytes, but range is not finished: file offset: {}, reading until: {}, read type: {}, cache file size: {}",
|
||||
file_offset_of_buffer_end, read_until_position, toString(read_type), cache_file_size ? std::to_string(*cache_file_size) : "None");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -757,12 +802,24 @@ std::optional<size_t> CachedReadBufferFromRemoteFS::getLastNonDownloadedOffset()
|
||||
|
||||
String CachedReadBufferFromRemoteFS::getInfoForLog()
|
||||
{
|
||||
return fmt::format("Buffer path: {}, hash key: {}, file_offset_of_buffer_end: {}, internal buffer remaining read range: {}, file segment info: {}",
|
||||
remote_fs_object_path, getHexUIntLowercase(cache_key), file_offset_of_buffer_end,
|
||||
(implementation_buffer ?
|
||||
std::to_string(implementation_buffer->getRemainingReadRange().left) + '-' + (implementation_buffer->getRemainingReadRange().right ? std::to_string(*implementation_buffer->getRemainingReadRange().right) : "None")
|
||||
: "None"),
|
||||
(current_file_segment_it == file_segments_holder->file_segments.end() ? "None" : (*current_file_segment_it)->getInfoForLog()));
|
||||
auto implementation_buffer_read_range_str =
|
||||
implementation_buffer ?
|
||||
std::to_string(implementation_buffer->getRemainingReadRange().left)
|
||||
+ '-'
|
||||
+ (implementation_buffer->getRemainingReadRange().right ? std::to_string(*implementation_buffer->getRemainingReadRange().right) : "None")
|
||||
: "None";
|
||||
|
||||
auto current_file_segment_info = current_file_segment_it == file_segments_holder->file_segments.end() ? "None" : (*current_file_segment_it)->getInfoForLog();
|
||||
|
||||
return fmt::format("Buffer path: {}, hash key: {}, file_offset_of_buffer_end: {}, internal buffer remaining read range: {}, "
|
||||
"read_type: {}, last caller: {}, file segment info: {}",
|
||||
remote_fs_object_path,
|
||||
getHexUIntLowercase(cache_key),
|
||||
file_offset_of_buffer_end,
|
||||
implementation_buffer_read_range_str,
|
||||
toString(read_type),
|
||||
last_caller_id,
|
||||
current_file_segment_info);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -98,7 +98,10 @@ private:
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
size_t first_offset = 0;
|
||||
String nextimpl_step_log_info;
|
||||
String last_caller_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -68,16 +68,28 @@ std::future<IAsynchronousReader::Result> ThreadPoolRemoteFSReader::submit(Reques
|
||||
auto * remote_fs_fd = assert_cast<RemoteFSFileDescriptor *>(request.descriptor.get());
|
||||
|
||||
Stopwatch watch(CLOCK_MONOTONIC);
|
||||
auto [bytes_read, offset] = remote_fs_fd->readInto(request.buf, request.size, request.offset, request.ignore);
|
||||
|
||||
ReadBufferFromRemoteFSGather::ReadResult result;
|
||||
try
|
||||
{
|
||||
result = remote_fs_fd->readInto(request.buf, request.size, request.offset, request.ignore);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (running_group)
|
||||
CurrentThread::detachQuery();
|
||||
throw;
|
||||
}
|
||||
|
||||
watch.stop();
|
||||
|
||||
ProfileEvents::increment(ProfileEvents::RemoteFSReadMicroseconds, watch.elapsedMicroseconds());
|
||||
ProfileEvents::increment(ProfileEvents::RemoteFSReadBytes, bytes_read);
|
||||
|
||||
if (running_group)
|
||||
thread_status.detachQuery();
|
||||
CurrentThread::detachQuery();
|
||||
|
||||
return Result{ .size = bytes_read, .offset = offset };
|
||||
ProfileEvents::increment(ProfileEvents::RemoteFSReadMicroseconds, watch.elapsedMicroseconds());
|
||||
ProfileEvents::increment(ProfileEvents::RemoteFSReadBytes, result.offset ? result.size - result.offset : result.size);
|
||||
|
||||
return Result{ .size = result.size, .offset = result.offset };
|
||||
});
|
||||
|
||||
auto future = task->get_future();
|
||||
|
@ -69,6 +69,7 @@ public:
|
||||
/// All below are parameters related to initial query.
|
||||
|
||||
Interface interface = Interface::TCP;
|
||||
bool is_secure = false;
|
||||
|
||||
/// For tcp
|
||||
String os_user;
|
||||
|
@ -86,6 +86,7 @@ NamesAndTypesList QueryLogElement::getNamesAndTypes()
|
||||
{"initial_query_start_time", std::make_shared<DataTypeDateTime>()},
|
||||
{"initial_query_start_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
||||
{"interface", std::make_shared<DataTypeUInt8>()},
|
||||
{"is_secure", std::make_shared<DataTypeUInt8>()},
|
||||
{"os_user", std::make_shared<DataTypeString>()},
|
||||
{"client_hostname", std::make_shared<DataTypeString>()},
|
||||
{"client_name", std::make_shared<DataTypeString>()},
|
||||
@ -279,6 +280,7 @@ void QueryLogElement::appendClientInfo(const ClientInfo & client_info, MutableCo
|
||||
columns[i++]->insert(client_info.initial_query_start_time_microseconds);
|
||||
|
||||
columns[i++]->insert(UInt64(client_info.interface));
|
||||
columns[i++]->insert(static_cast<UInt64>(client_info.is_secure));
|
||||
|
||||
columns[i++]->insert(client_info.os_user);
|
||||
columns[i++]->insert(client_info.client_hostname);
|
||||
|
@ -56,6 +56,7 @@ NamesAndTypesList QueryThreadLogElement::getNamesAndTypes()
|
||||
{"initial_query_start_time", std::make_shared<DataTypeDateTime>()},
|
||||
{"initial_query_start_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
||||
{"interface", std::make_shared<DataTypeUInt8>()},
|
||||
{"is_secure", std::make_shared<DataTypeUInt8>()},
|
||||
{"os_user", std::make_shared<DataTypeString>()},
|
||||
{"client_hostname", std::make_shared<DataTypeString>()},
|
||||
{"client_name", std::make_shared<DataTypeString>()},
|
||||
|
@ -243,7 +243,7 @@ void Session::shutdownNamedSessions()
|
||||
NamedSessionsStorage::instance().shutdown();
|
||||
}
|
||||
|
||||
Session::Session(const ContextPtr & global_context_, ClientInfo::Interface interface_)
|
||||
Session::Session(const ContextPtr & global_context_, ClientInfo::Interface interface_, bool is_secure)
|
||||
: auth_id(UUIDHelpers::generateV4()),
|
||||
global_context(global_context_),
|
||||
interface(interface_),
|
||||
@ -251,6 +251,7 @@ Session::Session(const ContextPtr & global_context_, ClientInfo::Interface inter
|
||||
{
|
||||
prepared_client_info.emplace();
|
||||
prepared_client_info->interface = interface_;
|
||||
prepared_client_info->is_secure = is_secure;
|
||||
}
|
||||
|
||||
Session::~Session()
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
/// Stops using named sessions. The method must be called at the server shutdown.
|
||||
static void shutdownNamedSessions();
|
||||
|
||||
Session(const ContextPtr & global_context_, ClientInfo::Interface interface_);
|
||||
Session(const ContextPtr & global_context_, ClientInfo::Interface interface_, bool is_secure = false);
|
||||
~Session();
|
||||
|
||||
Session(const Session &&) = delete;
|
||||
|
@ -505,32 +505,34 @@ namespace
|
||||
|
||||
bool parseExtract(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
ASTPtr expr;
|
||||
|
||||
IParser::Pos begin = pos;
|
||||
IntervalKind interval_kind;
|
||||
if (!parseIntervalKind(pos, expected, interval_kind))
|
||||
{
|
||||
ASTPtr expr_list;
|
||||
if (!ParserExpressionList(false, false).parse(pos, expr_list, expected))
|
||||
return false;
|
||||
|
||||
auto res = std::make_shared<ASTFunction>();
|
||||
res->name = "extract";
|
||||
res->arguments = expr_list;
|
||||
res->children.push_back(res->arguments);
|
||||
node = std::move(res);
|
||||
return true;
|
||||
if (parseIntervalKind(pos, expected, interval_kind))
|
||||
{
|
||||
ASTPtr expr;
|
||||
|
||||
ParserKeyword s_from("FROM");
|
||||
ParserExpression elem_parser;
|
||||
|
||||
if (s_from.ignore(pos, expected) && elem_parser.parse(pos, expr, expected))
|
||||
{
|
||||
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ParserKeyword s_from("FROM");
|
||||
if (!s_from.ignore(pos, expected))
|
||||
pos = begin;
|
||||
|
||||
ASTPtr expr_list;
|
||||
if (!ParserExpressionList(false, false).parse(pos, expr_list, expected))
|
||||
return false;
|
||||
|
||||
ParserExpression elem_parser;
|
||||
if (!elem_parser.parse(pos, expr, expected))
|
||||
return false;
|
||||
|
||||
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
||||
auto res = std::make_shared<ASTFunction>();
|
||||
res->name = "extract";
|
||||
res->arguments = expr_list;
|
||||
res->children.push_back(res->arguments);
|
||||
node = std::move(res);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ struct ColumnMapping
|
||||
OptionalIndexes column_indexes_for_input_fields;
|
||||
|
||||
/// The list of column indexes that are not presented in input data.
|
||||
std::vector<UInt8> not_presented_columns;
|
||||
std::vector<size_t> not_presented_columns;
|
||||
|
||||
/// The list of column names in input data. Needed for better exception messages.
|
||||
std::vector<String> names_of_columns;
|
||||
|
@ -98,8 +98,6 @@ void RowInputFormatWithNamesAndTypes::readPrefix()
|
||||
/// Skip prefix before names and types.
|
||||
format_reader->skipPrefixBeforeHeader();
|
||||
|
||||
/// This is a bit of abstraction leakage, but we need it in parallel parsing:
|
||||
/// we check if this InputFormat is working with the "real" beginning of the data.
|
||||
if (with_names)
|
||||
{
|
||||
if (format_settings.with_names_use_header)
|
||||
|
@ -759,44 +759,6 @@ void Pipe::setSinks(const Pipe::ProcessorGetterWithStreamKind & getter)
|
||||
header.clear();
|
||||
}
|
||||
|
||||
void Pipe::setOutputFormat(ProcessorPtr output)
|
||||
{
|
||||
if (output_ports.empty())
|
||||
throw Exception("Cannot set output format to empty Pipe.", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
if (output_ports.size() != 1)
|
||||
throw Exception("Cannot set output format to Pipe because single output port is expected, "
|
||||
"but it has " + std::to_string(output_ports.size()) + " ports", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
auto * format = dynamic_cast<IOutputFormat * >(output.get());
|
||||
|
||||
if (!format)
|
||||
throw Exception("IOutputFormat processor expected for QueryPipelineBuilder::setOutputFormat.",
|
||||
ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
auto & main = format->getPort(IOutputFormat::PortKind::Main);
|
||||
auto & totals = format->getPort(IOutputFormat::PortKind::Totals);
|
||||
auto & extremes = format->getPort(IOutputFormat::PortKind::Extremes);
|
||||
|
||||
if (!totals_port)
|
||||
addTotalsSource(std::make_shared<NullSource>(totals.getHeader()));
|
||||
|
||||
if (!extremes_port)
|
||||
addExtremesSource(std::make_shared<NullSource>(extremes.getHeader()));
|
||||
|
||||
if (collected_processors)
|
||||
collected_processors->emplace_back(output);
|
||||
|
||||
processors.emplace_back(std::move(output));
|
||||
|
||||
connect(*output_ports.front(), main);
|
||||
connect(*totals_port, totals);
|
||||
connect(*extremes_port, extremes);
|
||||
|
||||
output_ports.clear();
|
||||
header.clear();
|
||||
}
|
||||
|
||||
void Pipe::transform(const Transformer & transformer)
|
||||
{
|
||||
if (output_ports.empty())
|
||||
|
@ -141,7 +141,6 @@ private:
|
||||
bool isCompleted() const { return !empty() && output_ports.empty(); }
|
||||
static Pipe unitePipes(Pipes pipes, Processors * collected_processors, bool allow_empty_header);
|
||||
void setSinks(const Pipe::ProcessorGetterWithStreamKind & getter);
|
||||
void setOutputFormat(ProcessorPtr output);
|
||||
|
||||
friend class QueryPipelineBuilder;
|
||||
friend class QueryPipeline;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <Processors/Transforms/ExpressionTransform.h>
|
||||
#include <Processors/Transforms/MergingAggregatedMemoryEfficientTransform.h>
|
||||
#include <Processors/Transforms/JoiningTransform.h>
|
||||
#include <Processors/Formats/IOutputFormat.h>
|
||||
#include <Processors/Executors/PipelineExecutor.h>
|
||||
#include <Processors/Transforms/PartialSortingTransform.h>
|
||||
#include <Processors/Sources/SourceFromSingleChunk.h>
|
||||
@ -247,21 +246,6 @@ void QueryPipelineBuilder::addExtremesTransform()
|
||||
pipe.addTransform(std::move(transform), nullptr, port);
|
||||
}
|
||||
|
||||
void QueryPipelineBuilder::setOutputFormat(ProcessorPtr output)
|
||||
{
|
||||
checkInitializedAndNotCompleted();
|
||||
|
||||
if (output_format)
|
||||
throw Exception("QueryPipeline already has output.", ErrorCodes::LOGICAL_ERROR);
|
||||
|
||||
resize(1);
|
||||
|
||||
output_format = dynamic_cast<IOutputFormat * >(output.get());
|
||||
pipe.setOutputFormat(std::move(output));
|
||||
|
||||
initRowsBeforeLimit();
|
||||
}
|
||||
|
||||
QueryPipelineBuilder QueryPipelineBuilder::unitePipelines(
|
||||
std::vector<std::unique_ptr<QueryPipelineBuilder>> pipelines,
|
||||
size_t max_threads_limit,
|
||||
@ -461,93 +445,6 @@ void QueryPipelineBuilder::setProcessListElement(QueryStatus * elem)
|
||||
}
|
||||
}
|
||||
|
||||
void QueryPipelineBuilder::initRowsBeforeLimit()
|
||||
{
|
||||
RowsBeforeLimitCounterPtr rows_before_limit_at_least;
|
||||
|
||||
/// TODO: add setRowsBeforeLimitCounter as virtual method to IProcessor.
|
||||
std::vector<LimitTransform *> limits;
|
||||
std::vector<RemoteSource *> remote_sources;
|
||||
|
||||
std::unordered_set<IProcessor *> visited;
|
||||
|
||||
struct QueuedEntry
|
||||
{
|
||||
IProcessor * processor;
|
||||
bool visited_limit;
|
||||
};
|
||||
|
||||
std::queue<QueuedEntry> queue;
|
||||
|
||||
queue.push({ output_format, false });
|
||||
visited.emplace(output_format);
|
||||
|
||||
while (!queue.empty())
|
||||
{
|
||||
auto * processor = queue.front().processor;
|
||||
auto visited_limit = queue.front().visited_limit;
|
||||
queue.pop();
|
||||
|
||||
if (!visited_limit)
|
||||
{
|
||||
if (auto * limit = typeid_cast<LimitTransform *>(processor))
|
||||
{
|
||||
visited_limit = true;
|
||||
limits.emplace_back(limit);
|
||||
}
|
||||
|
||||
if (auto * source = typeid_cast<RemoteSource *>(processor))
|
||||
remote_sources.emplace_back(source);
|
||||
}
|
||||
else if (auto * sorting = typeid_cast<PartialSortingTransform *>(processor))
|
||||
{
|
||||
if (!rows_before_limit_at_least)
|
||||
rows_before_limit_at_least = std::make_shared<RowsBeforeLimitCounter>();
|
||||
|
||||
sorting->setRowsBeforeLimitCounter(rows_before_limit_at_least);
|
||||
|
||||
/// Don't go to children. Take rows_before_limit from last PartialSortingTransform.
|
||||
continue;
|
||||
}
|
||||
|
||||
/// Skip totals and extremes port for output format.
|
||||
if (auto * format = dynamic_cast<IOutputFormat *>(processor))
|
||||
{
|
||||
auto * child_processor = &format->getPort(IOutputFormat::PortKind::Main).getOutputPort().getProcessor();
|
||||
if (visited.emplace(child_processor).second)
|
||||
queue.push({ child_processor, visited_limit });
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto & child_port : processor->getInputs())
|
||||
{
|
||||
auto * child_processor = &child_port.getOutputPort().getProcessor();
|
||||
if (visited.emplace(child_processor).second)
|
||||
queue.push({ child_processor, visited_limit });
|
||||
}
|
||||
}
|
||||
|
||||
if (!rows_before_limit_at_least && (!limits.empty() || !remote_sources.empty()))
|
||||
{
|
||||
rows_before_limit_at_least = std::make_shared<RowsBeforeLimitCounter>();
|
||||
|
||||
for (auto & limit : limits)
|
||||
limit->setRowsBeforeLimitCounter(rows_before_limit_at_least);
|
||||
|
||||
for (auto & source : remote_sources)
|
||||
source->setRowsBeforeLimitCounter(rows_before_limit_at_least);
|
||||
}
|
||||
|
||||
/// If there is a limit, then enable rows_before_limit_at_least
|
||||
/// It is needed when zero rows is read, but we still want rows_before_limit_at_least in result.
|
||||
if (!limits.empty())
|
||||
rows_before_limit_at_least->add(0);
|
||||
|
||||
if (rows_before_limit_at_least)
|
||||
output_format->setRowsBeforeLimitCounter(rows_before_limit_at_least);
|
||||
}
|
||||
|
||||
PipelineExecutorPtr QueryPipelineBuilder::execute()
|
||||
{
|
||||
if (!isCompleted())
|
||||
|
@ -10,8 +10,6 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
class IOutputFormat;
|
||||
|
||||
class QueryPipelineProcessorsCollector;
|
||||
|
||||
struct AggregatingTransformParams;
|
||||
@ -71,10 +69,6 @@ public:
|
||||
void addTotalsHavingTransform(ProcessorPtr transform);
|
||||
/// Add transform which calculates extremes. This transform adds extremes port and doesn't change inputs number.
|
||||
void addExtremesTransform();
|
||||
/// Resize pipeline to single output and add IOutputFormat. Pipeline will be completed after this transformation.
|
||||
void setOutputFormat(ProcessorPtr output);
|
||||
/// Get current OutputFormat.
|
||||
IOutputFormat * getOutputFormat() const { return output_format; }
|
||||
/// Sink is a processor with single input port and no output ports. Creates sink for each output port.
|
||||
/// Pipeline will be completed after this transformation.
|
||||
void setSinks(const Pipe::ProcessorGetterWithStreamKind & getter);
|
||||
@ -163,7 +157,6 @@ public:
|
||||
private:
|
||||
|
||||
Pipe pipe;
|
||||
IOutputFormat * output_format = nullptr;
|
||||
|
||||
/// Limit on the number of threads. Zero means no limit.
|
||||
/// Sometimes, more streams are created then the number of threads for more optimal execution.
|
||||
@ -174,8 +167,6 @@ private:
|
||||
void checkInitialized();
|
||||
void checkInitializedAndNotCompleted();
|
||||
|
||||
void initRowsBeforeLimit();
|
||||
|
||||
void setCollectedProcessors(Processors * processors);
|
||||
|
||||
friend class QueryPipelineProcessorsCollector;
|
||||
|
@ -922,7 +922,7 @@ void HTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse
|
||||
setThreadName("HTTPHandler");
|
||||
ThreadStatus thread_status;
|
||||
|
||||
session = std::make_unique<Session>(server.context(), ClientInfo::Interface::HTTP);
|
||||
session = std::make_unique<Session>(server.context(), ClientInfo::Interface::HTTP, request.isSecure());
|
||||
SCOPE_EXIT({ session.reset(); });
|
||||
std::optional<CurrentThread::QueryScope> query_scope;
|
||||
|
||||
|
@ -110,7 +110,7 @@ void TCPHandler::runImpl()
|
||||
setThreadName("TCPHandler");
|
||||
ThreadStatus thread_status;
|
||||
|
||||
session = std::make_unique<Session>(server.context(), ClientInfo::Interface::TCP);
|
||||
session = std::make_unique<Session>(server.context(), ClientInfo::Interface::TCP, socket().secure());
|
||||
extractConnectionSettingsFromContext(server.context());
|
||||
|
||||
socket().setReceiveTimeout(receive_timeout);
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <Storages/HDFS/ReadBufferFromHDFS.h>
|
||||
#include <Storages/HDFS/WriteBufferFromHDFS.h>
|
||||
#include <Storages/PartitionedSink.h>
|
||||
#include <Storages/getVirtualsForStorage.h>
|
||||
|
||||
#include <Formats/ReadSchemaUtils.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
@ -164,6 +165,13 @@ StorageHDFS::StorageHDFS(
|
||||
storage_metadata.setConstraints(constraints_);
|
||||
storage_metadata.setComment(comment);
|
||||
setInMemoryMetadata(storage_metadata);
|
||||
|
||||
auto default_virtuals = NamesAndTypesList{
|
||||
{"_path", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
||||
{"_file", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())}};
|
||||
|
||||
auto columns = storage_metadata.getSampleBlock().getNamesAndTypesList();
|
||||
virtual_columns = getVirtualsForStorage(columns, default_virtuals);
|
||||
}
|
||||
|
||||
ColumnsDescription StorageHDFS::getTableStructureFromData(
|
||||
@ -273,36 +281,6 @@ private:
|
||||
Strings::iterator uris_iter;
|
||||
};
|
||||
|
||||
Block HDFSSource::getHeader(const StorageMetadataPtr & metadata_snapshot, bool need_path_column, bool need_file_column)
|
||||
{
|
||||
auto header = metadata_snapshot->getSampleBlock();
|
||||
/// Note: AddingDefaultsBlockInputStream doesn't change header.
|
||||
if (need_path_column)
|
||||
header.insert(
|
||||
{DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumn(),
|
||||
std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()),
|
||||
"_path"});
|
||||
if (need_file_column)
|
||||
header.insert(
|
||||
{DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumn(),
|
||||
std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()),
|
||||
"_file"});
|
||||
return header;
|
||||
}
|
||||
|
||||
Block HDFSSource::getBlockForSource(
|
||||
const StorageHDFSPtr & storage,
|
||||
const StorageSnapshotPtr & storage_snapshot,
|
||||
const ColumnsDescription & columns_description,
|
||||
bool need_path_column,
|
||||
bool need_file_column)
|
||||
{
|
||||
if (storage->isColumnOriented())
|
||||
return storage_snapshot->getSampleBlockForColumns(columns_description.getNamesOfPhysical());
|
||||
else
|
||||
return getHeader(storage_snapshot->metadata, need_path_column, need_file_column);
|
||||
}
|
||||
|
||||
HDFSSource::DisclosedGlobIterator::DisclosedGlobIterator(ContextPtr context_, const String & uri)
|
||||
: pimpl(std::make_shared<HDFSSource::DisclosedGlobIterator::Impl>(context_, uri)) {}
|
||||
|
||||
@ -321,22 +299,28 @@ String HDFSSource::URISIterator::next()
|
||||
return pimpl->next();
|
||||
}
|
||||
|
||||
Block HDFSSource::getHeader(Block sample_block, const std::vector<NameAndTypePair> & requested_virtual_columns)
|
||||
{
|
||||
for (const auto & virtual_column : requested_virtual_columns)
|
||||
sample_block.insert({virtual_column.type->createColumn(), virtual_column.type, virtual_column.name});
|
||||
|
||||
return sample_block;
|
||||
}
|
||||
|
||||
HDFSSource::HDFSSource(
|
||||
StorageHDFSPtr storage_,
|
||||
const StorageSnapshotPtr & storage_snapshot_,
|
||||
const Block & block_for_format_,
|
||||
const std::vector<NameAndTypePair> & requested_virtual_columns_,
|
||||
ContextPtr context_,
|
||||
UInt64 max_block_size_,
|
||||
bool need_path_column_,
|
||||
bool need_file_column_,
|
||||
std::shared_ptr<IteratorWrapper> file_iterator_,
|
||||
ColumnsDescription columns_description_)
|
||||
: SourceWithProgress(getBlockForSource(storage_, storage_snapshot_, columns_description_, need_path_column_, need_file_column_))
|
||||
: SourceWithProgress(getHeader(block_for_format_, requested_virtual_columns_))
|
||||
, WithContext(context_)
|
||||
, storage(std::move(storage_))
|
||||
, storage_snapshot(storage_snapshot_)
|
||||
, block_for_format(block_for_format_)
|
||||
, requested_virtual_columns(requested_virtual_columns_)
|
||||
, max_block_size(max_block_size_)
|
||||
, need_path_column(need_path_column_)
|
||||
, need_file_column(need_file_column_)
|
||||
, file_iterator(file_iterator_)
|
||||
, columns_description(std::move(columns_description_))
|
||||
{
|
||||
@ -361,14 +345,7 @@ bool HDFSSource::initialize()
|
||||
auto compression = chooseCompressionMethod(path_from_uri, storage->compression_method);
|
||||
read_buf = wrapReadBufferWithCompressionMethod(std::make_unique<ReadBufferFromHDFS>(uri_without_path, path_from_uri, getContext()->getGlobalContext()->getConfigRef()), compression);
|
||||
|
||||
auto get_block_for_format = [&]() -> Block
|
||||
{
|
||||
if (storage->isColumnOriented())
|
||||
return storage_snapshot->getSampleBlockForColumns(columns_description.getNamesOfPhysical());
|
||||
return storage_snapshot->metadata->getSampleBlock();
|
||||
};
|
||||
|
||||
auto input_format = getContext()->getInputFormat(storage->format_name, *read_buf, get_block_for_format(), max_block_size);
|
||||
auto input_format = getContext()->getInputFormat(storage->format_name, *read_buf, block_for_format, max_block_size);
|
||||
|
||||
QueryPipelineBuilder builder;
|
||||
builder.init(Pipe(input_format));
|
||||
@ -402,20 +379,21 @@ Chunk HDFSSource::generate()
|
||||
Columns columns = chunk.getColumns();
|
||||
UInt64 num_rows = chunk.getNumRows();
|
||||
|
||||
/// Enrich with virtual columns.
|
||||
if (need_path_column)
|
||||
for (const auto & virtual_column : requested_virtual_columns)
|
||||
{
|
||||
auto column = DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumnConst(num_rows, current_path);
|
||||
columns.push_back(column->convertToFullColumnIfConst());
|
||||
}
|
||||
if (virtual_column.name == "_path")
|
||||
{
|
||||
auto column = DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumnConst(num_rows, current_path);
|
||||
columns.push_back(column->convertToFullColumnIfConst());
|
||||
}
|
||||
else if (virtual_column.name == "_file")
|
||||
{
|
||||
size_t last_slash_pos = current_path.find_last_of('/');
|
||||
auto file_name = current_path.substr(last_slash_pos + 1);
|
||||
|
||||
if (need_file_column)
|
||||
{
|
||||
size_t last_slash_pos = current_path.find_last_of('/');
|
||||
auto file_name = current_path.substr(last_slash_pos + 1);
|
||||
|
||||
auto column = DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumnConst(num_rows, std::move(file_name));
|
||||
columns.push_back(column->convertToFullColumnIfConst());
|
||||
auto column = DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumnConst(num_rows, std::move(file_name));
|
||||
columns.push_back(column->convertToFullColumnIfConst());
|
||||
}
|
||||
}
|
||||
|
||||
return Chunk(std::move(columns), num_rows);
|
||||
@ -526,17 +504,6 @@ Pipe StorageHDFS::read(
|
||||
size_t max_block_size,
|
||||
unsigned num_streams)
|
||||
{
|
||||
bool need_path_column = false;
|
||||
bool need_file_column = false;
|
||||
|
||||
for (const auto & column : column_names)
|
||||
{
|
||||
if (column == "_path")
|
||||
need_path_column = true;
|
||||
if (column == "_file")
|
||||
need_file_column = true;
|
||||
}
|
||||
|
||||
std::shared_ptr<HDFSSource::IteratorWrapper> iterator_wrapper{nullptr};
|
||||
if (distributed_processing)
|
||||
{
|
||||
@ -563,27 +530,51 @@ Pipe StorageHDFS::read(
|
||||
});
|
||||
}
|
||||
|
||||
std::unordered_set<String> column_names_set(column_names.begin(), column_names.end());
|
||||
std::vector<NameAndTypePair> requested_virtual_columns;
|
||||
|
||||
for (const auto & virtual_column : getVirtuals())
|
||||
{
|
||||
if (column_names_set.contains(virtual_column.name))
|
||||
requested_virtual_columns.push_back(virtual_column);
|
||||
}
|
||||
|
||||
ColumnsDescription columns_description;
|
||||
Block block_for_format;
|
||||
if (isColumnOriented())
|
||||
{
|
||||
auto fetch_columns = column_names;
|
||||
const auto & virtuals = getVirtuals();
|
||||
std::erase_if(
|
||||
fetch_columns,
|
||||
[&](const String & col)
|
||||
{ return std::any_of(virtuals.begin(), virtuals.end(), [&](const NameAndTypePair & virtual_col){ return col == virtual_col.name; }); });
|
||||
|
||||
if (fetch_columns.empty())
|
||||
fetch_columns.push_back(ExpressionActions::getSmallestColumn(storage_snapshot->metadata->getColumns().getAllPhysical()));
|
||||
|
||||
columns_description = ColumnsDescription{
|
||||
storage_snapshot->getSampleBlockForColumns(fetch_columns).getNamesAndTypesList()};
|
||||
block_for_format = storage_snapshot->getSampleBlockForColumns(columns_description.getNamesOfPhysical());
|
||||
}
|
||||
else
|
||||
{
|
||||
columns_description = storage_snapshot->metadata->getColumns();
|
||||
block_for_format = storage_snapshot->metadata->getSampleBlock();
|
||||
}
|
||||
|
||||
Pipes pipes;
|
||||
auto this_ptr = std::static_pointer_cast<StorageHDFS>(shared_from_this());
|
||||
for (size_t i = 0; i < num_streams; ++i)
|
||||
{
|
||||
const auto get_columns_for_format = [&]() -> ColumnsDescription
|
||||
{
|
||||
if (isColumnOriented())
|
||||
return ColumnsDescription{storage_snapshot->getSampleBlockForColumns(column_names).getNamesAndTypesList()};
|
||||
else
|
||||
return storage_snapshot->metadata->getColumns();
|
||||
};
|
||||
|
||||
pipes.emplace_back(std::make_shared<HDFSSource>(
|
||||
this_ptr,
|
||||
storage_snapshot,
|
||||
block_for_format,
|
||||
requested_virtual_columns,
|
||||
context_,
|
||||
max_block_size,
|
||||
need_path_column,
|
||||
need_file_column,
|
||||
iterator_wrapper,
|
||||
get_columns_for_format()));
|
||||
columns_description));
|
||||
}
|
||||
return Pipe::unitePipes(std::move(pipes));
|
||||
}
|
||||
@ -715,9 +706,7 @@ void registerStorageHDFS(StorageFactory & factory)
|
||||
|
||||
NamesAndTypesList StorageHDFS::getVirtuals() const
|
||||
{
|
||||
return NamesAndTypesList{
|
||||
{"_path", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
||||
{"_file", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())}};
|
||||
return virtual_columns;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ private:
|
||||
const bool distributed_processing;
|
||||
ASTPtr partition_by;
|
||||
bool is_path_with_globs;
|
||||
NamesAndTypesList virtual_columns;
|
||||
|
||||
Poco::Logger * log = &Poco::Logger::get("StorageHDFS");
|
||||
};
|
||||
@ -110,25 +111,14 @@ public:
|
||||
using IteratorWrapper = std::function<String()>;
|
||||
using StorageHDFSPtr = std::shared_ptr<StorageHDFS>;
|
||||
|
||||
static Block getHeader(
|
||||
const StorageMetadataPtr & metadata_snapshot,
|
||||
bool need_path_column,
|
||||
bool need_file_column);
|
||||
|
||||
static Block getBlockForSource(
|
||||
const StorageHDFSPtr & storage,
|
||||
const StorageSnapshotPtr & storage_snapshot_,
|
||||
const ColumnsDescription & columns_description,
|
||||
bool need_path_column,
|
||||
bool need_file_column);
|
||||
static Block getHeader(Block sample_block, const std::vector<NameAndTypePair> & requested_virtual_columns);
|
||||
|
||||
HDFSSource(
|
||||
StorageHDFSPtr storage_,
|
||||
const StorageSnapshotPtr & storage_snapshot_,
|
||||
const Block & block_for_format_,
|
||||
const std::vector<NameAndTypePair> & requested_virtual_columns_,
|
||||
ContextPtr context_,
|
||||
UInt64 max_block_size_,
|
||||
bool need_path_column_,
|
||||
bool need_file_column_,
|
||||
std::shared_ptr<IteratorWrapper> file_iterator_,
|
||||
ColumnsDescription columns_description_);
|
||||
|
||||
@ -140,7 +130,8 @@ public:
|
||||
|
||||
private:
|
||||
StorageHDFSPtr storage;
|
||||
StorageSnapshotPtr storage_snapshot;
|
||||
Block block_for_format;
|
||||
std::vector<NameAndTypePair> requested_virtual_columns;
|
||||
UInt64 max_block_size;
|
||||
bool need_path_column;
|
||||
bool need_file_column;
|
||||
|
@ -742,6 +742,7 @@ void registerStorageHive(StorageFactory & factory)
|
||||
StorageFactory::StorageFeatures{
|
||||
.supports_settings = true,
|
||||
.supports_sort_order = true,
|
||||
.source_access_type = AccessType::HIVE,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1314,9 +1314,6 @@ void MergeTreeData::loadDataParts(bool skip_sanity_checks)
|
||||
if (!parts_from_wal.empty())
|
||||
loadDataPartsFromWAL(broken_parts_to_detach, duplicate_parts_to_remove, parts_from_wal, part_lock);
|
||||
|
||||
for (auto & part : duplicate_parts_to_remove)
|
||||
part->remove();
|
||||
|
||||
for (auto & part : broken_parts_to_detach)
|
||||
part->renameToDetached("broken-on-start"); /// detached parts must not have '_' in prefixes
|
||||
|
||||
|
@ -256,20 +256,19 @@ static StoragePtr create(const StorageFactory::Arguments & args)
|
||||
{
|
||||
String msg;
|
||||
if (is_extended_storage_def)
|
||||
msg += "With extended storage definition syntax storage " + args.engine_name + " requires ";
|
||||
msg += fmt::format("With extended storage definition syntax storage {} requires ", args.engine_name);
|
||||
else
|
||||
msg += "Storage " + args.engine_name + " requires ";
|
||||
msg += fmt::format("ORDER BY or PRIMARY KEY clause is missing. "
|
||||
"Consider using extended storage definition syntax with ORDER BY or PRIMARY KEY clause. "
|
||||
"With deprecated old syntax (highly not recommended) storage {} requires ", args.engine_name);
|
||||
|
||||
if (max_num_params)
|
||||
{
|
||||
if (min_num_params == max_num_params)
|
||||
msg += toString(min_num_params) + " parameters: ";
|
||||
else
|
||||
msg += toString(min_num_params) + " to " + toString(max_num_params) + " parameters: ";
|
||||
msg += needed_params;
|
||||
}
|
||||
else
|
||||
if (max_num_params == 0)
|
||||
msg += "no parameters";
|
||||
if (min_num_params == max_num_params)
|
||||
msg += fmt::format("{} parameters: {}", min_num_params, needed_params);
|
||||
else
|
||||
msg += fmt::format("{} to {} parameters: {}", min_num_params, max_num_params, needed_params);
|
||||
|
||||
|
||||
msg += getMergeTreeVerboseHelp(is_extended_storage_def);
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <Storages/StorageS3Settings.h>
|
||||
#include <Storages/StorageSnapshot.h>
|
||||
#include <Storages/PartitionedSink.h>
|
||||
#include <Storages/getVirtualsForStorage.h>
|
||||
|
||||
#include <IO/ReadBufferFromS3.h>
|
||||
#include <IO/WriteBufferFromS3.h>
|
||||
@ -210,25 +211,16 @@ String StorageS3Source::KeysIterator::next()
|
||||
return pimpl->next();
|
||||
}
|
||||
|
||||
Block StorageS3Source::getHeader(Block sample_block, bool with_path_column, bool with_file_column)
|
||||
Block StorageS3Source::getHeader(Block sample_block, const std::vector<NameAndTypePair> & requested_virtual_columns)
|
||||
{
|
||||
if (with_path_column)
|
||||
sample_block.insert(
|
||||
{DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumn(),
|
||||
std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()),
|
||||
"_path"});
|
||||
if (with_file_column)
|
||||
sample_block.insert(
|
||||
{DataTypeLowCardinality{std::make_shared<DataTypeString>()}.createColumn(),
|
||||
std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()),
|
||||
"_file"});
|
||||
for (const auto & virtual_column : requested_virtual_columns)
|
||||
sample_block.insert({virtual_column.type->createColumn(), virtual_column.type, virtual_column.name});
|
||||
|
||||
return sample_block;
|
||||
}
|
||||
|
||||
StorageS3Source::StorageS3Source(
|
||||
bool need_path,
|
||||
bool need_file,
|
||||
const std::vector<NameAndTypePair> & requested_virtual_columns_,
|
||||
const String & format_,
|
||||
String name_,
|
||||
const Block & sample_block_,
|
||||
@ -242,7 +234,7 @@ StorageS3Source::StorageS3Source(
|
||||
const String & bucket_,
|
||||
std::shared_ptr<IteratorWrapper> file_iterator_,
|
||||
const size_t download_thread_num_)
|
||||
: SourceWithProgress(getHeader(sample_block_, need_path, need_file))
|
||||
: SourceWithProgress(getHeader(sample_block_, requested_virtual_columns_))
|
||||
, WithContext(context_)
|
||||
, name(std::move(name_))
|
||||
, bucket(bucket_)
|
||||
@ -254,8 +246,7 @@ StorageS3Source::StorageS3Source(
|
||||
, client(client_)
|
||||
, sample_block(sample_block_)
|
||||
, format_settings(format_settings_)
|
||||
, with_file_column(need_file)
|
||||
, with_path_column(need_path)
|
||||
, requested_virtual_columns(requested_virtual_columns_)
|
||||
, file_iterator(file_iterator_)
|
||||
, download_thread_num(download_thread_num_)
|
||||
{
|
||||
@ -344,16 +335,18 @@ Chunk StorageS3Source::generate()
|
||||
{
|
||||
UInt64 num_rows = chunk.getNumRows();
|
||||
|
||||
if (with_path_column)
|
||||
chunk.addColumn(DataTypeLowCardinality{std::make_shared<DataTypeString>()}
|
||||
.createColumnConst(num_rows, file_path)
|
||||
->convertToFullColumnIfConst());
|
||||
if (with_file_column)
|
||||
for (const auto & virtual_column : requested_virtual_columns)
|
||||
{
|
||||
size_t last_slash_pos = file_path.find_last_of('/');
|
||||
chunk.addColumn(DataTypeLowCardinality{std::make_shared<DataTypeString>()}
|
||||
.createColumnConst(num_rows, file_path.substr(last_slash_pos + 1))
|
||||
->convertToFullColumnIfConst());
|
||||
if (virtual_column.name == "_path")
|
||||
{
|
||||
chunk.addColumn(virtual_column.type->createColumnConst(num_rows, file_path)->convertToFullColumnIfConst());
|
||||
}
|
||||
else if (virtual_column.name == "_file")
|
||||
{
|
||||
size_t last_slash_pos = file_path.find_last_of('/');
|
||||
auto column = virtual_column.type->createColumnConst(num_rows, file_path.substr(last_slash_pos + 1));
|
||||
chunk.addColumn(column->convertToFullColumnIfConst());
|
||||
}
|
||||
}
|
||||
|
||||
return chunk;
|
||||
@ -627,6 +620,13 @@ StorageS3::StorageS3(
|
||||
storage_metadata.setConstraints(constraints_);
|
||||
storage_metadata.setComment(comment);
|
||||
setInMemoryMetadata(storage_metadata);
|
||||
|
||||
auto default_virtuals = NamesAndTypesList{
|
||||
{"_path", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
||||
{"_file", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())}};
|
||||
|
||||
auto columns = storage_metadata.getSampleBlock().getNamesAndTypesList();
|
||||
virtual_columns = getVirtualsForStorage(columns, default_virtuals);
|
||||
}
|
||||
|
||||
std::shared_ptr<StorageS3Source::IteratorWrapper> StorageS3::createFileIterator(const ClientAuthentication & client_auth, const std::vector<String> & keys, bool is_key_with_globs, bool distributed_processing, ContextPtr local_context)
|
||||
@ -674,14 +674,14 @@ Pipe StorageS3::read(
|
||||
updateClientAndAuthSettings(local_context, client_auth);
|
||||
|
||||
Pipes pipes;
|
||||
bool need_path_column = false;
|
||||
bool need_file_column = false;
|
||||
for (const auto & column : column_names)
|
||||
|
||||
std::unordered_set<String> column_names_set(column_names.begin(), column_names.end());
|
||||
std::vector<NameAndTypePair> requested_virtual_columns;
|
||||
|
||||
for (const auto & virtual_column : getVirtuals())
|
||||
{
|
||||
if (column == "_path")
|
||||
need_path_column = true;
|
||||
if (column == "_file")
|
||||
need_file_column = true;
|
||||
if (column_names_set.contains(virtual_column.name))
|
||||
requested_virtual_columns.push_back(virtual_column);
|
||||
}
|
||||
|
||||
std::shared_ptr<StorageS3Source::IteratorWrapper> iterator_wrapper = createFileIterator(client_auth, keys, is_key_with_globs, distributed_processing, local_context);
|
||||
@ -690,8 +690,18 @@ Pipe StorageS3::read(
|
||||
Block block_for_format;
|
||||
if (isColumnOriented())
|
||||
{
|
||||
auto fetch_columns = column_names;
|
||||
const auto & virtuals = getVirtuals();
|
||||
std::erase_if(
|
||||
fetch_columns,
|
||||
[&](const String & col)
|
||||
{ return std::any_of(virtuals.begin(), virtuals.end(), [&](const NameAndTypePair & virtual_col){ return col == virtual_col.name; }); });
|
||||
|
||||
if (fetch_columns.empty())
|
||||
fetch_columns.push_back(ExpressionActions::getSmallestColumn(storage_snapshot->metadata->getColumns().getAllPhysical()));
|
||||
|
||||
columns_description = ColumnsDescription{
|
||||
storage_snapshot->getSampleBlockForColumns(column_names).getNamesAndTypesList()};
|
||||
storage_snapshot->getSampleBlockForColumns(fetch_columns).getNamesAndTypesList()};
|
||||
block_for_format = storage_snapshot->getSampleBlockForColumns(columns_description.getNamesOfPhysical());
|
||||
}
|
||||
else
|
||||
@ -704,8 +714,7 @@ Pipe StorageS3::read(
|
||||
for (size_t i = 0; i < num_streams; ++i)
|
||||
{
|
||||
pipes.emplace_back(std::make_shared<StorageS3Source>(
|
||||
need_path_column,
|
||||
need_file_column,
|
||||
requested_virtual_columns,
|
||||
format_name,
|
||||
getName(),
|
||||
block_for_format,
|
||||
@ -882,6 +891,8 @@ StorageS3Configuration StorageS3::getConfiguration(ASTs & engine_args, ContextPt
|
||||
configuration.access_key_id = arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else if (arg_name == "secret_access_key")
|
||||
configuration.secret_access_key = arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else if (arg_name == "filename")
|
||||
configuration.url = std::filesystem::path(configuration.url) / arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH,
|
||||
"Unknown key-value argument `{}` for StorageS3, expected: url, [access_key_id, secret_access_key], name of used format and [compression_method].",
|
||||
@ -1081,9 +1092,7 @@ void registerStorageCOS(StorageFactory & factory)
|
||||
|
||||
NamesAndTypesList StorageS3::getVirtuals() const
|
||||
{
|
||||
return NamesAndTypesList{
|
||||
{"_path", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
||||
{"_file", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())}};
|
||||
return virtual_columns;
|
||||
}
|
||||
|
||||
bool StorageS3::supportsPartitionBy() const
|
||||
|
@ -58,11 +58,10 @@ public:
|
||||
|
||||
using IteratorWrapper = std::function<String()>;
|
||||
|
||||
static Block getHeader(Block sample_block, bool with_path_column, bool with_file_column);
|
||||
static Block getHeader(Block sample_block, const std::vector<NameAndTypePair> & requested_virtual_columns);
|
||||
|
||||
StorageS3Source(
|
||||
bool need_path,
|
||||
bool need_file,
|
||||
const std::vector<NameAndTypePair> & requested_virtual_columns_,
|
||||
const String & format,
|
||||
String name_,
|
||||
const Block & sample_block,
|
||||
@ -102,8 +101,7 @@ private:
|
||||
std::unique_ptr<PullingPipelineExecutor> reader;
|
||||
/// onCancel and generate can be called concurrently
|
||||
std::mutex reader_mutex;
|
||||
bool with_file_column = false;
|
||||
bool with_path_column = false;
|
||||
std::vector<NameAndTypePair> requested_virtual_columns;
|
||||
std::shared_ptr<IteratorWrapper> file_iterator;
|
||||
size_t download_thread_num = 1;
|
||||
|
||||
@ -196,6 +194,7 @@ private:
|
||||
|
||||
ClientAuthentication client_auth;
|
||||
std::vector<String> keys;
|
||||
NamesAndTypesList virtual_columns;
|
||||
|
||||
String format_name;
|
||||
UInt64 max_single_read_retries;
|
||||
|
@ -182,7 +182,6 @@ private:
|
||||
|
||||
/// Mutex for the blocks and ready condition
|
||||
std::mutex mutex;
|
||||
std::mutex flush_table_mutex;
|
||||
std::shared_mutex fire_signal_mutex;
|
||||
mutable std::mutex sample_block_lock; /// Mutex to protect access to sample block and inner_blocks_query
|
||||
|
||||
|
22
src/Storages/getVirtualsForStorage.cpp
Normal file
22
src/Storages/getVirtualsForStorage.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "getVirtualsForStorage.h"
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
NamesAndTypesList getVirtualsForStorage(const NamesAndTypesList & storage_columns_, const NamesAndTypesList & default_virtuals_)
|
||||
{
|
||||
auto default_virtuals = default_virtuals_;
|
||||
auto storage_columns = storage_columns_;
|
||||
default_virtuals.sort();
|
||||
storage_columns.sort();
|
||||
|
||||
NamesAndTypesList result_virtuals;
|
||||
std::set_difference(
|
||||
default_virtuals.begin(), default_virtuals.end(), storage_columns.begin(), storage_columns.end(),
|
||||
std::back_inserter(result_virtuals),
|
||||
[](const NameAndTypePair & lhs, const NameAndTypePair & rhs){ return lhs.name < rhs.name; });
|
||||
|
||||
return result_virtuals;
|
||||
}
|
||||
|
||||
}
|
9
src/Storages/getVirtualsForStorage.h
Normal file
9
src/Storages/getVirtualsForStorage.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <Core/NamesAndTypes.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
NamesAndTypesList getVirtualsForStorage(const NamesAndTypesList & storage_columns_, const NamesAndTypesList & default_virtuals_);
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ class TableFunctionHive : public ITableFunction
|
||||
{
|
||||
public:
|
||||
static constexpr auto name = "hive";
|
||||
static constexpr auto storage_type_name = "hive";
|
||||
static constexpr auto storage_type_name = "Hive";
|
||||
std::string getName() const override { return name; }
|
||||
|
||||
bool hasStaticStructure() const override { return true; }
|
||||
|
@ -14,11 +14,16 @@ namespace ProfileEvents
|
||||
namespace DB
|
||||
{
|
||||
|
||||
AccessType ITableFunction::getSourceAccessType() const
|
||||
{
|
||||
return StorageFactory::instance().getSourceAccessType(getStorageTypeName());
|
||||
}
|
||||
|
||||
StoragePtr ITableFunction::execute(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name,
|
||||
ColumnsDescription cached_columns, bool use_global_context) const
|
||||
{
|
||||
ProfileEvents::increment(ProfileEvents::TableFunctionExecute);
|
||||
context->checkAccess(AccessType::CREATE_TEMPORARY_TABLE | StorageFactory::instance().getSourceAccessType(getStorageTypeName()));
|
||||
context->checkAccess(AccessType::CREATE_TEMPORARY_TABLE | getSourceAccessType());
|
||||
|
||||
auto context_to_use = use_global_context ? context->getGlobalContext() : context;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <Parsers/IAST_fwd.h>
|
||||
#include <Storages/IStorage_fwd.h>
|
||||
#include <Storages/ColumnsDescription.h>
|
||||
#include <Access/Common/AccessType.h>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -71,7 +72,10 @@ public:
|
||||
private:
|
||||
virtual StoragePtr executeImpl(
|
||||
const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const = 0;
|
||||
|
||||
virtual const char * getStorageTypeName() const = 0;
|
||||
|
||||
virtual AccessType getSourceAccessType() const;
|
||||
};
|
||||
|
||||
using TableFunctionPtr = std::shared_ptr<ITableFunction>;
|
||||
|
@ -39,6 +39,8 @@ protected:
|
||||
|
||||
const char * getStorageTypeName() const override { return "HDFSCluster"; }
|
||||
|
||||
AccessType getSourceAccessType() const override { return AccessType::HDFS; }
|
||||
|
||||
ColumnsDescription getActualTableStructure(ContextPtr) const override;
|
||||
void parseArguments(const ASTPtr &, ContextPtr) override;
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <Storages/StorageS3.h>
|
||||
#include <Formats/FormatFactory.h>
|
||||
#include "registerTableFunctions.h"
|
||||
#include <filesystem>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -37,6 +38,8 @@ void TableFunctionS3::parseArgumentsImpl(const String & error_message, ASTs & ar
|
||||
s3_configuration.access_key_id = arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else if (arg_name == "secret_access_key")
|
||||
s3_configuration.secret_access_key = arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else if (arg_name == "filename")
|
||||
s3_configuration.url = std::filesystem::path(s3_configuration.url) / arg_value->as<ASTLiteral>()->value.safeGet<String>();
|
||||
else
|
||||
throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, error_message);
|
||||
}
|
||||
|
@ -45,6 +45,8 @@ protected:
|
||||
|
||||
const char * getStorageTypeName() const override { return "S3Cluster"; }
|
||||
|
||||
AccessType getSourceAccessType() const override { return AccessType::S3; }
|
||||
|
||||
ColumnsDescription getActualTableStructure(ContextPtr) const override;
|
||||
void parseArguments(const ASTPtr &, ContextPtr) override;
|
||||
|
||||
|
@ -56,18 +56,20 @@ def get_images_with_versions(
|
||||
for i in range(10):
|
||||
try:
|
||||
logging.info("Pulling image %s", docker_image)
|
||||
latest_error = subprocess.check_output(
|
||||
subprocess.check_output(
|
||||
f"docker pull {docker_image}",
|
||||
stderr=subprocess.STDOUT,
|
||||
shell=True,
|
||||
)
|
||||
break
|
||||
except Exception as ex:
|
||||
latest_error = ex
|
||||
time.sleep(i * 3)
|
||||
logging.info("Got execption pulling docker %s", ex)
|
||||
else:
|
||||
raise Exception(
|
||||
f"Cannot pull dockerhub for image docker pull {docker_image} because of {latest_error}"
|
||||
"Cannot pull dockerhub for image docker pull "
|
||||
f"{docker_image} because of {latest_error}"
|
||||
)
|
||||
|
||||
return docker_images
|
||||
|
@ -22,5 +22,11 @@
|
||||
</header>
|
||||
</headers>
|
||||
</url_with_headers>
|
||||
<s3_conn>
|
||||
<url>http://localhost:11111/test/</url>
|
||||
<access_key_id>test</access_key_id>
|
||||
<secret_access_key>testtest</secret_access_key>
|
||||
<structure>auto</structure>
|
||||
</s3_conn>
|
||||
</named_collections>
|
||||
</clickhouse>
|
||||
|
@ -44,7 +44,7 @@ def dotnet_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--no-build",
|
||||
]
|
||||
|
@ -55,7 +55,7 @@ def golang_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--no-build",
|
||||
]
|
||||
@ -82,7 +82,7 @@ def php_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--no-build",
|
||||
]
|
||||
@ -109,7 +109,7 @@ def nodejs_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--no-build",
|
||||
]
|
||||
@ -136,7 +136,7 @@ def java_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--no-build",
|
||||
]
|
||||
|
@ -56,7 +56,7 @@ def psql_client():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--build",
|
||||
]
|
||||
@ -99,7 +99,7 @@ def java_container():
|
||||
"-f",
|
||||
docker_compose,
|
||||
"up",
|
||||
"--no-recreate",
|
||||
"--force-recreate",
|
||||
"-d",
|
||||
"--build",
|
||||
]
|
||||
|
@ -554,6 +554,26 @@ def test_insert_select_schema_inference(started_cluster):
|
||||
assert int(result) == 1
|
||||
|
||||
|
||||
def test_virtual_columns_2(started_cluster):
|
||||
hdfs_api = started_cluster.hdfs_api
|
||||
|
||||
table_function = (
|
||||
f"hdfs('hdfs://hdfs1:9000/parquet_2', 'Parquet', 'a Int32, b String')"
|
||||
)
|
||||
node1.query(f"insert into table function {table_function} SELECT 1, 'kek'")
|
||||
|
||||
result = node1.query(f"SELECT _path FROM {table_function}")
|
||||
assert result.strip() == "hdfs://hdfs1:9000/parquet_2"
|
||||
|
||||
table_function = (
|
||||
f"hdfs('hdfs://hdfs1:9000/parquet_3', 'Parquet', 'a Int32, _path String')"
|
||||
)
|
||||
node1.query(f"insert into table function {table_function} SELECT 1, 'kek'")
|
||||
|
||||
result = node1.query(f"SELECT _path FROM {table_function}")
|
||||
assert result.strip() == "kek"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cluster.start()
|
||||
input("Cluster created, press any key to destroy...")
|
||||
|
@ -134,6 +134,7 @@ ODBC [] GLOBAL SOURCES
|
||||
JDBC [] GLOBAL SOURCES
|
||||
HDFS [] GLOBAL SOURCES
|
||||
S3 [] GLOBAL SOURCES
|
||||
HIVE [] GLOBAL SOURCES
|
||||
SOURCES [] \N ALL
|
||||
ALL ['ALL PRIVILEGES'] \N \N
|
||||
NONE ['USAGE','NO PRIVILEGES'] \N \N
|
||||
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,32 @@
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
||||
OK
|
73
tests/queries/0_stateless/02235_remote_fs_cache_stress.sh
Executable file
73
tests/queries/0_stateless/02235_remote_fs_cache_stress.sh
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest, long, no-random-settings
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
|
||||
${CLICKHOUSE_CLIENT} --multiquery --multiline --query="""
|
||||
|
||||
DROP TABLE IF EXISTS t_01411;
|
||||
DROP TABLE IF EXISTS t_01411_num;
|
||||
drop table if exists lc_dict_reading;
|
||||
|
||||
CREATE TABLE t_01411(
|
||||
str LowCardinality(String),
|
||||
arr Array(LowCardinality(String)) default [str]
|
||||
) ENGINE = MergeTree()
|
||||
ORDER BY tuple();
|
||||
|
||||
INSERT INTO t_01411 (str) SELECT concat('asdf', toString(number % 10000)) FROM numbers(100000);
|
||||
|
||||
CREATE TABLE t_01411_num(
|
||||
num UInt8,
|
||||
arr Array(LowCardinality(Int64)) default [num]
|
||||
) ENGINE = MergeTree()
|
||||
ORDER BY tuple();
|
||||
|
||||
INSERT INTO t_01411_num (num) SELECT number % 1000 FROM numbers(100000);
|
||||
|
||||
create table lc_dict_reading (val UInt64, str StringWithDictionary, pat String) engine = MergeTree order by val;
|
||||
insert into lc_dict_reading select number, if(number < 8192 * 4, number % 100, number) as s, s from system.numbers limit 100000;
|
||||
"""
|
||||
|
||||
function go()
|
||||
{
|
||||
|
||||
${CLICKHOUSE_CLIENT} --multiquery --multiline --query="""
|
||||
|
||||
select sum(toUInt64(str)), sum(toUInt64(pat)) from lc_dict_reading where val < 8129 or val > 8192 * 4;
|
||||
|
||||
SELECT count() FROM t_01411 WHERE str = 'asdf337';
|
||||
SELECT count() FROM t_01411 WHERE arr[1] = 'asdf337';
|
||||
SELECT count() FROM t_01411 WHERE has(arr, 'asdf337');
|
||||
SELECT count() FROM t_01411 WHERE indexOf(arr, 'asdf337') > 0;
|
||||
|
||||
SELECT count() FROM t_01411 WHERE arr[1] = str;
|
||||
SELECT count() FROM t_01411 WHERE has(arr, str);
|
||||
SELECT count() FROM t_01411 WHERE indexOf(arr, str) > 0;
|
||||
|
||||
SELECT count() FROM t_01411_num WHERE num = 42;
|
||||
SELECT count() FROM t_01411_num WHERE arr[1] = 42;
|
||||
SELECT count() FROM t_01411_num WHERE has(arr, 42);
|
||||
SELECT count() FROM t_01411_num WHERE indexOf(arr, 42) > 0;
|
||||
|
||||
SELECT count() FROM t_01411_num WHERE arr[1] = num;
|
||||
SELECT count() FROM t_01411_num WHERE has(arr, num);
|
||||
SELECT count() FROM t_01411_num WHERE indexOf(arr, num) > 0;
|
||||
SELECT count() FROM t_01411_num WHERE indexOf(arr, num % 337) > 0;
|
||||
|
||||
SELECT indexOf(['a', 'b', 'c'], toLowCardinality('a'));
|
||||
SELECT indexOf(['a', 'b', NULL], toLowCardinality('a'));
|
||||
"""
|
||||
}
|
||||
|
||||
for i in `seq 1 32`; do go | grep -q "Exception" && echo 'FAIL' || echo 'OK' ||: & done
|
||||
|
||||
wait
|
||||
|
||||
${CLICKHOUSE_CLIENT} --multiquery --multiline --query="""
|
||||
DROP TABLE IF EXISTS t_01411;
|
||||
DROP TABLE IF EXISTS t_01411_num;
|
||||
"""
|
15
tests/queries/0_stateless/02245_s3_virtual_columns.reference
Normal file
15
tests/queries/0_stateless/02245_s3_virtual_columns.reference
Normal file
@ -0,0 +1,15 @@
|
||||
-- { echo }
|
||||
drop table if exists test_02245;
|
||||
create table test_02245 (a UInt64) engine = S3(s3_conn, filename='test_02245', format=Parquet);
|
||||
insert into test_02245 select 1 settings s3_truncate_on_insert=1;
|
||||
select * from test_02245;
|
||||
1
|
||||
select _path from test_02245;
|
||||
test/test_02245
|
||||
drop table if exists test_02245_2;
|
||||
create table test_02245_2 (a UInt64, _path Int32) engine = S3(s3_conn, filename='test_02245_2', format=Parquet);
|
||||
insert into test_02245_2 select 1, 2 settings s3_truncate_on_insert=1;
|
||||
select * from test_02245_2;
|
||||
1 2
|
||||
select _path from test_02245_2;
|
||||
2
|
15
tests/queries/0_stateless/02245_s3_virtual_columns.sql
Normal file
15
tests/queries/0_stateless/02245_s3_virtual_columns.sql
Normal file
@ -0,0 +1,15 @@
|
||||
-- Tags: no-fasttest
|
||||
-- Tag no-fasttest: Depends on AWS
|
||||
|
||||
-- { echo }
|
||||
drop table if exists test_02245;
|
||||
create table test_02245 (a UInt64) engine = S3(s3_conn, filename='test_02245', format=Parquet);
|
||||
insert into test_02245 select 1 settings s3_truncate_on_insert=1;
|
||||
select * from test_02245;
|
||||
select _path from test_02245;
|
||||
|
||||
drop table if exists test_02245_2;
|
||||
create table test_02245_2 (a UInt64, _path Int32) engine = S3(s3_conn, filename='test_02245_2', format=Parquet);
|
||||
insert into test_02245_2 select 1, 2 settings s3_truncate_on_insert=1;
|
||||
select * from test_02245_2;
|
||||
select _path from test_02245_2;
|
@ -0,0 +1,4 @@
|
||||
1 0
|
||||
1 1
|
||||
2 0
|
||||
2 1
|
22
tests/queries/0_stateless/02246_is_secure_query_log.sh
Executable file
22
tests/queries/0_stateless/02246_is_secure_query_log.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-fasttest
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CLIENT} --log_queries=1 --query_id "2246_${CLICKHOUSE_DATABASE}_client_nonsecure" -q "select 1 Format Null"
|
||||
${CLICKHOUSE_CLIENT} -q "system flush logs"
|
||||
${CLICKHOUSE_CLIENT} -q "select interface, is_secure from system.query_log where query_id = '2246_${CLICKHOUSE_DATABASE}_client_nonsecure' and type = 'QueryFinish' and current_database = currentDatabase()"
|
||||
|
||||
${CLICKHOUSE_CLIENT_SECURE} --log_queries=1 --query_id "2246_${CLICKHOUSE_DATABASE}_client_secure" -q "select 1 Format Null"
|
||||
${CLICKHOUSE_CLIENT} -q "system flush logs"
|
||||
${CLICKHOUSE_CLIENT} -q "select interface, is_secure from system.query_log where query_id = '2246_${CLICKHOUSE_DATABASE}_client_secure' and type = 'QueryFinish' and current_database = currentDatabase()"
|
||||
|
||||
${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL}&log_queries=1&query_id=2246_${CLICKHOUSE_DATABASE}_http_nonsecure" -d "select 1 Format Null"
|
||||
${CLICKHOUSE_CLIENT} -q "system flush logs"
|
||||
${CLICKHOUSE_CLIENT} -q "select interface, is_secure from system.query_log where query_id = '2246_${CLICKHOUSE_DATABASE}_http_nonsecure' and type = 'QueryFinish' and current_database = currentDatabase()"
|
||||
|
||||
${CLICKHOUSE_CURL} -sSk "${CLICKHOUSE_URL_HTTPS}&log_queries=1&query_id=2246_${CLICKHOUSE_DATABASE}_http_secure" -d "select 1 Format Null"
|
||||
${CLICKHOUSE_CLIENT} -q "system flush logs"
|
||||
${CLICKHOUSE_CLIENT} -q "select interface, is_secure from system.query_log where query_id = '2246_${CLICKHOUSE_DATABASE}_http_secure' and type = 'QueryFinish' and current_database = currentDatabase()"
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
3
tests/queries/0_stateless/02247_fix_extract_parser.sql
Normal file
3
tests/queries/0_stateless/02247_fix_extract_parser.sql
Normal file
@ -0,0 +1,3 @@
|
||||
WITH 'number: 1' as year SELECT extract(year, '\\d+');
|
||||
WITH 'number: 2' as mm SELECT extract(mm, '\\d+');
|
||||
WITH 'number: 3' as s SELECT extract(s, '\\d+');
|
@ -0,0 +1 @@
|
||||
42 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
274
tests/queries/0_stateless/02250_lots_of_columns_in_csv_with_names.sh
Executable file
274
tests/queries/0_stateless/02250_lots_of_columns_in_csv_with_names.sh
Executable file
@ -0,0 +1,274 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test_02250"
|
||||
|
||||
$CLICKHOUSE_CLIENT -q "CREATE TABLE test_02250
|
||||
(
|
||||
field_1 Int32,
|
||||
field_2 Int32,
|
||||
field_3 Int32,
|
||||
field_4 Int32,
|
||||
field_5 Int32,
|
||||
field_6 Int32,
|
||||
field_7 Int32,
|
||||
field_8 Int32,
|
||||
field_9 Int32,
|
||||
field_10 Int32,
|
||||
field_11 Int32,
|
||||
field_12 Int32,
|
||||
field_13 Int32,
|
||||
field_14 Int32,
|
||||
field_15 Int32,
|
||||
field_16 Int32,
|
||||
field_17 Int32,
|
||||
field_18 Int32,
|
||||
field_19 Int32,
|
||||
field_20 Int32,
|
||||
field_21 Int32,
|
||||
field_22 Int32,
|
||||
field_23 Int32,
|
||||
field_24 Int32,
|
||||
field_25 Int32,
|
||||
field_26 Int32,
|
||||
field_27 Int32,
|
||||
field_28 Int32,
|
||||
field_29 Int32,
|
||||
field_30 Int32,
|
||||
field_31 Int32,
|
||||
field_32 Int32,
|
||||
field_33 Int32,
|
||||
field_34 Int32,
|
||||
field_35 Int32,
|
||||
field_36 Int32,
|
||||
field_37 Int32,
|
||||
field_38 Int32,
|
||||
field_39 Int32,
|
||||
field_40 Int32,
|
||||
field_41 Int32,
|
||||
field_42 Int32,
|
||||
field_43 Int32,
|
||||
field_44 Int32,
|
||||
field_45 Int32,
|
||||
field_46 Int32,
|
||||
field_47 Int32,
|
||||
field_48 Int32,
|
||||
field_49 Int32,
|
||||
field_50 Int32,
|
||||
field_51 Int32,
|
||||
field_52 Int32,
|
||||
field_53 Int32,
|
||||
field_54 Int32,
|
||||
field_55 Int32,
|
||||
field_56 Int32,
|
||||
field_57 Int32,
|
||||
field_58 Int32,
|
||||
field_59 Int32,
|
||||
field_60 Int32,
|
||||
field_61 Int32,
|
||||
field_62 Int32,
|
||||
field_63 Int32,
|
||||
field_64 Int32,
|
||||
field_65 Int32,
|
||||
field_66 Int32,
|
||||
field_67 Int32,
|
||||
field_68 Int32,
|
||||
field_69 Int32,
|
||||
field_70 Int32,
|
||||
field_71 Int32,
|
||||
field_72 Int32,
|
||||
field_73 Int32,
|
||||
field_74 Int32,
|
||||
field_75 Int32,
|
||||
field_76 Int32,
|
||||
field_77 Int32,
|
||||
field_78 Int32,
|
||||
field_79 Int32,
|
||||
field_80 Int32,
|
||||
field_81 Int32,
|
||||
field_82 Int32,
|
||||
field_83 Int32,
|
||||
field_84 Int32,
|
||||
field_85 Int32,
|
||||
field_86 Int32,
|
||||
field_87 Int32,
|
||||
field_88 Int32,
|
||||
field_89 Int32,
|
||||
field_90 Int32,
|
||||
field_91 Int32,
|
||||
field_92 Int32,
|
||||
field_93 Int32,
|
||||
field_94 Int32,
|
||||
field_95 Int32,
|
||||
field_96 Int32,
|
||||
field_97 Int32,
|
||||
field_98 Int32,
|
||||
field_99 Int32,
|
||||
field_100 Int32,
|
||||
field_101 Int32,
|
||||
field_102 Int32,
|
||||
field_103 Int32,
|
||||
field_104 Int32,
|
||||
field_105 Int32,
|
||||
field_106 Int32,
|
||||
field_107 Int32,
|
||||
field_108 Int32,
|
||||
field_109 Int32,
|
||||
field_110 Int32,
|
||||
field_111 Int32,
|
||||
field_112 Int32,
|
||||
field_113 Int32,
|
||||
field_114 Int32,
|
||||
field_115 Int32,
|
||||
field_116 Int32,
|
||||
field_117 Int32,
|
||||
field_118 Int32,
|
||||
field_119 Int32,
|
||||
field_120 Int32,
|
||||
field_121 Int32,
|
||||
field_122 Int32,
|
||||
field_123 Int32,
|
||||
field_124 Int32,
|
||||
field_125 Int32,
|
||||
field_126 Int32,
|
||||
field_127 Int32,
|
||||
field_128 Int32,
|
||||
field_129 Int32,
|
||||
field_130 Int32,
|
||||
field_131 Int32,
|
||||
field_132 Int32,
|
||||
field_133 Int32,
|
||||
field_134 Int32,
|
||||
field_135 Int32,
|
||||
field_136 Int32,
|
||||
field_137 Int32,
|
||||
field_138 Int32,
|
||||
field_139 Int32,
|
||||
field_140 Int32,
|
||||
field_141 Int32,
|
||||
field_142 Int32,
|
||||
field_143 Int32,
|
||||
field_144 Int32,
|
||||
field_145 Int32,
|
||||
field_146 Int32,
|
||||
field_147 Int32,
|
||||
field_148 Int32,
|
||||
field_149 Int32,
|
||||
field_150 Int32,
|
||||
field_151 Int32,
|
||||
field_152 Int32,
|
||||
field_153 Int32,
|
||||
field_154 Int32,
|
||||
field_155 Int32,
|
||||
field_156 Int32,
|
||||
field_157 Int32,
|
||||
field_158 Int32,
|
||||
field_159 Int32,
|
||||
field_160 Int32,
|
||||
field_161 Int32,
|
||||
field_162 Int32,
|
||||
field_163 Int32,
|
||||
field_164 Int32,
|
||||
field_165 Int32,
|
||||
field_166 Int32,
|
||||
field_167 Int32,
|
||||
field_168 Int32,
|
||||
field_169 Int32,
|
||||
field_170 Int32,
|
||||
field_171 Int32,
|
||||
field_172 Int32,
|
||||
field_173 Int32,
|
||||
field_174 Int32,
|
||||
field_175 Int32,
|
||||
field_176 Int32,
|
||||
field_177 Int32,
|
||||
field_178 Int32,
|
||||
field_179 Int32,
|
||||
field_180 Int32,
|
||||
field_181 Int32,
|
||||
field_182 Int32,
|
||||
field_183 Int32,
|
||||
field_184 Int32,
|
||||
field_185 Int32,
|
||||
field_186 Int32,
|
||||
field_187 Int32,
|
||||
field_188 Int32,
|
||||
field_189 Int32,
|
||||
field_190 Int32,
|
||||
field_191 Int32,
|
||||
field_192 Int32,
|
||||
field_193 Int32,
|
||||
field_194 Int32,
|
||||
field_195 Int32,
|
||||
field_196 Int32,
|
||||
field_197 Int32,
|
||||
field_198 Int32,
|
||||
field_199 Int32,
|
||||
field_200 Int32,
|
||||
field_201 Int32,
|
||||
field_202 Int32,
|
||||
field_203 Int32,
|
||||
field_204 Int32,
|
||||
field_205 Int32,
|
||||
field_206 Int32,
|
||||
field_207 Int32,
|
||||
field_208 Int32,
|
||||
field_209 Int32,
|
||||
field_210 Int32,
|
||||
field_211 Int32,
|
||||
field_212 Int32,
|
||||
field_213 Int32,
|
||||
field_214 Int32,
|
||||
field_215 Int32,
|
||||
field_216 Int32,
|
||||
field_217 Int32,
|
||||
field_218 Int32,
|
||||
field_219 Int32,
|
||||
field_220 Int32,
|
||||
field_221 Int32,
|
||||
field_222 Int32,
|
||||
field_223 Int32,
|
||||
field_224 Int32,
|
||||
field_225 Int32,
|
||||
field_226 Int32,
|
||||
field_227 Int32,
|
||||
field_228 Int32,
|
||||
field_229 Int32,
|
||||
field_230 Int32,
|
||||
field_231 Int32,
|
||||
field_232 Int32,
|
||||
field_233 Int32,
|
||||
field_234 Int32,
|
||||
field_235 Int32,
|
||||
field_236 Int32,
|
||||
field_237 Int32,
|
||||
field_238 Int32,
|
||||
field_239 Int32,
|
||||
field_240 Int32,
|
||||
field_241 Int32,
|
||||
field_242 Int32,
|
||||
field_243 Int32,
|
||||
field_244 Int32,
|
||||
field_245 Int32,
|
||||
field_246 Int32,
|
||||
field_247 Int32,
|
||||
field_248 Int32,
|
||||
field_249 Int32,
|
||||
field_250 Int32,
|
||||
field_251 Int32,
|
||||
field_252 Int32,
|
||||
field_253 Int32,
|
||||
field_254 Int32,
|
||||
field_255 Int32,
|
||||
field_256 Int32,
|
||||
field_257 Int32
|
||||
)
|
||||
ENGINE = MergeTree
|
||||
ORDER BY tuple()"
|
||||
|
||||
echo -e "field_1\n42" | $CLICKHOUSE_CLIENT -q "INSERT INTO test_02250 FORMAT CSVWithNames" --input_format_with_names_use_header 1
|
||||
$CLICKHOUSE_CLIENT -q "SELECT * FROM test_02250"
|
||||
$CLICKHOUSE_CLIENT -q "DROP TABLE test_02250"
|
Loading…
Reference in New Issue
Block a user