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

Method parse

src/Storages/StorageFile.cpp:986–1036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

984}
985
986StorageFile::FileSource StorageFile::FileSource::parse(const String & source, const ContextPtr & context, std::optional<bool> allow_archive_path_syntax)
987{
988 String filename;
989 String path_to_archive;
990
991 if (!allow_archive_path_syntax)
992 allow_archive_path_syntax = context->getSettingsRef()[Setting::allow_archive_path_syntax];
993
994 if (*allow_archive_path_syntax)
995 std::tie(path_to_archive, filename) = splitToArchivePathAndPathInArchive(source);
996 else
997 filename = source;
998
999 FileSource res;
1000 String user_files_path = context->getUserFilesPath();
1001
1002 if (!path_to_archive.empty())
1003 res.archive_info = getArchiveInfo(path_to_archive, filename, user_files_path, context, res.total_bytes_to_read);
1004 else
1005 res.paths = getPathsList(filename, user_files_path, context, res.total_bytes_to_read);
1006
1007 res.with_globs = res.paths.size() > 1;
1008
1009 if (res.archive_info)
1010 {
1011 res.format_from_filenames = FormatFactory::instance().tryGetFormatFromFileName(res.archive_info->path_in_archive);
1012 }
1013 else
1014 {
1015 for (const String & path : res.paths)
1016 {
1017 auto single_file_format = FormatFactory::instance().tryGetFormatFromFileName(path);
1018 if (!res.format_from_filenames)
1019 {
1020 res.format_from_filenames = single_file_format;
1021 }
1022 else if (res.format_from_filenames != single_file_format)
1023 {
1024 res.format_from_filenames = {};
1025 break;
1026 }
1027 }
1028 }
1029
1030 if (!res.paths.empty())
1031 res.path_for_partitioned_write = res.paths.front();
1032 else
1033 res.path_for_partitioned_write = filename;
1034
1035 return res;
1036}
1037
1038std::pair<ColumnsDescription, String> StorageFile::getTableStructureAndFormatFromFileDescriptor(std::optional<String> format, const ContextPtr & context)
1039{

Callers 1

parseJSONFunction · 0.45

Calls 8

getArchiveInfoFunction · 0.85
getPathsListFunction · 0.85
getUserFilesPathMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected