Skip to content

Commit ca30c37

Browse files
refactor(elasticsearch): implement data catalog compliance via MetaDatabaseHandler
Migrate Elasticsearch handler to inherit from MetaDatabaseHandler to comply with data catalog specifications per review feedback on PR mindsdb#11552. Key changes: - Change base class from DatabaseHandler to MetaDatabaseHandler - Rename methods with meta_ prefix per data catalog API requirements - Add meta_get_tables and meta_get_columns required methods - Update column names to uppercase specification (TABLE_NAME, COLUMN_NAME, etc.) - Calculate NULL_PERCENTAGE as percentage (0.0-100.0) instead of count - Support multiple tables via Optional[List[str]] parameter - Remove data catalog documentation from README - Delete deprecated handler test files, consolidate tests in unit/handlers - Update all 18 unit tests to match new API - Maintain backward compatibility by preserving old methods All tests passing (18/18) and pre-commit checks passed.
1 parent ddde433 commit ca30c37

8 files changed

Lines changed: 252 additions & 1585 deletions

File tree

mindsdb/integrations/handlers/elasticsearch_handler/README.md

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -90,56 +90,6 @@ WHERE product_id = '12345';
9090
The Elasticsearch handler automatically detects and converts array fields to JSON strings for SQL compatibility. This prevents "Arrays not supported" errors while preserving the original data structure.
9191
</Tip>
9292

93-
## Schema Discovery
94-
95-
List available indices and columns:
96-
97-
```sql
98-
-- List all indices (tables)
99-
SELECT table_name FROM information_schema.tables
100-
WHERE table_schema = 'elasticsearch_conn';
101-
102-
-- Get column information
103-
SELECT column_name, data_type FROM information_schema.columns
104-
WHERE table_name = 'products' AND table_schema = 'elasticsearch_conn';
105-
```
106-
107-
## Data Catalog Support
108-
109-
The Elasticsearch handler provides Data Catalog support for enterprise requirements with three key methods:
110-
111-
### Column Statistics
112-
113-
Get detailed statistical information about index fields:
114-
115-
```sql
116-
-- All columns
117-
SELECT * FROM mindsdb.get_column_statistics('elasticsearch_conn', 'products');
118-
119-
-- Specific column
120-
SELECT * FROM mindsdb.get_column_statistics('elasticsearch_conn', 'products', 'price');
121-
```
122-
123-
Returns: `column_name`, `data_type`, `null_count`, `distinct_count`, `min`, `max`, `avg`
124-
125-
Supported field types: numeric (with min/max/avg), keyword, text, date, geo_point, ip, nested objects (flattened with dot notation).
126-
127-
### Primary Keys
128-
129-
```sql
130-
SELECT * FROM mindsdb.get_primary_keys('elasticsearch_conn', 'products');
131-
```
132-
133-
Returns `_id` as the primary key (Elasticsearch's document identifier).
134-
135-
### Foreign Keys
136-
137-
```sql
138-
SELECT * FROM mindsdb.get_foreign_keys('elasticsearch_conn', 'products');
139-
```
140-
141-
Returns empty (NoSQL databases don't have foreign keys).
142-
14393
## Troubleshooting
14494

14595
<Warning>

mindsdb/integrations/handlers/elasticsearch_handler/elasticsearch_handler.py

Lines changed: 200 additions & 65 deletions
Large diffs are not rendered by default.

mindsdb/integrations/handlers/elasticsearch_handler/tests/run_tests.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)