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

Function Changes #1383

Open
wants to merge 15 commits into
base: staging
Choose a base branch
from
Open
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,3 @@ eva_db/*
eva/*

blog.md

tests/integration_tests/short/*.db
8 changes: 2 additions & 6 deletions docs/source/reference/evaql/set_config.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SET CONFIGS
SET CONFIG
==============

.. _set_config:
Expand All @@ -8,8 +8,4 @@ Sets the value of a configuration parameter to the passed value. Both `TO` and `
.. code:: sql

SET OPENAI_KEY TO "abc";
SET OPENAI_KEY = "abc";

.. note::

The `SET` command does not support `CONFIG` or `CONFIGS` as keys names. This is because `CONFIG` and `CONFIGS` are reserved keywords.
SET OPENAI_KEY = "abc";
10 changes: 1 addition & 9 deletions docs/source/reference/evaql/show_config.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SHOW CONFIGS
SHOW CONFIG
==============

.. _show_config:
Expand All @@ -9,11 +9,3 @@ Returns the value of a specified configuration parameter.

SHOW <parameter_name>;
SHOW OPENAI_KEY;

.. _show_configs:

In order to see all the configuration parameters, use the following command:

.. code:: sql

SHOW CONFIGS;
3 changes: 0 additions & 3 deletions evadb/catalog/catalog_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,3 @@ def get_configuration_catalog_value(self, key: str, default: Any = None) -> Any:
if table_entry:
return table_entry.value
return default

def get_all_configuration_catalog_entries(self) -> List:
return self._config_catalog_service.get_all_entries()
2 changes: 2 additions & 0 deletions evadb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
IFRAMES = "IFRAMES"
AUDIORATE = "AUDIORATE"
DEFAULT_FUNCTION_EXPRESSION_COST = 100
DBFUNCTIONS = __file__[0: -13] + "/functions/"
ENVFUNCTIONS = "./Lib/site-packages/evadb/functions/"
6 changes: 0 additions & 6 deletions evadb/evadb_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
"evadb_installation_dir": "",
"datasets_dir": "",
"catalog_database_uri": "",
"index_dir": "",
"cache_dir": "",
"s3_download_dir": "",
"tmp_dir": "",
"function_dir": "",
"model_dir": "",
"application": "evadb",
"mode": "release",
"batch_mem_size": 30000000,
Expand Down
9 changes: 0 additions & 9 deletions evadb/executor/set_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
from evadb.executor.abstract_executor import AbstractExecutor
from evadb.parser.set_statement import SetStatement

RESERVED_CONFIG_KEYWORDS = ["CONFIG", "CONFIGS"]


class SetExecutor(AbstractExecutor):
def __init__(self, db: EvaDBDatabase, node: SetStatement):
Expand All @@ -39,13 +37,6 @@ def exec(self, *args, **kwargs):
will be replaced
"""

if self.node.config_name in RESERVED_CONFIG_KEYWORDS:
raise Exception(
"{} is a reserved keyword for configurations. Please use a word other than the following list: {}".format(
self.node.config_name, RESERVED_CONFIG_KEYWORDS
)
)

self.catalog().upsert_configuration_catalog_entry(
key=self.node.config_name,
value=self.node.config_value.value,
Expand Down
25 changes: 9 additions & 16 deletions evadb/executor/show_info_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def exec(self, *args, **kwargs):
self.node.show_type is ShowType.FUNCTIONS
or ShowType.TABLES
or ShowType.DATABASES
or ShowType.CONFIGS
or ShowType.CONFIG
), f"Show command does not support type {self.node.show_type}"

if self.node.show_type is ShowType.FUNCTIONS:
Expand All @@ -50,23 +50,16 @@ def exec(self, *args, **kwargs):
databases = self.catalog().get_all_database_catalog_entries()
for db in databases:
show_entries.append(db.display_format())
elif self.node.show_type is ShowType.CONFIGS:
elif self.node.show_type is ShowType.CONFIG:
value = self.catalog().get_configuration_catalog_value(
key=self.node.show_val.upper(),
)
show_entries = {}
# CONFIGS is a special word, which is used to display all the configurations
if self.node.show_val.upper() == ShowType.CONFIGS.name:
configs = self.catalog().get_all_configuration_catalog_entries()
for config in configs:
show_entries[config.key] = config.value
if value is not None:
show_entries = {self.node.show_val: [value]}
else:
value = self.catalog().get_configuration_catalog_value(
key=self.node.show_val.upper(),
raise Exception(
"No configuration found with key {}".format(self.node.show_val)
)
show_entries = {}
if value is not None:
show_entries = {self.node.show_val: [value]}
else:
raise Exception(
"No configuration found with key {}".format(self.node.show_val)
)

yield Batch(pd.DataFrame(show_entries))
5 changes: 3 additions & 2 deletions evadb/functions/function_bootstrap_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
NDARRAY_DIR = "ndarray"
TUTORIALS_DIR = "tutorials"


DummyObjectDetector_function_query = """CREATE FUNCTION IF NOT EXISTS DummyObjectDetector
INPUT (Frame_Array NDARRAY INT8(3, ANYDIM, ANYDIM))
OUTPUT (label NDARRAY STR(1))
Expand Down Expand Up @@ -289,8 +290,8 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
stablediffusion_function_query,
dalle_function_query,
Upper_function_query,
Lower_function_query,
Concat_function_query,
Lower_function_query,
]

# if mode is 'debug', add debug functions
Expand All @@ -313,4 +314,4 @@ def init_builtin_functions(db: EvaDBDatabase, mode: str = "debug") -> None:
db, query, do_not_print_exceptions=False, do_not_raise_exceptions=True
)
except Exception:
pass
pass
16 changes: 14 additions & 2 deletions evadb/parser/create_function_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from pathlib import Path
from typing import List, Tuple

from evadb.configuration.constants import EvaDB_INSTALLATION_DIR
from evadb.parser.create_statement import ColumnDefinition
from evadb.parser.select_statement import SelectStatement
from evadb.parser.statement import AbstractStatement
Expand Down Expand Up @@ -64,7 +65,18 @@ def __init__(
self._if_not_exists = if_not_exists
self._inputs = inputs
self._outputs = outputs
self._impl_path = Path(impl_path) if impl_path else None

if impl_path:
if len(str(impl_path)) < 12:
self._impl_path = Path(impl_path)
elif "DBFUNCTIONS" == str(impl_path)[0:11] and (str(impl_path)[11:12] == "." or str(impl_path)[11:12] == "\\" or str(impl_path)[11:12] == "/"):
self._impl_path = Path(str(EvaDB_INSTALLATION_DIR) + "\\functions\\" + str(impl_path)[12:])
elif "ENVFUNCTIONS" == str(impl_path)[0:12] and (str(impl_path)[12:13] == "." or str(impl_path)[12:13] == "\\" or str(impl_path)[12:13] == "/"):
self._impl_path = Path( "..\\functions\\" + str(impl_path)[13:])
else:
self._impl_path = Path(impl_path)
else:
self._impl_path = None
self._function_type = function_type
self._query = query
self._metadata = metadata
Expand Down Expand Up @@ -171,4 +183,4 @@ def __hash__(self) -> int:
self.query,
tuple(self.metadata),
)
)
)
2 changes: 0 additions & 2 deletions evadb/parser/lark_visitor/_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ def aggregate_windowed_function(self, tree):
# Support for COUNT(*)
if token != "*":
agg_func_name = token
elif token == "*":
agg_func_arg = TupleValueExpression(name="_row_id")
else:
agg_func_arg = TupleValueExpression(name="id")

Expand Down
2 changes: 1 addition & 1 deletion evadb/parser/lark_visitor/_show_statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ def show_statement(self, tree):
elif isinstance(token, str) and str.upper(token) == "DATABASES":
return ShowStatement(show_type=ShowType.DATABASES)
elif token is not None:
return ShowStatement(show_type=ShowType.CONFIGS, show_val=self.visit(token))
return ShowStatement(show_type=ShowType.CONFIG, show_val=self.visit(token))
2 changes: 1 addition & 1 deletion evadb/parser/show_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __str__(self):
show_str = "FUNCTIONS"
elif self.show_type == ShowType.TABLES:
show_str = "TABLES"
elif self.show_type == ShowType.CONFIGS:
elif self.show_type == ShowType.CONFIG:
show_str = self.show_val
elif self.show_type == ShowType.DATABASES:
show_str = "DATABASES"
Expand Down
2 changes: 1 addition & 1 deletion evadb/parser/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class FileFormatType(EvaDBEnum):
class ShowType(EvaDBEnum):
FUNCTIONS # noqa: F821
TABLES # noqa: F821
CONFIGS # noqa: F821
CONFIG # noqa: F821
DATABASES # noqa: F821


Expand Down
2 changes: 1 addition & 1 deletion evadb/plan_nodes/show_info_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __str__(self):
return "ShowDatabasePlan"
elif self._show_type == ShowType.TABLES:
return "ShowTablePlan"
elif self._show_type == ShowType.CONFIGS:
elif self._show_type == ShowType.CONFIG:
return "ShowConfigPlan"

def __hash__(self) -> int:
Expand Down
32 changes: 0 additions & 32 deletions test/integration_tests/short/test_select_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,38 +293,6 @@ def test_select_and_groupby_with_sample(self):
expected_batch.project(["FIRST.id", "SEGMENT.data"]),
)

def test_select_and_groupby_and_aggregate_with_pdf(self):
GROUPBY_SIZE = 8
execute_query_fetch_all(self.evadb, "DROP TABLE IF EXISTS MyPDFs;")
# load from directory
pdf_path = (
"test/data/uadetrac/small-data/pdf_data/fall_2023_orientation_document.pdf"
)
load_query = f"LOAD PDF '{pdf_path}' INTO MyPDFs;"
execute_query_fetch_all(self.evadb, load_query)
select_all_query = "SELECT * FROM MyPDFs;"
all_pdf_batch = execute_query_fetch_all(self.evadb, select_all_query)

select_query = (
f"SELECT COUNT(*) FROM MyPDFs GROUP BY '{GROUPBY_SIZE} paragraphs';"
)
actual_batch = execute_query_fetch_all(self.evadb, select_query)

self.assertAlmostEqual(
len(all_pdf_batch),
len(actual_batch) * actual_batch.frames.iloc[0, 0],
None,
None,
GROUPBY_SIZE,
)
self.assertEqual(len(actual_batch), 99)
n = len(actual_batch)
for i in range(n):
self.assertEqual(actual_batch.frames.iloc[i, 0], GROUPBY_SIZE)

# tear down
execute_query_fetch_all(self.evadb, "DROP TABLE IF EXISTS MyPDFs;")

def test_lateral_join_with_unnest_and_sample(self):
query = """SELECT id, label
FROM MyVideo SAMPLE 2 JOIN LATERAL
Expand Down
10 changes: 1 addition & 9 deletions test/integration_tests/short/test_show_info_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import pytest

from evadb.configuration.constants import EvaDB_ROOT_DIR
from evadb.evadb_config import BASE_EVADB_CONFIG
from evadb.functions.function_bootstrap_queries import (
ArrayCount_function_query,
Fastrcnn_function_query,
Expand Down Expand Up @@ -119,6 +118,7 @@ def test_show_tables(self):

def test_show_config_execution(self):
execute_query_fetch_all(self.evadb, "SET OPENAIKEY = 'ABCD';")
#
expected_output = Batch(pd.DataFrame({"OPENAIKEY": ["ABCD"]}))

show_config_value = execute_query_fetch_all(self.evadb, "SHOW OPENAIKEY")
Expand All @@ -128,14 +128,6 @@ def test_show_config_execution(self):
with self.assertRaises(Exception):
execute_query_fetch_all(self.evadb, "SHOW BADCONFIG")

def test_show_all_configs(self):
show_all_config_value = execute_query_fetch_all(self.evadb, "SHOW CONFIGS")

# NOTE :- Since the values of configs like the paths are not user/machine/installation agnostic,
# It doesn't make sense to test for the values. Hence, we are only testing for the keys
columns = show_all_config_value.columns
self.assertEqual(columns == list(BASE_EVADB_CONFIG.keys()), True)

# integration test
def test_show_databases(self):
result = execute_query_fetch_all(self.evadb, "SHOW DATABASES;")
Expand Down
2 changes: 1 addition & 1 deletion test/unit_tests/parser/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ def test_show_config_statement(self):

show_config_stmt = evadb_statement_list[0]

expected_stmt = ShowStatement(show_type=ShowType.CONFIGS, show_val="OPENAIKEY")
expected_stmt = ShowStatement(show_type=ShowType.CONFIG, show_val="OPENAIKEY")

self.assertEqual(show_config_stmt, expected_stmt)

Expand Down