mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
Improve schema inference in clickhouse-local
This commit is contained in:
@@ -313,9 +313,17 @@ void LocalServer::cleanup()
|
||||
}
|
||||
|
||||
|
||||
static bool checkIfStdinIsNotEmpty()
|
||||
{
|
||||
struct stat file_stat;
|
||||
return fstat(STDIN_FILENO, &file_stat) == 0 && (S_ISREG(file_stat.st_mode) || S_ISFIFO(file_stat.st_mode));
|
||||
}
|
||||
|
||||
std::string LocalServer::getInitialCreateTableQuery()
|
||||
{
|
||||
if (!config().has("table-structure") && !config().has("table-file") && !config().has("table-data-format"))
|
||||
/// We can create initial table only when we have data for it
|
||||
/// in file or in stdin (we treat stdin as table data if we have query)
|
||||
if (!config().has("table-file") && (!checkIfStdinIsNotEmpty() || !config().has("query")))
|
||||
return {};
|
||||
|
||||
auto table_name = backQuoteIfNeed(config().getString("table-name", "table"));
|
||||
|
||||
Reference in New Issue
Block a user