From d11ab5937862c2e7359203cc5cab980e92aa5e56 Mon Sep 17 00:00:00 2001 From: Prashant Rakheja Date: Tue, 1 Oct 2024 12:36:59 +0530 Subject: [PATCH 1/2] Fix hanadb issue with default column length Signed-off-by: Prashant Rakheja --- libs/langchain-community/src/vectorstores/hanavector.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/langchain-community/src/vectorstores/hanavector.ts b/libs/langchain-community/src/vectorstores/hanavector.ts index 7650eeb40bdd..098c5aaa6ff6 100644 --- a/libs/langchain-community/src/vectorstores/hanavector.ts +++ b/libs/langchain-community/src/vectorstores/hanavector.ts @@ -269,8 +269,14 @@ export class HanaDB extends VectorStore { throw new Error(`Column ${columnName} has the wrong type: ${dataType}`); } + // For the vector column, we have defined a default value of -1 + // which refers to dynamic length + // However, Length can either be -1 (QRC01+02-24) or 0 (QRC03-24 onwards) + // i.e. HANA db can return 0 (length) even when we set the default value + // Hence, ignoring this check for now only in case of default value + // Check length, if parameter was provided - if (columnLength !== undefined && length !== columnLength) { + if (columnLength !== undefined && length !== columnLength && length > 0) { throw new Error(`Column ${columnName} has the wrong length: ${length}`); } } From 7e2804809c4712428d9be4849c30d30cf2062a83 Mon Sep 17 00:00:00 2001 From: Prashant Rakheja Date: Tue, 1 Oct 2024 13:44:54 +0530 Subject: [PATCH 2/2] Update comment Signed-off-by: Prashant Rakheja --- libs/langchain-community/src/vectorstores/hanavector.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libs/langchain-community/src/vectorstores/hanavector.ts b/libs/langchain-community/src/vectorstores/hanavector.ts index 098c5aaa6ff6..8f55568adb27 100644 --- a/libs/langchain-community/src/vectorstores/hanavector.ts +++ b/libs/langchain-community/src/vectorstores/hanavector.ts @@ -269,11 +269,8 @@ export class HanaDB extends VectorStore { throw new Error(`Column ${columnName} has the wrong type: ${dataType}`); } - // For the vector column, we have defined a default value of -1 - // which refers to dynamic length - // However, Length can either be -1 (QRC01+02-24) or 0 (QRC03-24 onwards) - // i.e. HANA db can return 0 (length) even when we set the default value - // Hence, ignoring this check for now only in case of default value + // Length can either be -1 (QRC01+02-24) or 0 (QRC03-24 onwards) + // to indicate no length constraint being present. // Check length, if parameter was provided if (columnLength !== undefined && length !== columnLength && length > 0) {