2018-06-11 12:13:00 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2022-04-27 12:15:52 +00:00
|
|
|
#include "Parsers/IAST_fwd.h"
|
2018-06-11 12:13:00 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2019-08-01 01:53:38 +00:00
|
|
|
class ColumnsDescription;
|
2020-05-20 20:16:32 +00:00
|
|
|
class Context;
|
2019-08-01 01:53:38 +00:00
|
|
|
|
2018-06-11 12:13:00 +00:00
|
|
|
/*
|
2021-12-15 11:30:57 +00:00
|
|
|
* function(source, format, structure[, compression_method]) - creates a temporary storage from formatted source
|
2018-06-11 12:13:00 +00:00
|
|
|
*/
|
|
|
|
class ITableFunctionFileLike : public ITableFunction
|
|
|
|
{
|
2022-02-18 16:19:42 +00:00
|
|
|
public:
|
|
|
|
bool needStructureHint() const override { return structure == "auto"; }
|
|
|
|
|
|
|
|
void setStructureHint(const ColumnsDescription & structure_hint_) override { structure_hint = structure_hint_; }
|
2021-09-08 19:28:22 +00:00
|
|
|
|
2022-10-14 15:09:35 +00:00
|
|
|
bool supportsReadingSubsetOfColumns() override;
|
|
|
|
|
2021-09-08 19:28:22 +00:00
|
|
|
protected:
|
|
|
|
void parseArguments(const ASTPtr & ast_function, ContextPtr context) override;
|
2022-06-23 20:04:06 +00:00
|
|
|
virtual void parseFirstArguments(const ASTPtr & arg, const ContextPtr & context);
|
2022-04-27 12:15:52 +00:00
|
|
|
virtual String getFormatFromFirstArgument();
|
2021-09-08 19:28:22 +00:00
|
|
|
|
|
|
|
String filename;
|
2022-01-12 15:28:13 +00:00
|
|
|
String format = "auto";
|
2021-12-15 11:30:57 +00:00
|
|
|
String structure = "auto";
|
2021-09-08 19:28:22 +00:00
|
|
|
String compression_method = "auto";
|
2022-02-18 16:19:42 +00:00
|
|
|
ColumnsDescription structure_hint;
|
2021-09-08 19:28:22 +00:00
|
|
|
|
2018-06-11 12:13:00 +00:00
|
|
|
private:
|
2021-04-10 23:33:54 +00:00
|
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const override;
|
2020-10-14 12:19:29 +00:00
|
|
|
|
2018-06-11 12:13:00 +00:00
|
|
|
virtual StoragePtr getStorage(
|
2021-04-10 23:33:54 +00:00
|
|
|
const String & source, const String & format, const ColumnsDescription & columns, ContextPtr global_context,
|
2020-10-14 12:19:29 +00:00
|
|
|
const std::string & table_name, const String & compression_method) const = 0;
|
|
|
|
|
2021-12-15 11:30:57 +00:00
|
|
|
bool hasStaticStructure() const override { return structure != "auto"; }
|
2018-06-11 12:13:00 +00:00
|
|
|
};
|
2021-12-15 11:30:57 +00:00
|
|
|
|
2018-06-11 12:13:00 +00:00
|
|
|
}
|