From 56472769985b50f2ecdf2e8a8deb42805c5903d1 Mon Sep 17 00:00:00 2001 From: Marcelo Nunes Alves Date: Fri, 11 Oct 2024 15:54:50 -0300 Subject: [PATCH] community: Problem with embeddings in new versions of clickhouse. (#26041) Starting with Clickhouse version 24.8, a different type of configuration has been introduced in the vectorized data ingestion, and if this configuration occurs, an error occurs when generating the table. As can be seen below: ![Screenshot from 2024-09-04 11-48-00](https://github.com/user-attachments/assets/70840a93-1001-490c-921a-26924c51d9eb) --------- Co-authored-by: Erick Friis --- .../langchain_community/vectorstores/clickhouse.py | 8 ++++++++ .../community/langchain_community/vectorstores/myscale.py | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/libs/community/langchain_community/vectorstores/clickhouse.py b/libs/community/langchain_community/vectorstores/clickhouse.py index a285cb8445210..4246abfc0ddde 100644 --- a/libs/community/langchain_community/vectorstores/clickhouse.py +++ b/libs/community/langchain_community/vectorstores/clickhouse.py @@ -309,6 +309,14 @@ def __init__( **kwargs, ) # Enable JSON type + try: + self.client.command("SET allow_experimental_json_type=1") + except Exception as _: + logger.debug( + f"Clickhouse version={self.client.server_version} - " + "There is no allow_experimental_json_type parameter." + ) + self.client.command("SET allow_experimental_object_type=1") if self.config.index_type: # Enable index diff --git a/libs/community/langchain_community/vectorstores/myscale.py b/libs/community/langchain_community/vectorstores/myscale.py index ecd2108d419ba..d3dec65c8b71e 100644 --- a/libs/community/langchain_community/vectorstores/myscale.py +++ b/libs/community/langchain_community/vectorstores/myscale.py @@ -193,6 +193,13 @@ def __init__( password=self.config.password, **kwargs, ) + try: + self.client.command("SET allow_experimental_json_type=1") + except Exception as _: + logger.debug( + f"Clickhouse version={self.client.server_version} - " + "There is no allow_experimental_json_type parameter." + ) self.client.command("SET allow_experimental_object_type=1") self.client.command(schema_)