diff --git a/evadb/binder/binder_utils.py b/evadb/binder/binder_utils.py index bb1b36edb..59746445c 100644 --- a/evadb/binder/binder_utils.py +++ b/evadb/binder/binder_utils.py @@ -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( @@ -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, diff --git a/evadb/binder/statement_binder_context.py b/evadb/binder/statement_binder_context.py index b1101a2b3..32dc12c7d 100644 --- a/evadb/binder/statement_binder_context.py +++ b/evadb/binder/statement_binder_context.py @@ -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) diff --git a/evadb/storage/native_storage_engine.py b/evadb/storage/native_storage_engine.py index d56557ed9..f72852402 100644 --- a/evadb/storage/native_storage_engine.py +++ b/evadb/storage/native_storage_engine.py @@ -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: diff --git a/evadb/third_party/databases/sqlite/sqlite_handler.py b/evadb/third_party/databases/sqlite/sqlite_handler.py index 204db36d2..7256280ad 100644 --- a/evadb/third_party/databases/sqlite/sqlite_handler.py +++ b/evadb/third_party/databases/sqlite/sqlite_handler.py @@ -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 [], ) diff --git a/test/third_party_tests/test_native_executor.py b/test/third_party_tests/test_native_executor.py index 7259f4ef0..834f43492 100644 --- a/test/third_party_tests/test_native_executor.py +++ b/test/third_party_tests/test_native_executor.py @@ -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) ) }""", @@ -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}' ) @@ -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