Skip to content

Adding Oracle Database Vector Store Connector #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
bc2c366
Adding Oracle Vector Store
psilberk Apr 22, 2025
ba1aa96
Upsert and Main sample
psilberk Apr 25, 2025
7d476fc
Split out the data into its own module
fmeheust May 22, 2025
bf0c167
Removed dependencies
fmeheust May 22, 2025
9a7c650
Merge branch 'microsoft:main' into main
psilberk May 22, 2025
a643fe2
Merge pull request #1 from fmeheust/split-data-module
psilberk May 22, 2025
376d8d2
Added oracle store
fmeheust Jun 2, 2025
458ace8
Added Oracle store
fmeheust Jun 2, 2025
8bef1ff
Added reference to parent's pom in sqlite
psilberk Jun 2, 2025
a514b28
Any tag filter
fmeheust Jun 3, 2025
d8b6895
Clean pom and 1st Sample
psilberk Jun 5, 2025
e3ea6a2
Merge branch 'main' into pom_and_demos1
psilberk Jun 5, 2025
e5e4ae3
Merge pull request #2 from psilberk/pom_and_demos1
psilberk Jun 5, 2025
df07b40
Sample wip #2
psilberk Jun 5, 2025
f0099cf
Merge pull request #3 from psilberk/pom_and_demos1
psilberk Jun 5, 2025
805f5fa
Add test for IndexKind.UNDEFINED and IndexKind.HNSW
norah-li Jun 7, 2025
1ca9439
Remove old implementation
psilberk Jun 9, 2025
92339ab
Merge pull request #4 from psilberk/pom_and_demos1
psilberk Jun 9, 2025
c3bfafb
Added constants for type mapping and matched ODP type mapping when po…
fmeheust Jun 10, 2025
bc0f640
Adding Book class and pom fixes
psilberk Jun 11, 2025
3cbee72
Missing getter methods and wrong null check
fmeheust Jun 11, 2025
03456d1
Merge remote-tracking branch 'origin/add-oracle-store' into add-oracl…
norah-li Jun 14, 2025
c3db036
add test for key type
norah-li Jun 14, 2025
2306e21
enable test for COSINE_DISTANCE, COSINE_SIMILARITY, DOT_PRODUCT in Ho…
norah-li Jun 14, 2025
0bf9199
Refactoring
fmeheust Jun 17, 2025
434b9e6
Add test for supported data type(timestamp and uuid not included)
norah-li Jun 18, 2025
89bc5ea
Merge remote-tracking branch 'origin/add-oracle-store-tests' into add…
fmeheust Jun 19, 2025
1c83d62
Test and bug fixes
fmeheust Jun 20, 2025
a6fac68
BigDecimal mapping and value range
fmeheust Jun 20, 2025
2f421a8
Any tag filter
fmeheust Jun 3, 2025
cf99cf7
Added constants for type mapping and matched ODP type mapping when po…
fmeheust Jun 10, 2025
a9bc539
Refactoring
fmeheust Jun 17, 2025
17fce47
Add test for IndexKind.UNDEFINED and IndexKind.HNSW
norah-li Jun 7, 2025
a9e8213
add test for key type
norah-li Jun 14, 2025
b3e1f4b
Add test for supported data type(timestamp and uuid not included)
norah-li Jun 18, 2025
ec31376
Test and bug fixes
fmeheust Jun 20, 2025
cb4f726
BigDecimal mapping and value range
fmeheust Jun 20, 2025
6bd3a8e
Upsert and Main sample
psilberk Apr 25, 2025
2e31333
Books demo with vector similarity search
psilberk Jun 23, 2025
32f3ddc
Fix pom for demo
psilberk Jun 23, 2025
e87089e
Merge pull request #6 from psilberk/pom_and_demos1
psilberk Jun 23, 2025
b7d5ab3
Fixing samples poms
psilberk Jun 24, 2025
67aec2b
JsonTypeInfo annotation
fmeheust Jun 25, 2025
ef2050a
Merge branch 'add-oracle-store' of https://github.com/psilberk/semant…
fmeheust Jun 25, 2025
0e044a0
Javadod and comments + map UUID to string and other small changes
fmeheust Jun 26, 2025
113ae52
Merge remote-tracking branch 'origin/main' into add-oracle-store
fmeheust Jun 26, 2025
9eaad94
Merge branch 'main' into add-oracle-store
fmeheust Jun 26, 2025
abd6d42
Fixed merge issues
fmeheust Jun 26, 2025
219a4d8
add extended test
norah-li Jun 27, 2025
756e1ad
resolve conflict of git rebase
norah-li Jun 27, 2025
578c733
Changes after Michael's code review
fmeheust Jun 27, 2025
dd6be5e
add more test to extended test
norah-li Jun 28, 2025
f5c9cfa
Set search vector as array of float[] insteand of List as string
fmeheust Jul 1, 2025
d20908a
Merge branch 'add-oracle-store' of https://github.com/psilberk/semant…
fmeheust Jul 1, 2025
d6f63a5
Merge pull request #7 from psilberk/add-oracle-store
psilberk Jul 1, 2025
2a8d372
Clean up and remove deps from pom
psilberk Jul 1, 2025
c793b82
Remove unused imports
psilberk Jul 2, 2025
3b299ee
Copyright and license
fmeheust Jul 7, 2025
632e388
Samples
fmeheust Jul 7, 2025
9662092
Merge pull request #8 from psilberk/copyright-and-license
psilberk Jul 7, 2025
129ad0d
Merge branch 'microsoft:main' into main
psilberk Jul 8, 2025
68f7914
Addressing review comments
psilberk Jul 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions data/semantickernel-data-hsqldb/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-data-hsqldb</artifactId>
<name>Semantic Kernel HLSQLDB connector</name>
<description>Provides a HLSQLDB connector for the Semantic Kernel</description>

<dependencies>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-api</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
</dependency>
</dependencies>
</project>
7 changes: 6 additions & 1 deletion data/semantickernel-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC2-SNAPSHOT</version>
<version>1.4.4-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -63,5 +63,10 @@
<artifactId>sqlite-jdbc</artifactId>
<version>3.47.0.0</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>23.7.0.25.01</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public Map<Class<?>, String> getSupportedVectorTypes() {
@Override
public void prepareVectorStore() {
String createCollectionsTable = formatQuery(
"CREATE TABLE IF NOT EXISTS %s (collectionId VARCHAR(255) PRIMARY KEY);",
"CREATE TABLE IF NOT EXISTS %s (collectionId VARCHAR(255) PRIMARY KEY)",
validateSQLidentifier(collectionsTable));

try (Connection connection = dataSource.getConnection();
Expand Down Expand Up @@ -696,10 +696,19 @@ public String getEqualToFilter(EqualToFilterClause filterClause) {
@Override
public String getAnyTagEqualToFilter(AnyTagEqualToFilterClause filterClause) {
String fieldName = JDBCVectorStoreQueryProvider
.validateSQLidentifier(filterClause.getFieldName());
.validateSQLidentifier(filterClause.getFieldName());

return String.format("%s LIKE ?", fieldName);
}

@Override
public <Record> VectorStoreRecordMapper<Record, ResultSet> getVectorStoreRecordMapper(Class<Record> recordClass,
VectorStoreRecordDefinition recordDefinition) {
return JDBCVectorStoreRecordMapper.<Record>builder()
.withRecordClass(recordClass)
.withVectorStoreRecordDefinition(recordDefinition)
.build();
}

/**
* The builder for {@link JDBCVectorStoreQueryProvider}.
Expand Down Expand Up @@ -755,4 +764,6 @@ public JDBCVectorStoreQueryProvider build() {
prefixForCollectionTables);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
package com.microsoft.semantickernel.data.jdbc;

import com.microsoft.semantickernel.builders.SemanticKernelBuilder;
import com.microsoft.semantickernel.data.jdbc.mysql.MySQLVectorStoreQueryProvider;
import com.microsoft.semantickernel.data.jdbc.postgres.PostgreSQLVectorStoreQueryProvider;
import com.microsoft.semantickernel.data.jdbc.postgres.PostgreSQLVectorStoreRecordMapper;
import com.microsoft.semantickernel.data.vectorsearch.VectorSearchResults;
import com.microsoft.semantickernel.data.vectorstorage.VectorStoreRecordCollection;
import com.microsoft.semantickernel.data.vectorstorage.VectorStoreRecordMapper;
Expand Down Expand Up @@ -37,10 +34,10 @@ public class JDBCVectorStoreRecordCollection<Record>
implements SQLVectorStoreRecordCollection<String, Record> {

private final String collectionName;
private final VectorStoreRecordDefinition recordDefinition;
private final VectorStoreRecordMapper<Record, ResultSet> vectorStoreRecordMapper;
protected final VectorStoreRecordDefinition recordDefinition;
protected final VectorStoreRecordMapper<Record, ResultSet> vectorStoreRecordMapper;
private final JDBCVectorStoreRecordCollectionOptions<Record> options;
private final SQLVectorStoreQueryProvider queryProvider;
protected final SQLVectorStoreQueryProvider queryProvider;

/**
* Creates a new instance of the {@link JDBCVectorStoreRecordCollection}.
Expand Down Expand Up @@ -73,25 +70,9 @@ public JDBCVectorStoreRecordCollection(

// If mapper is not provided, set a default one
if (options.getVectorStoreRecordMapper() == null) {
// Default mapper for PostgreSQL
if (this.queryProvider instanceof PostgreSQLVectorStoreQueryProvider) {
vectorStoreRecordMapper = PostgreSQLVectorStoreRecordMapper.<Record>builder()
.withRecordClass(options.getRecordClass())
.withVectorStoreRecordDefinition(recordDefinition)
.build();
// Default mapper for MySQL
} else if (this.queryProvider instanceof MySQLVectorStoreQueryProvider) {
vectorStoreRecordMapper = JDBCVectorStoreRecordMapper.<Record>builder()
.withRecordClass(options.getRecordClass())
.withVectorStoreRecordDefinition(recordDefinition)
.build();
// Default mapper for other databases
} else {
vectorStoreRecordMapper = JDBCVectorStoreRecordMapper.<Record>builder()
.withRecordClass(options.getRecordClass())
.withVectorStoreRecordDefinition(recordDefinition)
.build();
}
vectorStoreRecordMapper = options.getQueryProvider()
.getVectorStoreRecordMapper(options.getRecordClass(),
recordDefinition);
} else {
vectorStoreRecordMapper = options.getVectorStoreRecordMapper();
}
Expand Down Expand Up @@ -214,7 +195,7 @@ protected String getKeyFromRecord(Record data) {
Field keyField = data.getClass()
.getDeclaredField(recordDefinition.getKeyField().getName());
keyField.setAccessible(true);
return (String) keyField.get(data);
return keyField.get(data).toString();
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new SKException("Failed to get key from record", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ <Record> VectorSearchResults<Record> search(String collectionName,
VectorStoreRecordDefinition recordDefinition,
VectorStoreRecordMapper<Record, ResultSet> mapper);

/**
* Gets the record mapper for the given record class and definition.
*
* @param <Record> the record type
* @param recordClass the record class
* @param recordDefinition the record definition
* @return the record mapper that maps JDBC result sets to the given record.
*/
<Record> VectorStoreRecordMapper<Record, ResultSet> getVectorStoreRecordMapper(
final Class<Record> recordClass,
final VectorStoreRecordDefinition recordDefinition);

/**
* The builder for the JDBC vector store query provider.
*/
Expand Down
42 changes: 42 additions & 0 deletions data/semantickernel-data-mysql/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-data-mysql</artifactId>
<name>Semantic Kernel MySQL connector</name>
<description>Provides a MySQL connector for the Semantic Kernel</description>

<dependencies>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-api</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
</dependency>
</dependencies>
</project>
82 changes: 82 additions & 0 deletions data/semantickernel-data-oracle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-parent</artifactId>
<version>1.4.4-RC2-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>semantickernel-data-oracle</artifactId>
<name>Semantic Kernel Oracle connector</name>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add version 0.0.1 and indicate that this is a preview version.

<description>Provides a Oracle connector for the Semantic Kernel</description>

<properties>
<testcontainers.version>1.20.4</testcontainers.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.microsoft.semantic-kernel</groupId>
<artifactId>semantickernel-data-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>23.7.0.25.01</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc-provider-jackson-oson</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-free</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading