Skip to content

Commit 6752437

Browse files
committed
Add bit and binary_quantize function
1 parent 494d05c commit 6752437

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pgvector-module/src/main/kotlin/griffio/PgVectorModule.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import app.cash.sqldelight.dialect.api.PrimitiveType
66
import app.cash.sqldelight.dialect.api.SqlDelightModule
77
import app.cash.sqldelight.dialect.api.TypeResolver
88
import app.cash.sqldelight.dialect.api.PrimitiveType.BOOLEAN
9+
import app.cash.sqldelight.dialects.postgresql.PostgreSqlType
910
import app.cash.sqldelight.dialects.postgresql.PostgreSqlTypeResolver
1011
import app.cash.sqldelight.dialects.postgresql.grammar.psi.PostgreSqlTypes
1112
import com.alecstrong.sql.psi.core.psi.SqlFunctionExpr
@@ -59,8 +60,9 @@ private class PgVectorTypeResolver(private val parentResolver: TypeResolver) : P
5960

6061
override fun functionType(functionExpr: SqlFunctionExpr): IntermediateType? =
6162
when (functionExpr.functionName.text.lowercase()) {
62-
"subvector" -> IntermediateType(PgVectorSqlType.VECTOR)
63+
"binary_quantize" -> IntermediateType(PostgreSqlType.BIT)
6364
"cosine_distance" -> IntermediateType(PrimitiveType.REAL)
65+
"subvector" -> IntermediateType(PgVectorSqlType.VECTOR)
6466
else -> parentResolver.functionType(functionExpr)
6567
}
6668
}

pgvector-module/src/main/kotlin/griffio/grammar/pgvector.bnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
// PostgreSql type_name will be replaced - need to inline inherited types plus new vector data types
2828
type_name ::= (
2929
vector_data_type |
30+
{bit_data_type}
3031
{small_int_data_type} |
3132
{int_data_type} |
3233
{big_int_data_type} |

0 commit comments

Comments
 (0)