The ClickHouse server failed to execute a query because it encountered a function that it doesn’t recognize or has not yet implemented.

This error, Code 48: Function Is Not Implemented, typically signals that you’re trying to use a function in your ClickHouse SQL query that the specific version of ClickHouse you’re running doesn’t support. This can happen for a few reasons:

  • Using a new function from a recent version: You might be running an older version of ClickHouse but using a function that was introduced in a much newer release. ClickHouse adds new functions regularly, and they aren’t always backward-compatible with older server versions.

    • Diagnosis: Check the ClickHouse documentation for the exact version you are running. Compare the function in your query against the list of supported functions for that version. You can also check the system.functions table:
      SELECT name FROM system.functions WHERE name = 'your_function_name';
      
      If this query returns no rows, the function is not available.
    • Fix: The most straightforward fix is to upgrade your ClickHouse server to a version that supports the desired function. Alternatively, if you must use an older version, you’ll need to rewrite your query using only functions available in that version. For example, if you’re using array_join on a string and array_join isn’t implemented, you might need to find a string manipulation function that achieves a similar result or use a different approach entirely.
  • Typo in the function name: A simple misspelling is the most common culprit. array_join could easily become array_jion, or to_utf8 might be to_utf8r.

    • Diagnosis: Carefully review your SQL query for any typographical errors in function names. Pay close attention to the spelling and underscores.
    • Fix: Correct the spelling of the function name in your query. For instance, change array_jion back to array_join.
  • Using a function from a specific module that isn’t enabled or compiled: Some functions are part of optional modules or require specific build flags. If your ClickHouse installation didn’t include or enable these, the function won’t be available. This is less common for standard functions but can occur with specialized ones (e.g., certain geospatial or machine learning functions).

    • Diagnosis: Check your ClickHouse server’s build configuration or the system.build_options table if available. Look for any flags related to the function’s module.
    • Fix: Recompile ClickHouse with the necessary module enabled, or install a pre-compiled version that includes the required functionality. This is often a more involved process, requiring server downtime.
  • Function name collision or reserved keyword: While rare, it’s possible that a function name you’re using conflicts with a reserved keyword or another internal identifier in a specific ClickHouse context.

    • Diagnosis: Check the ClickHouse documentation for reserved keywords. Also, examine if the function name is very generic.
    • Fix: If it’s a reserved keyword, you might need to quote the function name using backticks, like `function_name`, though this is usually a workaround and not a true fix. Better to rename your custom function or avoid using reserved words.
  • Client-side interpretation issue (less likely for Code 48): In some rare cases, a client library or driver might be interpreting a query incorrectly or sending an unrecognized function name to the server. However, Code 48 is almost always a server-side complaint.

    • Diagnosis: Try running the exact same query directly against the ClickHouse server using the clickhouse-client. If it works there, the issue is with your client application or driver.
    • Fix: Update your client library or driver to the latest version compatible with your ClickHouse server.
  • Corrupted ClickHouse installation or data files: Though highly improbable, a corrupted installation or critical system files could lead to functions not being recognized.

    • Diagnosis: This is a last resort. Check ClickHouse server logs for other related errors or warnings. Examine the integrity of your ClickHouse installation directory.
    • Fix: Reinstall ClickHouse. Ensure you back up your data and configuration before doing so.

Once you’ve resolved the Code 48 error, the next immediate problem you might encounter, if the underlying issue was a missing dependency or a complex function, is a Code 27: Illegal type of argument for function.

Want structured learning?

Take the full Clickhouse course →