Menu
Simba Technologies
Simba Technologies

SimbaEngine X SDK 10.1.3
Developing Drivers for SQL-Capable Data Stores

SimbaEngine X SDK Documentation > Core Features > Adding Custom Metadata Columns

Adding Custom Metadata Columns

Each catalog function returns data as a result set. In addition to the ODBC-standard columns that are returned when a catalog function is executed, the data store can return additional columns. Your custom driver can add custom metadata columns to the Metadata result tables in order to support data source-specific data. The DSIMetadataSource-derived classes support custom columns, which are enabled by proper implementations of several functions. These functions are:

  • GetCustomColumns
  • GetCustomMetadata
Note:
  • All custom metadata columns must be of type DSICustomMetadataColumn. The header file for DSICustomerMetadataColumn can be found at [INSTALL_DIRECTORY]\DataAccessComponents\Include\DSI\Client\DSICustomMetadataColumn.h
  • This feature is only supported in the C++ SDK.

A sample implementation of a custom metadata column for CustomerDSIITablesMetadataSource is shown below. Adding custom metadata columns to any other metadata source follows a similar formula.

To Add Custom Metadata Columns:

  1. Define a custom column tag for the custom column:

    const simba_uint16 CUSTOM_TABLES_COLUMN_TAG = 50;

  2. Define a member variable for the custom column:

    std::vector<Simba::DataSToreInterface::DataEngine::Client::
    DSICustomMetadataColumn*> m_customMetadataColumns;

  3. Initialize the metadata for the custom columns in the CustomerDSIITablesMetadataSource constructor. Use the static MakeNewSqlTypeMetadata function of the Simba::Support::TypedDataWrapper::SqlTypeMetadataFactory class.
  4. using namespace Simba::DSI;

    using namespace Simba::Support;

    DSICustomMetadataColumn* column = NULL;

    DSIColumnMetadata* colMetadata = NULL;

    SqlTypeMetadata* metadata = NULL;

    // Custom column

    colMetadata = new DSIColumnMetadata();

    colMetadata->m_autoUnique = false;

    colMetadata->m_caseSensitive = false;

    colMetadata->m_label = L"CUSTOM_COL";

    colMetadata->m_name = L"CUSTOM_COL";

    colMetadata->m_unnamed = false;

    colMetadata->m_charOrBinarySize = 128;

    colMetadata->m_nullable = DSI_NULLABLE;

    colMetadata->m_searchable = DSI_PRED_NONE;

    colMetadata->m_updatable = DSI_READ_ONLY;

    // Create SqlTypeMetadata*

    metadata = SqlTypeMetadataFactorySingleton::GetInstance()>CreateNewSqlTypeMetadata(SQL_VARCHAR);

    column = new DSICustomMetadataColumn(

    metadata,

    colMetadata,

    CUSTOM_TABLES_COLUMN_TAG);

    m_customColumnMetadata.push_back(column);

  5. For information on DSIColumnMetadata, refer to SimbaEngine Java API Reference or SimbaEngine C++ API Reference.

  6. Implement CustomerDSIITablesMetadataSource::GetCustomColumns:
  7. void CustomerDSIMetadataSource::GetCustomColumns(std::vector<Simba::DSI::DSICustomMetadataColumn*>& out_customColumns)

  8. Iterate over m_customColumns and push them into out_customColumns.

  9. Implement CustomerDSIITablesMetadataSource::GetCustomMetadata:

    bool CustomerDSIITablesMetadataSource:::GetCustomMetadata(

    simba_uint16 in_columnTag,

    SqlData* in_data,

    simba_signed_native in_offset,

    simba_signed_native in_maxSize)

    The implementation is the same as CustomerDSIITablesMetadataSource::GetMetadata except the column tags you check are your custom column tags.For example:

    switch (in_columnTag){

    case CUSTOM_TABLES_COLUMN_TAG:{

    //retrieve the appropriate data from your m_result

    }

    default:{

    //throw exception – metadata column not found.

    }

    }