The Metabase OceanBase Plugin is specifically designed for integrating Metabase with OceanBase databases. This plugin supports both MySQL and Oracle compatibility modes of OceanBase, automatically detects database compatibility modes, and adapts corresponding SQL syntax.
| Issue | Description | Solution |
|---|---|---|
| Compatibility Mode Detection | Metabase cannot automatically identify OceanBase's compatibility mode. | Automatically detect compatibility mode via SHOW VARIABLES LIKE 'ob_compatibility_mode'. |
| SQL Syntax Adaptation | SQL syntax differences between compatibility modes cause query failures. | Automatically select appropriate SQL syntax and functions based on detected compatibility mode. |
| Metadata Sync | Unable to correctly retrieve OceanBase table structure and field information. | Implement metadata query logic for both MySQL and Oracle modes. |
| Connection Parameter Config | Missing OceanBase-specific connection parameters and configuration options. | Provide complete OceanBase connection parameter configuration including timeout, reconnection, etc. |
| Data Type Mapping | OceanBase-specific data types cannot be correctly mapped to Metabase. | Implement complete data type mapping table supporting MySQL and Oracle modes. |
- ✅ Automatic Compatibility Mode Detection:Automatically identify OceanBase's MySQL or Oracle compatibility mode by querying
ob_compatibility_modevariable. - ✅ Dual-Mode SQL Adaptation:Automatically select appropriate SQL syntax, functions, and query methods based on detected compatibility mode.
- ✅ Complete Metadata Support:Support correct retrieval and synchronization of table structure, field information, indexes, constraints, and other metadata.
- ✅ Data Type Mapping:Complete support for all data type mappings in OceanBase MySQL and Oracle modes.
- Metabase version ≥ 0.48.0
- Java 11 or higher
- OceanBase version ≥ 3.1.0
The Metabase OceanBase plugin is included in this repository. Navigate to the plugin directory:
cd metabase-oceanbase-plugin# Build OceanBase driver
cd modules/drivers/oceanbase
clojure -M:buildCopy the built plugin file to Metabase's plugin directory:
# Copy plugin to Metabase plugin directory
cp modules/drivers/oceanbase/target/metabase-driver-oceanbase.jar /path/to/metabase/plugins/Start Metabase container:
docker run -d -p 3000:3000 --name metabase metabase/metabaseCopy plugin to container:
docker cp /path/to/oceanbase.metabase-driver.jar metabase:/pluginsRestart container to load plugin:
docker restart metabase- Log in to Metabase admin interface
- Go to Admin → Databases
- Click Add Database
- Select OceanBase as database type
| Parameter Name | Description | Example Value |
|---|---|---|
| Host | OceanBase server address | localhost |
| Port | OceanBase service port (default 2881) | 2881 |
| Database | Database name to connect to | your_database |
| Username | Database username | your_username |
| Password | Database password | your_password |
After configuration, click the Test Connection button to verify if the configuration is correct. The plugin will automatically:
- Detect OceanBase compatibility mode
- Verify connection parameters
- Test basic query functionality
In Native Query mode, you can use SQL syntax corresponding to the compatibility mode:
MySQL Mode Example:
SELECT
user_id,
username,
created_at
FROM users
WHERE created_at >= '2024-01-01'
ORDER BY created_at DESC
LIMIT 100;Oracle Mode Example:
SELECT
user_id,
username,
created_at
FROM users
WHERE created_at >= DATE '2024-01-01'
ORDER BY created_at DESC
FETCH FIRST 100 ROWS ONLY;A1: Solution
- Confirm the database name is correct
- Check if the user has permission to access the database
- Verify OceanBase service is running normally
-- Check if database exists
SHOW DATABASES;
-- Check user permissions
SHOW GRANTS FOR 'your_username'@'%';A2: Solution
-
Adjust connection timeout parameters:
connectTimeout=60000 socketTimeout=60000
-
Optimize query statements and add appropriate indexes
-
Check OceanBase server performance
We welcome contributions to help improve plugin functionality.
This project is licensed under the Apache License 2.0.
Through this plugin, Metabase can seamlessly connect to OceanBase databases, achieving efficient data analysis and visualization functionality.