[BUG REPORT] - Supabase: Load

I’m using the BETA version of N8N.io and I’m implementing the Retrieval Q&A Chain. When connecting the Supabase: Load node as the vector store retriever:

If the table name is not “documents” it throws an error “ERROR: Error searching for documents: 42P01 relation “documents” does not exist null”.

Even though I have set the table name correctly in the node’s Table Name input field, it seems to ignore that value, and looks for “documents” as default.

If I change the table name to “documents” in Supabase, it works.

Hi @James_Pardoe, thanks so much for reporting this and sorry for the trouble. I’ve added this to our bug tracker for a closer look and fix.

Happy to help! n8n is an amazing tool and if I can help make it even more amazing then great!

2 Likes

@James_Pardoe Are you sure you’ve correctly updated the database name in the initial query to set-up the Supabase db? I just tried with not_documents and it worked for me as expected. I followed this Supabase docs: LangChain | Supabase Docs and replaced documents with not_documents. So the final query:

-- Enable the pgvector extension to work with embedding vectors
create extension vector;

-- Create a table to store your documents
create table not_documents (
  id bigserial primary key,
  content text, -- corresponds to Document.pageContent
  metadata jsonb, -- corresponds to Document.metadata
  embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);

-- Create a function to search for documents
create function match_documents (
  query_embedding vector(1536),
  match_count int default null,
  filter jsonb DEFAULT '{}'
) returns table (
  id bigint,
  content text,
  metadata jsonb,
  similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
  return query
  select
    id,
    content,
    metadata,
    1 - (not_documents.embedding <=> query_embedding) as similarity
  from not_documents
  where metadata @> filter
  order by not_documents.embedding <=> query_embedding
  limit match_count;
end;
$$;

Setting it up like this, allows me to use Supabase: Load:

Hi Oleg,

Ah, could that be it? I used the Supabase template query to create a new LangChain database, and it would have been the default ‘documents’ table name. I then manually renamed the table name.

I subsequently then renamed the table name in n8n to match.

Will try with your approach a bit later on and let you know how it goes.

Super strange. I have created a new table called not_documents, and it worked. I then renamed documents to temp, and it still worked.

The bug has self-healed!

Sorry if I wasted your time.

2 Likes

@James_Pardoe Happy to hear it had an happy ending.
No wasted time, appreciate your effort in reporting it and helping us test this beta release :slight_smile:

Hmm, the bug seems to have reemerged. Please see attached screenshot.

If I rename the table zoe_emails to documents in Supabase:

Screenshot 2023-10-20 at 17.01.22

And I keep the Table Name as “zoe_emails” in the Supabase: Load node:

You can see that it actually works. Even though zoe_emails no longer exists in Supabase.

Which proves that it’s not listening to the Table Name variable when communicating with Supabase and it’s using the default ‘documents’ table name.

It’s not just about the table name. What’s also important is the matching function which is used which I assume you didn’t update.

-- Enable the pgvector extension to work with embedding vectors
create extension vector;

-- Create a table to store your documents
create table documents (
  id bigserial primary key,
  content text, -- corresponds to Document.pageContent
  metadata jsonb, -- corresponds to Document.metadata
  embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);

-- Create a function to search for documents
create function match_documents (
  query_embedding vector(1536),
  match_count int default null,
  filter jsonb DEFAULT '{}'
) returns table (
  id bigint,
  content text,
  metadata jsonb,
  similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
  return query
  select
    id,
    content,
    metadata,
    1 - (documents.embedding <=> query_embedding) as similarity
  from documents
  where metadata @> filter
  order by documents.embedding <=> query_embedding
  limit match_count;
end;
$$;

You can see that in that function documents get referenced several times. So you would have to update that function as well.

4 Likes

Oh I see, I didn’t realise. So I need to create a unique matching function for every vector table that’s created. Thanks for the reply.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.