| 755 | } |
| 756 | |
| 757 | BlockInputStreamPtr InterpreterInsertQuery::buildInputStreamFromSource( |
| 758 | const ContextPtr context_ptr, |
| 759 | const ColumnsDescription & columns, |
| 760 | const Block & sample, |
| 761 | const Settings & settings, |
| 762 | const String & source_uri, |
| 763 | const String & format, |
| 764 | bool is_enable_squash, |
| 765 | const String & compression_method) |
| 766 | { |
| 767 | Poco::URI uri(source_uri); |
| 768 | const String & scheme = uri.getScheme(); |
| 769 | |
| 770 | BlockInputStreams inputs; |
| 771 | { |
| 772 | std::vector<String> file_path_list; |
| 773 | parseFuzzyName(context_ptr, file_path_list, source_uri, scheme); |
| 774 | |
| 775 | for (auto & file_path : file_path_list) |
| 776 | { |
| 777 | std::unique_ptr<ReadBuffer> read_buf = nullptr; |
| 778 | |
| 779 | if (scheme.empty() || scheme == "file") |
| 780 | { |
| 781 | read_buf = std::make_unique<ReadBufferFromFile>(Poco::URI(file_path).getPath()); |
| 782 | } |
| 783 | #if USE_HDFS |
| 784 | else if (DB::isHdfsOrCfsScheme(scheme)) |
| 785 | { |
| 786 | ReadSettings read_settings; |
| 787 | read_settings.remote_throttler = context_ptr->getProcessList().getHDFSDownloadThrottler(); |
| 788 | read_buf = std::make_unique<ReadBufferFromByteHDFS>(file_path, context_ptr->getHdfsConnectionParams(), read_settings); |
| 789 | } |
| 790 | #endif |
| 791 | #if USE_AWS_S3 |
| 792 | else if (isS3URIScheme(scheme)) |
| 793 | { |
| 794 | S3::URI s3_uri(file_path); |
| 795 | String endpoint = s3_uri.endpoint.empty() ? context_ptr->getSettingsRef().s3_endpoint.toString() : s3_uri.endpoint; |
| 796 | String bucket = s3_uri.bucket; |
| 797 | String key = s3_uri.key; |
| 798 | S3::S3Config s3_cfg( |
| 799 | endpoint, |
| 800 | context_ptr->getSettingsRef().s3_region.toString(), |
| 801 | bucket, |
| 802 | context_ptr->getSettingsRef().s3_ak_id.toString(), |
| 803 | context_ptr->getSettingsRef().s3_ak_secret.toString(), |
| 804 | "", |
| 805 | "", |
| 806 | context_ptr->getSettingsRef().s3_use_virtual_hosted_style); |
| 807 | const std::shared_ptr<Aws::S3::S3Client> client = s3_cfg.create(); |
| 808 | read_buf = std::make_unique<ReadBufferFromS3>(client, bucket, key, context_ptr->getReadSettings()); |
| 809 | } |
| 810 | #endif |
| 811 | else |
| 812 | { |
| 813 | throw Exception("URI scheme " + scheme + " is not supported with insert statement yet", ErrorCodes::NOT_IMPLEMENTED); |
| 814 | } |
nothing calls this directly
no test coverage detected