Skip to content
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

feat: function_metadata supports boolean and float #1296

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -51,7 +51,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 @@ -199,20 +199,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