2023-06-05 18:36:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#if USE_AZURE_BLOB_STORAGE
|
|
|
|
|
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2023-06-06 19:58:54 +00:00
|
|
|
#include <Storages/StorageAzureBlob.h>
|
2023-06-05 18:36:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class Context;
|
|
|
|
|
2023-07-17 12:52:11 +00:00
|
|
|
/* AzureBlob(source, [access_key_id, secret_access_key,] [format, compression, structure]) - creates a temporary storage for a file in AzureBlob.
|
2023-06-05 18:36:17 +00:00
|
|
|
*/
|
2023-06-06 18:23:20 +00:00
|
|
|
class TableFunctionAzureBlobStorage : public ITableFunction
|
2023-06-05 18:36:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2023-06-09 17:28:06 +00:00
|
|
|
static constexpr auto name = "azureBlobStorage";
|
2023-07-17 15:18:14 +00:00
|
|
|
|
2023-07-17 12:52:11 +00:00
|
|
|
static constexpr auto signature = " - connection_string, container_name, blobpath\n"
|
|
|
|
" - connection_string, container_name, blobpath, structure \n"
|
|
|
|
" - connection_string, container_name, blobpath, format \n"
|
|
|
|
" - connection_string, container_name, blobpath, format, compression \n"
|
|
|
|
" - connection_string, container_name, blobpath, format, compression, structure \n"
|
|
|
|
" - storage_account_url, container_name, blobpath, account_name, account_key\n"
|
|
|
|
" - storage_account_url, container_name, blobpath, account_name, account_key, structure\n"
|
|
|
|
" - storage_account_url, container_name, blobpath, account_name, account_key, format\n"
|
|
|
|
" - storage_account_url, container_name, blobpath, account_name, account_key, format, compression\n"
|
|
|
|
" - storage_account_url, container_name, blobpath, account_name, account_key, format, compression, structure\n";
|
2023-06-05 18:36:17 +00:00
|
|
|
|
2023-06-06 16:48:20 +00:00
|
|
|
static size_t getMaxNumberOfArguments() { return 8; }
|
2023-06-05 18:36:17 +00:00
|
|
|
|
|
|
|
String getName() const override
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual String getSignature() const
|
|
|
|
{
|
|
|
|
return signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hasStaticStructure() const override { return configuration.structure != "auto"; }
|
|
|
|
|
|
|
|
bool needStructureHint() const override { return configuration.structure == "auto"; }
|
|
|
|
|
|
|
|
void setStructureHint(const ColumnsDescription & structure_hint_) override { structure_hint = structure_hint_; }
|
|
|
|
|
2023-09-11 14:55:37 +00:00
|
|
|
bool supportsReadingSubsetOfColumns(const ContextPtr & context) override;
|
2023-06-05 18:36:17 +00:00
|
|
|
|
2023-11-28 18:15:07 +00:00
|
|
|
std::unordered_set<String> getVirtualsToCheckBeforeUsingStructureHint() const override;
|
2023-06-05 18:36:17 +00:00
|
|
|
|
2023-06-08 07:26:30 +00:00
|
|
|
virtual void parseArgumentsImpl(ASTs & args, const ContextPtr & context);
|
|
|
|
|
2024-01-22 22:55:50 +00:00
|
|
|
static void updateStructureAndFormatArgumentsIfNeeded(ASTs & args, const String & structure, const String & format, const ContextPtr & context);
|
2023-06-05 18:36:17 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
StoragePtr executeImpl(
|
|
|
|
const ASTPtr & ast_function,
|
|
|
|
ContextPtr context,
|
|
|
|
const std::string & table_name,
|
2023-07-06 08:56:07 +00:00
|
|
|
ColumnsDescription cached_columns,
|
|
|
|
bool is_insert_query) const override;
|
2023-06-05 18:36:17 +00:00
|
|
|
|
|
|
|
const char * getStorageTypeName() const override { return "Azure"; }
|
|
|
|
|
2023-07-06 08:56:07 +00:00
|
|
|
ColumnsDescription getActualTableStructure(ContextPtr context, bool is_insert_query) const override;
|
2023-06-05 18:36:17 +00:00
|
|
|
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
|
|
|
|
2023-06-06 19:58:54 +00:00
|
|
|
mutable StorageAzureBlob::Configuration configuration;
|
2023-06-05 18:36:17 +00:00
|
|
|
ColumnsDescription structure_hint;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|