Skip to content

Commit

Permalink
feat: function_metadata supports boolean and float (georgia-tech-db#1296
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav274 authored and a0x8o committed Oct 30, 2023
1 parent d88cf7e commit e0596f6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions evadb/catalog/models/function_metadata_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from sqlalchemy.orm import relationship

from evadb.catalog.models.base_model import BaseModel
from evadb.catalog.models.utils import FunctionMetadataCatalogEntry
from evadb.catalog.models.utils import FunctionMetadataCatalogEntry, TextPickleType


class FunctionMetadataCatalog(BaseModel):
Expand All @@ -34,7 +34,7 @@ class FunctionMetadataCatalog(BaseModel):
__tablename__ = "function_metadata_catalog"

_key = Column("key", String(100))
_value = Column("value", String(100))
_value = Column("value", TextPickleType())
_function_id = Column(
"function_id", Integer, ForeignKey("function_catalog._row_id")
)
Expand Down
2 changes: 1 addition & 1 deletion evadb/parser/evadb.lark
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function_metadata: function_metadata_key function_metadata_value

function_metadata_key: uid

function_metadata_value: string_literal | decimal_literal
function_metadata_value: constant

vector_store_type: USING (FAISS | QDRANT | PINECONE | PGVECTOR | CHROMADB)

Expand Down
6 changes: 6 additions & 0 deletions evadb/parser/lark_visitor/_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def array_literal(self, tree):
res = ConstantValueExpression(np.array(array_elements), ColumnType.NDARRAY)
return res

def boolean_literal(self, tree):
text = tree.children[0]
if text == "TRUE":
return ConstantValueExpression(True, ColumnType.BOOLEAN)
return ConstantValueExpression(False, ColumnType.BOOLEAN)

def constant(self, tree):
for child in tree.children:
if isinstance(child, Tree):
Expand Down
17 changes: 13 additions & 4 deletions test/integration_tests/long/test_function_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,29 @@ def test_should_create_function_with_metadata(self):
OUTPUT (label NDARRAY STR(10))
TYPE Classification
IMPL 'test/util.py'
CACHE 'TRUE'
BATCH 'FALSE';
CACHE TRUE
BATCH FALSE
INT_VAL 1
FLOAT_VAL 1.5
STR_VAL "gg";
"""
execute_query_fetch_all(self.evadb, create_function_query.format(function_name))

# try fetching the metadata values
entries = self.evadb.catalog().get_function_metadata_entries_by_function_name(
function_name
)
self.assertEqual(len(entries), 2)
self.assertEqual(len(entries), 5)
metadata = [(entry.key, entry.value) for entry in entries]

# metadata ultimately stored as lowercase string literals in metadata
expected_metadata = [("cache", "TRUE"), ("batch", "FALSE")]
expected_metadata = [
("cache", True),
("batch", False),
("int_val", 1),
("float_val", 1.5),
("str_val", "gg"),
]
self.assertEqual(set(metadata), set(expected_metadata))

def test_should_return_empty_metadata_list_for_missing_function(self):
Expand Down

0 comments on commit e0596f6

Please sign in to comment.