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

fix: evadb is now consistent with lowercase #1091

Merged
merged 2 commits into from
Sep 11, 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/binder/binder_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def create_table_catalog_entry_for_data_source(
]
column_list = []
for name, dtype in zip(column_name_list, column_type_list):
column_list.append(ColumnCatalogEntry(name, dtype))
column_list.append(ColumnCatalogEntry(name.lower(), dtype))

# Assemble table.
table_catalog_entry = TableCatalogEntry(
Expand Down Expand Up @@ -339,7 +339,7 @@ def get_column_definition_from_select_target_list(
for col_name, output_obj in output_objs:
binded_col_list.append(
ColumnDefinition(
col_name,
col_name.lower(),
output_obj.type,
output_obj.array_type,
output_obj.array_dimensions,
Expand Down
3 changes: 3 additions & 0 deletions evadb/binder/statement_binder_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def get_binded_column(
A tuple of alias and column object
"""

# binder is case insensitive
col_name = col_name.lower()

def raise_error():
err_msg = f"Found invalid column {col_name}"
logger.error(err_msg)
Expand Down
7 changes: 7 additions & 0 deletions evadb/storage/native_storage_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def read(self, database_name: str, table: TableCatalogEntry) -> Iterator[Batch]:
handler.connect()

data_df = handler.execute_native_query(f"SELECT * FROM {table.name}").data

# Handling case-sensitive databases like SQLite can be tricky. Currently,
# EvaDB converts all columns to lowercase, which may result in issues with
# these databases. As we move forward, we are actively working on improving
# this aspect within Binder.
# For more information, please refer to https://github.com/georgia-tech-db/evadb/issues/1079.
data_df.columns = data_df.columns.str.lower()
yield Batch(pd.DataFrame(data_df))

except Exception as e:
Expand Down
8 changes: 7 additions & 1 deletion evadb/third_party/databases/sqlite/sqlite_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,16 @@ def get_columns(self, table_name: str) -> DBHandlerResponse:

def _fetch_results_as_df(self, cursor):
try:
# Handling case-sensitive databases like SQLite can be tricky. Currently,
# EvaDB converts all columns to lowercase, which may result in issues with
# these databases. As we move forward, we are actively working on improving
# this aspect within Binder.
# For more information, please refer to https://github.com/georgia-tech-db/evadb/issues/1079.

res = cursor.fetchall()
res_df = pd.DataFrame(
res,
columns=[desc[0] for desc in cursor.description]
columns=[desc[0].lower() for desc in cursor.description]
if cursor.description
else [],
)
Expand Down
6 changes: 3 additions & 3 deletions test/third_party_tests/test_native_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _create_table_in_native_database(self):
"""USE test_data_source {
CREATE TABLE test_table (
name VARCHAR(10),
age INT,
Age INT,
comment VARCHAR (100)
)
}""",
Expand All @@ -49,7 +49,7 @@ def _insert_value_into_native_database(self, col1, col2, col3):
self.evadb,
f"""USE test_data_source {{
INSERT INTO test_table (
name, age, comment
name, Age, comment
) VALUES (
'{col1}', {col2}, '{col3}'
)
Expand All @@ -67,7 +67,7 @@ def _drop_table_in_native_database(self):
def _create_evadb_table_using_select_query(self):
execute_query_fetch_all(
self.evadb,
"""CREATE TABLE eva_table AS SELECT name, age FROM test_data_source.test_table;""",
"""CREATE TABLE eva_table AS SELECT name, Age FROM test_data_source.test_table;""",
)

# check if the create table is successful
Expand Down