Skip to content

Commit a12455b

Browse files
Make SQL UDF persistent in clickhouse-local
1 parent bb83c84 commit a12455b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

programs/local/LocalServer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,14 +948,14 @@ void LocalServer::processConfig()
948948
DatabaseCatalog::instance().startupBackgroundTasks();
949949
}
950950

951-
/// For ClickHouse local if path is not set the loader will be disabled.
952-
global_context->getUserDefinedSQLObjectsStorage().loadObjects();
953-
954951
LOG_DEBUG(log, "Loaded metadata.");
955952
}
956953

957954
if (!attached_system_database)
958955
attachSystemTablesServer(global_context, *createMemoryDatabaseIfNotExists(global_context, DatabaseCatalog::SYSTEM_DATABASE), false);
956+
957+
if (fs::exists(fs::path(path) / "user_defined"))
958+
global_context->getUserDefinedSQLObjectsStorage().loadObjects();
959959
}
960960
else if (!getClientConfiguration().has("no-system-tables"))
961961
{
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2
2+
3
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
# shellcheck source=../shell_config.sh
5+
. "$CURDIR"/../shell_config.sh
6+
7+
$CLICKHOUSE_LOCAL --path "${CLICKHOUSE_TMP}" "CREATE FUNCTION f AS x -> x + 1; SELECT f(1);"
8+
$CLICKHOUSE_LOCAL --path "${CLICKHOUSE_TMP}" "SELECT f(2); DROP FUNCTION f;"

0 commit comments

Comments
 (0)